opentelemetry.baggage package

Module contents

opentelemetry.baggage.get_all(context=None)[source]

Returns the name/value pairs in the Baggage

Parameters

context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Mapping[str, object]

Returns

The name/value pairs in the Baggage

opentelemetry.baggage.get_baggage(name, context=None)[source]

Provides access to the value for a name/value pair in the Baggage

Parameters
  • name (str) – The name of the value to retrieve

  • context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Optional[object]

Returns

The value associated with the given name, or null if the given name is not present.

opentelemetry.baggage.set_baggage(name, value, context=None)[source]

Sets a value in the Baggage

Parameters
  • name (str) – The name of the value to set

  • value (object) – The value to set

  • context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Context

Returns

A Context with the value updated

opentelemetry.baggage.remove_baggage(name, context=None)[source]

Removes a value from the Baggage

Parameters
  • name (str) – The name of the value to remove

  • context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Context

Returns

A Context with the name/value removed

opentelemetry.baggage.clear(context=None)[source]

Removes all values from the Baggage

Parameters

context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Context

Returns

A Context with all baggage entries removed