get_context_value()

Signature

1get_context_value(key: str) -> Any

Returns the value for the given key from the current OpenTelemetry context, or None if not found.

Example

1from respan import Respan, workflow, get_client
2
3respan = Respan(api_key="your-api-key")
4
5@workflow(name="context_demo")
6def context_demo():
7 client = get_client()
8 client.set_context_value("custom.key", "my_value")
9 value = client.get_context_value("custom.key")
10 print(value) # "my_value"
11 return value
12
13context_demo()