Class B3Propagator

  • All Implemented Interfaces:
    io.opentelemetry.context.propagation.TextMapPropagator

    @Immutable
    public final class B3Propagator
    extends Object
    implements io.opentelemetry.context.propagation.TextMapPropagator
    Implementation of the B3 propagation protocol. See openzipkin/b3-propagation.

    Also see B3 Requirements

    To register the default B3 propagator, which injects a single header, use:

    
     OpenTelemetry.setPropagators(
       DefaultContextPropagators
         .builder()
         .addTextMapPropagator(B3Propagator.injectingSingleHeader())
         .build());
     

    To register a B3 propagator that injects multiple headers, use:

    
     OpenTelemetry.setPropagators(
       DefaultContextPropagators
         .builder()
         .addTextMapPropagator(B3Propagator.injectingMultiHeaders())
         .build());
     
    • Method Detail

      • injectingMultiHeaders

        public static B3Propagator injectingMultiHeaders()
        Returns an instance of the B3Propagator that injects multi headers format.

        This instance extracts both formats, in the order: single header, multi header.

        Returns:
        an instance of the B3Propagator that injects multi headers format.
      • injectingSingleHeader

        public static B3Propagator injectingSingleHeader()
        Returns an instance of the B3Propagator that injects single header format.

        This instance extracts both formats, in the order: single header, multi header.

        This is the default instance for B3Propagator.

        Returns:
        an instance of the B3Propagator that injects single header format.
      • fields

        public Collection<String> fields()
        Specified by:
        fields in interface io.opentelemetry.context.propagation.TextMapPropagator
      • inject

        public <C> void inject​(io.opentelemetry.context.Context context,
                               @Nullable
                               C carrier,
                               io.opentelemetry.context.propagation.TextMapSetter<C> setter)
        Specified by:
        inject in interface io.opentelemetry.context.propagation.TextMapPropagator
      • extract

        public <C> io.opentelemetry.context.Context extract​(io.opentelemetry.context.Context context,
                                                            @Nullable
                                                            C carrier,
                                                            io.opentelemetry.context.propagation.TextMapGetter<C> getter)
        Specified by:
        extract in interface io.opentelemetry.context.propagation.TextMapPropagator