opentelemetry.context package¶
Submodules¶
Module contents¶
- opentelemetry.context.create_key(keyname)[source]¶
To allow cross-cutting concern to control access to their local state, the RuntimeContext API provides a function which takes a keyname as input, and returns a unique key. :type keyname:
str
:param keyname: The key name is for debugging purposes and is not required to be unique.- Return type
str
- Returns
A unique string representing the newly created key.
- opentelemetry.context.get_value(key, context=None)[source]¶
To access the local state of a concern, the RuntimeContext API provides a function which takes a context and a key as input, and returns a value.
- Parameters
key (
str
) – The key of the value to retrieve.context (
Optional
[Context
]) – The context from which to retrieve the value, if None, the current context is used.
- Return type
object
- Returns
The value associated with the key.
- opentelemetry.context.set_value(key, value, context=None)[source]¶
To record the local state of a cross-cutting concern, the RuntimeContext API provides a function which takes a context, a key, and a value as input, and returns an updated context which contains the new value.
- opentelemetry.context.get_current()[source]¶
To access the context associated with program execution, the Context API provides a function which takes no arguments and returns a Context.