Package io.grpc.opentelemetry
Class GrpcTraceBinContextPropagator
- java.lang.Object
-
- io.grpc.opentelemetry.GrpcTraceBinContextPropagator
-
- All Implemented Interfaces:
io.opentelemetry.context.propagation.TextMapPropagator
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/11400") public final class GrpcTraceBinContextPropagator extends java.lang.Object implements io.opentelemetry.context.propagation.TextMapPropagator
ATextMapPropagator
for transmitting "grpc-trace-bin" span context.This propagator can transmit the "grpc-trace-bin" context in either binary or Base64-encoded text format, depending on the capabilities of the provided
TextMapGetter
andTextMapSetter
.If the
TextMapGetter
andTextMapSetter
only support text format, Base64 encoding and decoding will be used when communicating with the carrier API. But gRPC uses it with gRPC's metadata-based getter/setter, and the propagator can directly transmit the binary header, avoiding the need for Base64 encoding.
-
-
Field Summary
Fields Modifier and Type Field Description private io.grpc.Metadata.BinaryMarshaller<io.opentelemetry.api.trace.SpanContext>
binaryFormat
static java.lang.String
GRPC_TRACE_BIN_HEADER
private static GrpcTraceBinContextPropagator
INSTANCE
private static java.util.logging.Logger
log
-
Constructor Summary
Constructors Constructor Description GrpcTraceBinContextPropagator(io.grpc.Metadata.BinaryMarshaller<io.opentelemetry.api.trace.SpanContext> binaryFormat)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GrpcTraceBinContextPropagator
defaultInstance()
<C> io.opentelemetry.context.Context
extract(io.opentelemetry.context.Context context, C carrier, io.opentelemetry.context.propagation.TextMapGetter<C> getter)
java.util.Collection<java.lang.String>
fields()
<C> void
inject(io.opentelemetry.context.Context context, C carrier, io.opentelemetry.context.propagation.TextMapSetter<C> setter)
-
-
-
Field Detail
-
log
private static final java.util.logging.Logger log
-
GRPC_TRACE_BIN_HEADER
public static final java.lang.String GRPC_TRACE_BIN_HEADER
- See Also:
- Constant Field Values
-
binaryFormat
private final io.grpc.Metadata.BinaryMarshaller<io.opentelemetry.api.trace.SpanContext> binaryFormat
-
INSTANCE
private static final GrpcTraceBinContextPropagator INSTANCE
-
-
Method Detail
-
defaultInstance
public static GrpcTraceBinContextPropagator defaultInstance()
-
fields
public java.util.Collection<java.lang.String> fields()
- Specified by:
fields
in interfaceio.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 interfaceio.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 interfaceio.opentelemetry.context.propagation.TextMapPropagator
-
-