Documentation ¶
Index ¶
- Constants
- func ContextWithEnvPropagation(parent context.Context) context.Context
- func JaegerSetup(name string, with ...setupOptionFunc) (tp *trace.TracerProvider, closer closerFunc, err error)
- func MapCarrierAsEnviron(mc propagation.MapCarrier) []string
- func WithAgentExporter() setupOptionFunc
- func WithEnvGate() setupOptionFunc
- func WithGeneralPropagatorSetup() setupOptionFunc
- func WithLogger(logger logr.Logger) setupOptionFunc
- func WithRemoteSampler() setupOptionFunc
- func WithSampler(s trace.Sampler) setupOptionFunc
- func WithShutdownTimeout(t time.Duration) setupOptionFunc
- type EnvironCarrier
- type UberTraceContext
Constants ¶
const EnvGateCue = "true"
const EnvGateName = "JAEGER_ENABLED"
const EnvSamplerTemplateName = "OTEL_SAMPLER_JAEGER_CONFIG_URL_TEMPLATE"
const EnvironCarrierPrefix = "OTELTEXTMAP_" // exactly 1 underscore, trailing
EnvironCarrierPrefix defines the prefix we attach to carrier key names to store them in the process environment.
Variables ¶
This section is empty.
Functions ¶
func ContextWithEnvPropagation ¶
ContextWithEnvPropagation returns a copy of a parent Context with trace context propagation from the process environment.
func JaegerSetup ¶
func JaegerSetup(name string, with ...setupOptionFunc) ( tp *trace.TracerProvider, closer closerFunc, err error, )
JaegerSetup returns a jaeger TracerProvider and a closer function to shut down the provider.
Options order can be important. For example, WithRemoteSampler sets the sampler to one that falls back to any existing sampler, whilst WithSampler sets the sampler to the passed argument and overwrites the existing sampler.
It's a good idea to pass WithLogger first, so errors raised by subsequent options will be sent to that callback.
func MapCarrierAsEnviron ¶
func MapCarrierAsEnviron(mc propagation.MapCarrier) []string
MapCarrierAsEnviron returns the contents of a MapCarrier as a slice of "key=value" strings, suitable for e.g. os.exec.Cmd.Env
func WithAgentExporter ¶
func WithAgentExporter() setupOptionFunc
WithAgentExpoter causes JaegerSetup to configure an exporter targeting the Jaeger agent endpoint
func WithEnvGate ¶
func WithEnvGate() setupOptionFunc
WithEnvGate causes a call to JaegerSetup to be a no-op unless the environment variable defined by EnvGatename is set to the value defined by EnvGateCue
func WithGeneralPropagatorSetup ¶
func WithGeneralPropagatorSetup() setupOptionFunc
WithGeneralPropagatorSetup causes JaegerSetup to configure the default propagator with some basic propagators
func WithLogger ¶
WithLogger configures the given logger to be used for printing errors or info at runtime emitted by the tracer implementation. If unset, a default value of github.com/go-logr/stdr.New(log.Default()) will be used.
func WithRemoteSampler ¶
func WithRemoteSampler() setupOptionFunc
WithRemoteSampler causes JaegerSetup to configure Jaeger with a remote sampler URL constructed using the environment variable defined by EnvSamplerTemplateName, falling back to any previously configured sampler
func WithSampler ¶
WithSampler causes JaegerSetup to configure Jaeger with the provided sampler only
func WithShutdownTimeout ¶
WithShutdownTimeout limits the amount of time that the close function returned by JaegerSetup may wait
Types ¶
type EnvironCarrier ¶
type EnvironCarrier struct{}
EnvironCarrier provides a TextMapCarrier interface to the process environment.
func (EnvironCarrier) Get ¶
func (e EnvironCarrier) Get(key string) string
func (EnvironCarrier) Keys ¶
func (e EnvironCarrier) Keys() []string
func (EnvironCarrier) Set ¶
func (e EnvironCarrier) Set(key string, value string)
type UberTraceContext ¶
type UberTraceContext struct{}
UberTraceContext is a propagator that supports the "Jaeger native propagation format", better known as the "uber-trace-id" header. See: https://www.jaegertracing.io/docs/1.40/client-libraries/#propagation-format
UberTraceContext will propagate the uber-trace-id header to guarantee traces employing this type of header are not broken. It is up to the users of this propagator to choose if they want to participate in a trace by modifying the uber-trace-id header and relevant parts of the uber-trace-id header containing their proprietary information.
UberTraceContext operates on the came principle as the upstream TraceContext propagator, which injects and extracts the "W3C trace context format", better known as the "traceparent" header.
When a CompositeTextMapPropagator combines TraceContext and UberTraceContext propagators, SpanContexts will be propagated forward as both types of header, and both inbound header types will be extractable into a local SpanContext (with the later-defined propagator's header taking overriding precedence).
func (UberTraceContext) Extract ¶
func (tc UberTraceContext) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
Extract reads uber-trace-id from the carrier into a returned Context.
The returned Context will be a copy of ctx and contain the extracted uber-trace-id as the remote SpanContext. If the extracted uber-trace-id is invalid, the passed ctx will be returned directly instead.
func (UberTraceContext) Fields ¶
func (tc UberTraceContext) Fields() []string
Fields returns the keys whose values are set with Inject.
func (UberTraceContext) Inject ¶
func (tc UberTraceContext) Inject(ctx context.Context, carrier propagation.TextMapCarrier)
Inject sets uber-trace-id from the Context into the carrier.