echoing-lamp-18687
11/12/2025, 6:14 AMtall-airline-16756
11/12/2025, 6:14 AMtall-airline-16756
11/12/2025, 6:15 AMspeech_id field is especially useful, as it helps you connect processing times to specific conversation turns.
Here’s a simple way to get started:
• Set up event listeners to collect metrics using the metrics_collected event.
• Use the speech_id to organize metrics for each message.
• Keep track of important metrics like STT duration, LLM generation time, TTS synthesis time, and audio durations.
• If you want, you can also aggregate usage across the whole session with the UsageCollector or export these metrics to external tools for deeper analysis.
If you’d like, I’d be more than happy to provide detailed code examples or guide you through the process step by step—just let me know!
Sources: metrics/metrics_llm.py | LiveKit Docs | Logs, metrics, and telemetry | LiveKit Docs | Logs, metrics, and telemetry | LiveKit docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real...echoing-lamp-18687
11/12/2025, 6:17 AMtall-airline-16756
11/12/2025, 6:17 AMTTSMetrics to conversation items, a great approach is to use shared identifiers or timestamps. Here’s a simple way to do it:
• Look at the speech_id field in `TTSMetrics`—this uniquely matches the speech generated for a specific message, so you can link it to the right conversation turn.
• Another option is to compare the created_at timestamps in both the conversation item and the metrics payload to find when they align.
• For other metrics such as LLMMetrics, the request_id often corresponds directly to the id of a conversation item.
By putting these pieces together, you’ll be able to connect metrics to conversation items smoothly for better tracking and analysis. If you’d like, I’m here to provide more details or examples—just let me know!
Sources: tests/test_agent_session.py | metrics/send-metrics-to-3p/send_metrics_to_3p.pyechoing-lamp-18687
11/12/2025, 6:18 AMtall-airline-16756
11/12/2025, 6:18 AMTTSMetrics payload to a conversation item:
Let’s consider the following:
• Metrics Payload:
speech_id='speech_a4c16b0858b0', timestamp=1762927375.1260436
• Conversation Item:
id='item_76b22990ea80', created_at=1762927380.1710165
Here are the steps to help you correlate them:
1. Start by using the speech_id from TTSMetrics to find the matching conversation turn. If the conversation item’s metadata includes a speech_id, that’s a direct and easy match.
2. If you don’t see a speech_id in the conversation item, then compare the timestamp from TTSMetrics with the created_at timestamp of the conversation item. Just make sure the timestamps are close enough to suggest they’re part of the same event.
For instance, if the speech_id in TTSMetrics matches the conversation item’s metadata, or if the timestamps are aligned closely (say, within a few seconds), you can feel confident mapping the metric to that conversation item.
If you’d like, I’d be more than happy to provide a code snippet to make this even clearer—just let me know!echoing-lamp-18687
11/12/2025, 6:19 AMtall-airline-16756
11/12/2025, 6:20 AMmetrics_collected event. Here's a friendly way to approach this:
• Keep an eye on both the conversation_item_added and metrics_collected events.
• Try using shared identifiers such as speech_id or match up timestamps (created_at) between these events.
• Create some custom logic to link metrics with conversation items by looking at their timing and context.
If you're interested in more advanced tracking, integrating OpenTelemetry can offer trace-based observability throughout the agent's lifecycle. Please feel free to ask if you'd like me to share more details or some examples—I'm here to help!
Sources: Logs, metrics, and telemetry | LiveKit docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real... | Events and error handling | LiveKit docs