praval.observability.tracing.context
Compatibility context values backed by OpenTelemetry context propagation.
The v0.8.2 TraceContext name remains available for existing Spore helpers.
Current-span storage and async isolation are provided entirely by the official
OpenTelemetry context API. W3C Spore propagation replaces the legacy metadata
keys in work package O4.
Functions
|
Extract a remote parent with the configured OpenTelemetry propagator. |
|
Inject the configured OpenTelemetry propagator into a text carrier. |
Classes
|
Hex-encoded trace and parent-span identity for legacy Spore metadata. |
- class praval.observability.tracing.context.TraceContext(trace_id, span_id, trace_flags=1)[source]
Bases:
objectHex-encoded trace and parent-span identity for legacy Spore metadata.
- Parameters:
trace_id (str)
span_id (str)
trace_flags (int)
- trace_id: str
- span_id: str
- trace_flags: int = 1
- classmethod from_span(span)[source]
Create a compatibility value from an official span.
- Return type:
- Parameters:
span (Span)
- classmethod from_spore(spore)[source]
Read supported v0.8.2 trace fields from Spore metadata.
- Return type:
TraceContext|None- Parameters:
spore (Any)
- classmethod current()[source]
Return the current valid OpenTelemetry span context, if one exists.
- Return type:
TraceContext|None
- as_context()[source]
Return an official remote-parent context for span creation.
- Return type:
Context
- inject_into_spore(spore)[source]
Write supported v0.8.2 trace fields to mutable Spore metadata.
- Return type:
None- Parameters:
spore (Any)
- __init__(trace_id, span_id, trace_flags=1)
- Parameters:
trace_id (str)
span_id (str)
trace_flags (int)
- Return type:
None
- praval.observability.tracing.context.extract_trace_context(carrier)[source]
Extract a remote parent with the configured OpenTelemetry propagator.
- Return type:
Context- Parameters:
carrier (Mapping[str, str])
- praval.observability.tracing.context.get_current_span(context=None)[source]
Retrieve the current span.
- Parameters:
context (
Context|None) – A Context object. If one is not passed, the default current context is used instead.- Return type:
Span- Returns:
The Span set in the context if it exists. INVALID_SPAN otherwise.