baggage

package
v0.0.0-...-630b001 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package baggage provides an implementation of storing trace-level context data, i.e. baggage. Unlike OpenTelemetry's implementation of baggage, this baggage is only propagated to child spans of the current local process. Information is not propagated with any external calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithAttributes

func ContextWithAttributes(ctx context.Context, attributes []attribute.KeyValue) context.Context

ContextWithAttributes returns a copy of ctx with attributes set.

func ContextWithBaggage

func ContextWithBaggage(ctx context.Context, tv Baggage) context.Context

ContextWithBaggage returns a copy of ctx with baggage.

func ContextWithoutBaggage

func ContextWithoutBaggage(ctx context.Context) context.Context

ContextWithoutBaggage returns a copy of ctx with no baggage.

Types

type Baggage

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

An immutable object safe for concurrent use.

func BaggageFromContext

func BaggageFromContext(ctx context.Context) Baggage

FromContext returns the baggage contained in ctx.

func NewBaggage

func NewBaggage() Baggage

NewBaggage creates a properly-constructed Baggage.

func (Baggage) Attributes

func (mb Baggage) Attributes() []attribute.KeyValue

Attributes returns a copy of the key-value attributes contained.

func (Baggage) Delete

func (mb Baggage) Delete(key attribute.Key) Baggage

Delete removes the provided key, returning a new copy of Baggage. The new Baggage copy is returned that should be used.

func (Baggage) Get

func (mb Baggage) Get(key attribute.Key) attribute.Value

Get returns the value of the given key. If the key does not exist, the default value is returned.

func (Baggage) Keys

func (mb Baggage) Keys() []attribute.Key

Keys returns a copy of the keys contained.

func (Baggage) Len

func (mb Baggage) Len() int

Len returns the number of attributes contained.

func (Baggage) Lookup

func (mb Baggage) Lookup(key attribute.Key) (val attribute.Value, ok bool)

Lookup returns the value of the given key. If the key does not exist, the boolean value returned is false.

func (Baggage) Set

func (mb Baggage) Set(keyValue ...attribute.KeyValue) Baggage

Set sets the provided key value pairs, returning a new copy of Baggage. For any existing keys, the value is overridden.

Jump to

Keyboard shortcuts

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