package baggage
import "go.opentelemetry.io/otel/baggage"
Package baggage provides functionality for storing and retrieving baggage items in Go context. For propagating the baggage, see the go.opentelemetry.io/otel/propagation package.
This package is currently in a Release Candidate phase. Backwards incompatible changes may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
Index ¶
- func ContextWithBaggage(parent context.Context, b Baggage) context.Context
- func ContextWithoutBaggage(parent context.Context) context.Context
- type Baggage
- func FromContext(ctx context.Context) Baggage
- func New(members ...Member) (Baggage, error)
- func Parse(bStr string) (Baggage, error)
- func (b Baggage) DeleteMember(key string) Baggage
- func (b Baggage) Len() int
- func (b Baggage) Member(key string) Member
- func (b Baggage) Members() []Member
- func (b Baggage) SetMember(member Member) (Baggage, error)
- func (b Baggage) String() string
- type Member
- func NewMember(key, value string, props ...Property) (Member, error)
- func (m Member) Key() string
- func (m Member) Properties() []Property
- func (m Member) String() string
- func (m Member) Value() string
- type Property
Functions ¶
func ContextWithBaggage ¶
ContextWithBaggage returns a copy of parent with baggage.
func ContextWithoutBaggage ¶
ContextWithoutBaggage returns a copy of parent with no baggage.
Types ¶
type Baggage ¶
type Baggage struct {
// contains filtered or unexported fields
}
Baggage is a list of baggage members representing the baggage-string as defined by the W3C Baggage specification.
func FromContext ¶
FromContext returns the baggage contained in ctx.
func New ¶
New returns a new valid Baggage. It returns an error if the passed members are invalid according to the W3C Baggage specification or if it results in a Baggage exceeding limits set in that specification.
func Parse ¶
Parse attempts to decode a baggage-string from the passed string. It returns an error if the input is invalid according to the W3C Baggage specification.
If there are duplicate list-members contained in baggage, the last one defined (reading left-to-right) will be the only one kept. This diverges from the W3C Baggage specification which allows duplicate list-members, but conforms to the OpenTelemetry Baggage specification.
func (Baggage) DeleteMember ¶
DeleteMember returns a copy of the Baggage with the list-member identified by key removed.
func (Baggage) Len ¶
Len returns the number of list-members in the Baggage.
func (Baggage) Member ¶
Member returns the baggage list-member identified by key.
If there is no list-member matching the passed key the returned Member will be a zero-value Member.
func (Baggage) Members ¶
Members returns all the baggage list-members. The order of the returned list-members does not have significance.
func (Baggage) SetMember ¶
SetMember returns a copy the Baggage with the member included. If the baggage contains a Member with the same key the existing Member is replaced.
If member is invalid according to the W3C Baggage specification, an error is returned with the original Baggage.
func (Baggage) String ¶
String encodes Baggage into a string compliant with the W3C Baggage specification. The returned string will be invalid if the Baggage contains any invalid list-members.
type Member ¶
type Member struct {
// contains filtered or unexported fields
}
Member is a list-member of a baggage-string as defined by the W3C Baggage specification.
func NewMember ¶
NewMember returns a new Member from the passed arguments. An error is returned if the created Member would be invalid according to the W3C Baggage specification.
func (Member) Key ¶
Key returns the Member key.
func (Member) Properties ¶
Properties returns a copy of the Member properties.
func (Member) String ¶
String encodes Member into a string compliant with the W3C Baggage specification.
func (Member) Value ¶
Value returns the Member value.
type Property ¶
type Property struct {
// contains filtered or unexported fields
}
Property is an additional metadata entry for a baggage list-member.
func NewKeyProperty ¶
func NewKeyValueProperty ¶
func (Property) Key ¶
Key returns the Property key.
func (Property) String ¶
String encodes Property into a string compliant with the W3C Baggage specification.
func (Property) Value ¶
Value returns the Property value. Additionally a boolean value is returned indicating if the returned value is the empty if the Property has a value that is empty or if the value is not set.
Source Files ¶
baggage.go context.go doc.go
- Version
- v1.0.0-RC1
- Published
- Jun 18, 2021
- Platform
- darwin/amd64
- Imports
- 7 packages
- Last checked
- 32 minutes ago –
Tools for package owners.