opentelemetry.context package
Module contents
- class opentelemetry.context.Context[source]
-
- setdefault(key, default=None)[source]
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- Return type:
- pop(key, *args)[source]
If the key is not found, return the default if given; otherwise, raise a KeyError.
- Return type:
- opentelemetry.context.attach(context)[source]
Associates a Context with the caller’s current execution unit. Returns a token that can be used to restore the previous Context.
- 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:
- Returns:
A unique string representing the newly created key.
- opentelemetry.context.detach(token)[source]
Resets the Context associated with the caller’s current execution unit to the value it had before attaching a specified Context.
- 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.
- Return type:
- Returns:
The current Context object.
- 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.