TurnContextProvider

class pipecat.utils.tracing.turn_context_provider.TurnContextProvider[source]

Bases: object

Provides access to the current turn’s tracing context.

This is a singleton that services can use to get the current turn’s span context to create child spans.

classmethod get_instance()[source]

Get the singleton instance.

set_current_turn_context(span_context)[source]

Set the current turn context.

Parameters:

span_context (SpanContext | None) – The span context for the current turn or None to clear it.

get_current_turn_context()[source]

Get the OpenTelemetry context for the current turn.

Returns:

The current turn context or None if not available.

Return type:

Context | None

pipecat.utils.tracing.turn_context_provider.get_current_turn_context()[source]

Get the OpenTelemetry context for the current turn.

Returns:

The current turn context or None if not available.

Return type:

Context | None