ConversationContextProvider
- class pipecat.utils.tracing.conversation_context_provider.ConversationContextProvider[source]
Bases:
object
Provides access to the current conversation’s tracing context.
This is a singleton that can be used to get the current conversation’s span context to create child spans (like turns).
- classmethod get_instance()[source]
Get the singleton instance.
- set_current_conversation_context(span_context, conversation_id=None)[source]
Set the current conversation context.
- Parameters:
span_context (SpanContext | None) – The span context for the current conversation or None to clear it.
conversation_id (str | None) – Optional ID for the conversation.
- get_current_conversation_context()[source]
Get the OpenTelemetry context for the current conversation.
- Returns:
The current conversation context or None if not available.
- Return type:
Context | None
- get_conversation_id()[source]
Get the ID for the current conversation.
- Returns:
The current conversation ID or None if not available.
- Return type:
str | None
- generate_conversation_id()[source]
Generate a new conversation ID.
- Returns:
A new randomly generated UUID string.
- Return type:
str
- pipecat.utils.tracing.conversation_context_provider.get_current_conversation_context()[source]
Get the OpenTelemetry context for the current conversation.
- Returns:
The current conversation context or None if not available.
- Return type:
Context | None
- pipecat.utils.tracing.conversation_context_provider.get_conversation_id()[source]
Get the ID for the current conversation.
- Returns:
The current conversation ID or None if not available.
- Return type:
str | None