Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

baggage

v1.47.0
go.opentelemetry.io/otel/internal/baggage

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

16 matches

Top ↑

Package baggage provides base types and functionality to store and retrieve baggage in Go context. This package exists because the OpenTracing bridge to OpenTelemetry needs to synchronize state whenever baggage for a context is modified and that context contains an OpenTracing span. If it were not for this need this package would not need to exist and the `go.opentelemetry.io/otel/baggage` package would be the singular place where W3C baggage is handled.

Functions

ContextWithGetHook

func ContextWithGetHook(parent context.Context, hook GetHookFunc) context.Context

ContextWithGetHook returns a copy of parent with hook configured to be invoked every time FromContext is called.

Passing nil GetHookFunc creates a context with no get hook to call.

ContextWithList

func ContextWithList(parent context.Context, list List) context.Context

ContextWithList returns a copy of parent with baggage. Passing nil list returns a context without any baggage.

ContextWithSetHook

func ContextWithSetHook(parent context.Context, hook SetHookFunc) context.Context

ContextWithSetHook returns a copy of parent with hook configured to be invoked every time ContextWithBaggage is called.

Passing nil SetHookFunc creates a context with no set hook to call.

Types

GetHookFunc

type GetHookFunc func(context.Context, List) List

GetHookFunc is a callback called when getting baggage from the context.

Item

type Item struct {
	// contains filtered or unexported fields
}

Item is the value and metadata or properties part of a list-member. Metadata and properties are mutually exclusive representations.

NewItemWithMetadata

func NewItemWithMetadata(value, metadata string) Item

NewItemWithMetadata returns an Item with opaque W3C metadata.

NewItemWithProperties

func NewItemWithProperties(value string, properties []Property) Item

NewItemWithProperties returns an Item with materialized properties.

Item.Metadata

func (i Item) Metadata() string

Metadata returns the opaque W3C metadata of i. It is empty for an Item created with properties.

Item.Properties

func (i Item) Properties() []Property

Properties returns the materialized properties of i. It is nil for an Item created with metadata.

Item.Value

func (i Item) Value() string

Value returns the value of i.

List

type List map[string]Item

List is the collection of baggage members. The W3C allows for duplicates, but OpenTelemetry does not, therefore, this is represented as a map.

ListFromContext

func ListFromContext(ctx context.Context) List

ListFromContext returns the baggage contained in ctx.

Property

type Property struct {
	Key, Value string

	// HasValue indicates if a zero-value value means the property does not
	// have a value or if it was the zero-value.
	HasValue bool
}

Property is a metadata entry for a list-member.

SetHookFunc

type SetHookFunc func(context.Context, List) context.Context

SetHookFunc is a callback called when storing baggage in the context.

Dependency graph