astonishing-family-8385
02/14/2025, 10:58 AMgray-monkey-83525
02/14/2025, 10:58 AMmetrics_collected
event to capture metrics during an active session. Here's a basic example:
1. Import Metrics Module: Import the metrics module from LiveKit Agents.
2. Subscribe to Metrics Event: Use the metrics_collected
event to log or process the metrics.
const { metrics } = require('livekit-agents');
// Subscribe to metrics collection events
agent.on('metrics_collected', (mtrcs) => {
// Log or process the metrics
metrics.log_metrics(mtrcs);
});
Would you like more detailed information on specific metrics or further guidance on setting this up?
Sources:
- Capturing metrics | LiveKit Docs 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.astonishing-family-8385
02/14/2025, 11:00 AMgray-monkey-83525
02/14/2025, 11:00 AMUsageCollector
in LiveKit involves ensuring that metrics are being correctly passed to it. According to the UsageCollector API documentation, the UsageCollector
class is used to aggregate usage metrics over a session. Here are some steps you might consider for debugging:
1. Verify Event Subscription: Ensure that your agent is correctly subscribed to the metrics_collected
event and that the event handler is being triggered.
2. Check Metrics Type: Confirm that the metrics being passed to the UsageCollector
are of the correct type (e.g., STTMetrics
, LLMMetrics
, TTSMetrics
). The UsageCollector
processes these specific types to update its summary.
3. Log Metrics: Add logging within the event handler to verify that metrics are being received and passed to the UsageCollector
.
4. Inspect UsageCollector: After collecting metrics, use the get_summary
method to check if the summary reflects the expected data.
Here's a basic example of how you might set this up:
from livekit.agents import metrics
# Initialize UsageCollector
usage_collector = metrics.UsageCollector()
# Subscribe to metrics collection events
@agent.on("metrics_collected")
def on_metrics_collected(mtrcs):
# Log the received metrics
print(f"Received metrics: {mtrcs}")
# Collect metrics
usage_collector.collect(mtrcs)
# At some point, retrieve the summary
summary = usage_collector.get_summary()
print(f"Usage Summary: {summary}")
Would you like more detailed guidance on any specific part of this process?
Sources:
- UsageCollector API documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.astonishing-family-8385
02/14/2025, 11:14 AMgray-monkey-83525
02/14/2025, 11:14 AMTTSMetrics
event is not triggering due to a few common issues. According to the LiveKit documentation, metrics events, including those for TTS, are typically fired when a new metrics object is available during an active session. Here are some potential reasons and steps to troubleshoot:
1. Ensure Proper Subscription: Verify that your agent is correctly subscribed to the metrics_collected
event. Without this subscription, the event handler won't be triggered.
2. Check TTS Activity: Confirm that there is active TTS processing occurring. If no text-to-speech operations are being performed, no TTSMetrics
will be generated.
3. Verify Event Emission: Ensure that the TTS component is correctly emitting metrics. This might involve checking the implementation of the TTS component to see if it calls the emit
method for metrics.
4. Debug Logging: Add logging within your event handler to confirm whether any metrics are being received and to check their types.
If you need more detailed assistance, could you provide more context on how you're setting up the TTS and metrics collection?
Sources:
- LiveKit documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.astonishing-family-8385
02/14/2025, 11:19 AMgray-monkey-83525
02/14/2025, 11:19 AMmetrics_collected
event and that the event handler is set up to process TTS metrics specifically.
4. Inspect Emission Logic: Look into the TTS component's logic to ensure it emits metrics. There might be a condition or error preventing the emission of TTS metrics.
5. Debugging: Add debug logs in your event handler to see if any TTS metrics are being received but not processed correctly.
If you need more detailed guidance, could you provide more information on your TTS setup and how you're handling metrics?
Sources:
- https://docs.livekit.io/agents/build/metrics/#LLM 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.