autoprop

package module
v0.0.0-...-1e3363d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package autoprop provides an OpenTelemetry TextMapPropagator creation function. The OpenTelemetry specification states that the default TextMapPropagator needs to be a no-operation implementation. The opentelemetry-go project adheres to this requirement. However, for systems that perform propagation this default is not ideal. This package provides a TextMapPropagator with useful defaults (a combined TraceContext and Baggage TextMapPropagator), and supports environment overrides using the OTEL_PROPAGATORS environment variable.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTextMapPropagator

func NewTextMapPropagator(props ...propagation.TextMapPropagator) propagation.TextMapPropagator

NewTextMapPropagator returns a new TextMapPropagator composited by props or one defined by the OTEL_PROPAGATORS environment variable. The TextMapPropagator defined by OTEL_PROPAGATORS, if set, will take precedence to the once composited by props.

The propagators supported with the OTEL_PROPAGATORS environment variable by default are: tracecontext, baggage, b3, b3multi, jaeger, xray, ottrace, and none. Each of these values, and their combination, are supported in conformance with the OpenTelemetry specification. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#general-sdk-configuration for more information.

The supported environment variable propagators can be extended to include custom 3rd-party TextMapPropagator. See the RegisterTextMapPropagator function for more information.

If OTEL_PROPAGATORS is not defined and props is no provided, the returned TextMapPropagator will be a composite of the TraceContext and Baggage propagators.

Example
Output:

[baggage traceparent tracestate]
Example (Arguments)
Output:

[baggage traceparent tracestate x-b3-flags x-b3-sampled x-b3-spanid x-b3-traceid]
Example (Environment)
Output:

[baggage x-b3-flags x-b3-sampled x-b3-spanid x-b3-traceid]

func RegisterTextMapPropagator

func RegisterTextMapPropagator(name string, p propagation.TextMapPropagator)

RegisterTextMapPropagator sets the TextMapPropagator p to be used when the OTEL_PROPAGATORS environment variable contains the propagator name. This will panic if name has already been registered or is a default (tracecontext, baggage, b3, b3multi, jaeger, xray, or ottrace).

Example
Output:

[my-header-val]

func TextMapPropagator

func TextMapPropagator(names ...string) (propagation.TextMapPropagator, error)

TextMapPropagator returns a TextMapPropagator composed from the passed names of registered TextMapPropagators. Each name must match an already registered TextMapPropagator (see the RegisterTextMapPropagator function for more information) or a default (tracecontext, baggage, b3, b3multi, jaeger, xray, or ottrace).

If "none" is included in the arguments, or no names are provided, the returned TextMapPropagator will be a no-operation implementation.

An error is returned for any un-registered names. The remaining, known, names will be used to compose a TextMapPropagator that is returned with the error.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL