instrument_baggage (instrument v1.0.0)
View SourceBaggage propagation for OpenTelemetry-compatible instrumentation.
Baggage is used to propagate key-value pairs across service boundaries. It is stored as part of the context and can be encoded/decoded using W3C Baggage format.
Summary
Functions
Clears all baggage.
Decodes W3C Baggage header format to baggage. Stops adding entries past the spec-mandated maximums (180 entries / 8192 bytes).
Encodes baggage to W3C Baggage header format. Format: key1=value1;metadata1,key2=value2
Extracts baggage from a context.
Gets a value from the current baggage.
Gets a value from the current baggage with a default.
Gets all baggage entries.
Removes a key from the current baggage.
Sets a value in the current baggage (no metadata).
Sets a value in the current baggage with metadata. No-op if it would push the baggage over the W3C entry-count or byte-size limits and the key is not already present (updates to existing keys are always accepted).
Puts baggage into a context.
Types
-type baggage() :: #{baggage_key() => baggage_entry()}.
-type baggage_entry() :: {baggage_value(), metadata()}.
Functions
-spec clear() -> ok.
Clears all baggage.
Decodes W3C Baggage header format to baggage. Stops adding entries past the spec-mandated maximums (180 entries / 8192 bytes).
Encodes baggage to W3C Baggage header format. Format: key1=value1;metadata1,key2=value2
-spec from_context(instrument_context:context()) -> baggage().
Extracts baggage from a context.
-spec get(baggage_key()) -> baggage_value() | undefined.
Gets a value from the current baggage.
-spec get(baggage_key(), term()) -> baggage_value() | term().
Gets a value from the current baggage with a default.
-spec get_all() -> #{baggage_key() => baggage_value()}.
Gets all baggage entries.
-spec remove(baggage_key()) -> ok.
Removes a key from the current baggage.
-spec set(baggage_key(), baggage_value()) -> ok.
Sets a value in the current baggage (no metadata).
-spec set(baggage_key(), baggage_value(), metadata()) -> ok.
Sets a value in the current baggage with metadata. No-op if it would push the baggage over the W3C entry-count or byte-size limits and the key is not already present (updates to existing keys are always accepted).
-spec to_context(instrument_context:context(), baggage()) -> instrument_context:context().
Puts baggage into a context.