b3

package module
v0.0.0-...-806a58a Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package b3 implements the B3 propagator specification as defined at https://github.com/openzipkin/b3-propagation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New creates a B3 implementation of propagation.TextMapPropagator. B3 propagator serializes SpanContext to/from B3 Headers. This propagator supports both versions of B3 headers,

  1. Single Header: b3: {TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
  2. Multiple Headers: x-b3-traceid: {TraceId} x-b3-parentspanid: {ParentSpanId} x-b3-spanid: {SpanId} x-b3-sampled: {SamplingState} x-b3-flags: {DebugFlag}

The Single Header propagator is used by default.

Example
package main

import (
	"go.opentelemetry.io/contrib/propagators/b3"
	"go.opentelemetry.io/otel"
)

func main() {
	p := b3.New()
	// Register the B3 propagator globally.
	otel.SetTextMapPropagator(p)
}
Output:

Example (InjectEncoding)
package main

import (
	"go.opentelemetry.io/contrib/propagators/b3"
	"go.opentelemetry.io/otel"
)

func main() {
	// Create a B3 propagator configured to inject context with both multiple
	// and single header B3 HTTP encoding.
	p := b3.New(b3.WithInjectEncoding(b3.B3MultipleHeader | b3.B3SingleHeader))
	otel.SetTextMapPropagator(p)
}
Output:

func SemVersion deprecated

func SemVersion() string

SemVersion is the semantic version to be supplied to tracer/meter creation.

Deprecated: Use Version instead.

func Version

func Version() string

Version is the current release version of the B3 propagator.

Types

type Encoding

type Encoding uint8

Encoding is a bitmask representation of the B3 encoding type.

const (
	// B3Unspecified is an unspecified B3 encoding.
	B3Unspecified Encoding = 0
	// B3MultipleHeader is a B3 encoding that uses multiple headers to
	// transmit tracing information all prefixed with `x-b3-`.
	//    x-b3-traceid: {TraceId}
	//    x-b3-parentspanid: {ParentSpanId}
	//    x-b3-spanid: {SpanId}
	//    x-b3-sampled: {SamplingState}
	//    x-b3-flags: {DebugFlag}
	B3MultipleHeader Encoding = 1 << iota
	// B3SingleHeader is a B3 encoding that uses a single header named `b3`
	// to transmit tracing information.
	//    b3: {TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
	B3SingleHeader
)

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option interface used for setting optional config properties.

func WithInjectEncoding

func WithInjectEncoding(encoding Encoding) Option

WithInjectEncoding sets the encoding the propagator will inject. The encoding is interpreted as a bitmask. Therefore

WithInjectEncoding(B3SingleHeader | B3MultipleHeader)

means the propagator will inject both single and multi B3 headers.

Jump to

Keyboard shortcuts

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