service_attributes
Functions for adding attributes to OpenTelemetry spans.
This module provides specialized functions for adding service-specific attributes to OpenTelemetry spans, following standard semantic conventions where applicable and Pipecat-specific conventions for additional context.
- pipecat.utils.tracing.service_attributes.add_tts_span_attributes(span: Span, service_name: str, model: str, voice_id: str, text: str | None = None, settings: ServiceSettings | None = None, character_count: int | None = None, operation_name: str = 'tts', ttfb: float | None = None, **kwargs) None[source]
Add TTS-specific attributes to a span.
- Parameters:
span – The span to add attributes to.
service_name – Name of the TTS service (e.g., “cartesia”).
model – Model name/identifier.
voice_id – Voice identifier.
text – The text being synthesized.
settings – Service configuration settings.
character_count – Number of characters in the text.
operation_name – Name of the operation (default: “tts”).
ttfb – Time to first byte in seconds.
**kwargs – Additional attributes to add.
- pipecat.utils.tracing.service_attributes.add_stt_span_attributes(span: Span, service_name: str, model: str, operation_name: str = 'stt', transcript: str | None = None, is_final: bool | None = None, language: str | None = None, user_id: str | None = None, settings: ServiceSettings | None = None, vad_enabled: bool = False, ttfb: float | None = None, **kwargs) None[source]
Add STT-specific attributes to a span.
- Parameters:
span – The span to add attributes to.
service_name – Name of the STT service (e.g., “deepgram”).
model – Model name/identifier.
operation_name – Name of the operation (default: “stt”).
transcript – The transcribed text.
is_final – Whether this is a final transcript.
language – Detected or configured language.
user_id – User ID associated with the audio being transcribed.
settings – Service configuration settings.
vad_enabled – Whether voice activity detection is enabled.
ttfb – Time to first byte in seconds.
**kwargs – Additional attributes to add.
- pipecat.utils.tracing.service_attributes.add_llm_span_attributes(span: Span, service_name: str, model: str, stream: bool = True, messages: str | None = None, output: str | None = None, tools: str | None = None, tool_count: int | None = None, tool_choice: str | None = None, system_instructions: str | None = None, parameters: dict[str, Any] | None = None, extra_parameters: dict[str, Any] | None = None, ttfb: float | None = None, **kwargs) None[source]
Add LLM-specific attributes to a span.
- Parameters:
span – The span to add attributes to.
service_name – Name of the LLM service (e.g., “openai”).
model – Model name/identifier.
stream – Whether streaming is enabled.
messages – JSON-serialized messages.
output – Aggregated output text from the LLM.
tools – JSON-serialized tools configuration.
tool_count – Number of tools available.
tool_choice – Tool selection configuration.
system_instructions – System instructions.
parameters – Service parameters.
extra_parameters – Additional parameters.
ttfb – Time to first byte in seconds.
**kwargs – Additional attributes to add.
- pipecat.utils.tracing.service_attributes.add_gemini_live_span_attributes(span: Span, service_name: str, model: str, operation_name: str, voice_id: str | None = None, language: str | None = None, modalities: str | None = None, settings: ServiceSettings | None = None, tools: list[dict] | None = None, tools_serialized: str | None = None, transcript: str | None = None, is_input: bool | None = None, text_output: str | None = None, audio_data_size: int | None = None, **kwargs) None[source]
Add Gemini Live specific attributes to a span.
- Parameters:
span – The span to add attributes to.
service_name – Name of the service.
model – Model name/identifier.
operation_name – Name of the operation (setup, model_turn, tool_call, etc.).
voice_id – Voice identifier used for output.
language – Language code for the session.
modalities – Supported modalities (e.g., “AUDIO”, “TEXT”).
settings – Service configuration settings.
tools – Available tools/functions list.
tools_serialized – JSON-serialized tools for detailed inspection.
transcript – Transcription text.
is_input – Whether transcript is input (True) or output (False).
text_output – Text output from model.
audio_data_size – Size of audio data in bytes.
**kwargs – Additional attributes to add.
- pipecat.utils.tracing.service_attributes.add_openai_realtime_span_attributes(span: Span, service_name: str, model: str, operation_name: str, session_properties: dict[str, Any] | None = None, transcript: str | None = None, is_input: bool | None = None, context_messages: str | None = None, function_calls: list[dict] | None = None, tools: list[dict] | None = None, tools_serialized: str | None = None, audio_data_size: int | None = None, **kwargs) None[source]
Add OpenAI Realtime specific attributes to a span.
- Parameters:
span – The span to add attributes to.
service_name – Name of the service.
model – Model name/identifier.
operation_name – Name of the operation (setup, transcription, response, etc.).
session_properties – Session configuration properties.
transcript – Transcription text.
is_input – Whether transcript is input (True) or output (False).
context_messages – JSON-serialized context messages.
function_calls – Function calls being made.
tools – Available tools/functions list.
tools_serialized – JSON-serialized tools for detailed inspection.
audio_data_size – Size of audio data in bytes.
**kwargs – Additional attributes to add.