Skip to content

symfonic.observability.ports

ports

Runtime-service-facing port for capability-owned instrumentation state.

reset_active_recorder

reset_active_recorder(token: Token) -> None

Reset the contextvar to whatever value it held before the matching :func:set_active_recorder call.

Source code in src/symfonic/observability/tool_span_seam.py
def reset_active_recorder(token: Token) -> None:
    """Reset the contextvar to whatever value it held before the matching
    :func:`set_active_recorder` call."""
    _active_recorder.reset(token)

set_active_recorder

set_active_recorder(recorder: Any) -> Token

Install recorder as the active SpanRecorder for the current task.

Returns the ContextVar token; pass it to :func:reset_active_recorder when the run scope ends. The OTel tracer's start_run_span context manager owns the set/reset pair.

Source code in src/symfonic/observability/tool_span_seam.py
def set_active_recorder(recorder: Any) -> Token:
    """Install ``recorder`` as the active SpanRecorder for the current task.

    Returns the ContextVar token; pass it to :func:`reset_active_recorder`
    when the run scope ends.  The OTel tracer's ``start_run_span`` context
    manager owns the set/reset pair.
    """
    return _active_recorder.set(recorder)