npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@opentelemetry/propagator-b3

v1.30.0

Published

OpenTelemetry B3 propagator provides context propagation for systems that are using the B3 header format

Downloads

16,281,992

Readme

OpenTelemetry Propagator B3

NPM Published Version Apache License

The OpenTelemetry b3 propagator package provides multiple propagator implementations for systems using the b3 context format. See the b3 specification for complete details.

B3 Formats

Single-Header Format:

b3: {TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}

Multi-Header Format:

X-B3-TraceId: {TraceId}
X-B3-SpanId: {SpanId}
X-B3-ParentSpanId: {ParentSpanId}
X-B3-Sampled: {SamplingState}
  • {TraceId}

    • Required
    • Encoded as 32 or 16 lower-hex characters
    • 16 character traceIds will be converted to 32 characters by left-padding with 0s to conform with the OpenTelemetry specification
  • {SpanId}

    • Required
    • Encoded as 16 lower-hex characters
  • {ParentSpanId}

    • Optional
    • Used to support the Zipkin functionality where the client and server spans that make up an HTTP request share the same id
    • Not propagated by this library
  • {SamplingState} - Single-header

    • Optional
    • Valid values
      • 1 - Accept
      • 0 - Deny
      • d - Debug
      • Absent - Defer sampling decision
  • {SamplingState} - Multi-header

    • Optional
    • Valid values
      • 1 - Accept
      • 0 - Deny
  • {Flags} - Multi-header

    • Optional
    • Debug is encoded as X-B3-Flags: 1. Absent or any other value can be ignored. Debug implies an accept decision, so don't also send the X-B3-Sampled header.

B3 Propagation

The default B3Propagator implements b3 propagation according to the OpenTelemetry specification. It extracts b3 context from multi and single header encodings and injects context using the single-header b3 encoding by default. The inject encoding can be changed to multi-header via configuration. See the examples below.

B3 Single-Header Configuration

const api = require('@opentelemetry/api');
const { B3Propagator } = require('@opentelemetry/propagator-b3');

api.propagation.setGlobalPropagator(new B3Propagator());

B3 Multi-Header Configuration

const api = require('@opentelemetry/api');
const { B3Propagator, B3InjectEncoding } = require('@opentelemetry/propagator-b3');

api.propagation.setGlobalPropagator(
  new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })
);

B3 Single and Multi-Header Configuration

The B3Propagator always extracts both the single and multi-header b3 encodings. If you need to inject both encodings this can accomplished using a composite propagator.

const api = require('@opentelemetry/api');
const { CompositePropagator } = require('@opentelemetry/core');
const { B3Propagator, B3InjectEncoding } = require('@opentelemetry/propagator-b3');
api.propagation.setGlobalPropagator(
  new CompositePropagator({
    propagators: [
      new B3Propagator(),
      new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
    ],
  })
);

Useful links

License

Apache 2.0 - See LICENSE for more information.