important-garden-60239
10/15/2025, 9:00 AMtall-airline-16756
10/15/2025, 9:00 AMtall-airline-16756
10/15/2025, 9:01 AMentrypoint function.
• Record Session End: Then, listen for events like on_user_turn_completed or use session close callbacks to know when the session ends. From there, you can calculate the session duration by finding the difference between the end and start times.
• Optional Timeout: If you'd like, you can set a maximum session length using the max_session_duration parameter in the RealtimeModel.
• Log Duration: Finally, you can log the session length using Python’s logging module or connect to external telemetry tools, whichever fits your needs best.
If you'd like, I can walk you through a detailed code example or help with any specific part of the implementation. Just let me know what works best for you!
Sources: Logs, metrics, and telemetry | LiveKit Docs | agent/main.py | tests/test_agent_session.py | OpenAI Realtime API plugin guide | LiveKit Docsimportant-garden-60239
10/15/2025, 9:08 AMtall-airline-16756
10/15/2025, 9:09 AMSENTRY_DSN environment variable in your LiveKit deployment configuration. This will make sure your runtime logs are forwarded to your Sentry account seamlessly.
2. Enable Debug Logging: Set the LK_OPENAI_DEBUG environment variable to 1 in your configuration. This way, you’ll get detailed logs about the Realtime API connection and message traffic, which can be really helpful.
3. Log Events in Code: Use Python’s logging module to capture session events. For example, you can listen for openai_server_event_received and openai_client_event_queued events, then log them using logger.info() or logger.debug(). These logs will be sent to Sentry automatically.
If you’d like, I’m here to help with specific code examples or any configuration details you might need. Just let me know!
Sources: Log collection | LiveKit Docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real...