Skip to main content
Using a coding agent? Paste this prompt directly in your LiveKit agent codebase to jumpstart your Cekura integration.

Overview

LiveKit Tracing provides deep observability into your LiveKit agent’s performance by integrating the Cekura SDK directly into your agent code. This integration significantly enhances the information available in the Cekura platform for end-to-end visibility over agent execution. What you get:
  • Complete conversation transcripts with full message history
  • Tool/function calls with inputs and outputs
  • Detailed performance metrics (STT, TTS, LLM, End-of-Utterance)
  • Session logs captured automatically from your application
  • Mock tools support for testing with predictable tool responses
  • Dual-channel audio recording for monitoring production calls
  • LiveKit job and room metadata

Video Tutorial

Prerequisites

  • A Cekura account with an API key
  • A LiveKit agent project

Setup

Use this setup in your test agents while running simulation calls from the Cekura platform.
1

Install the Cekura SDK

2

Integrate the SDK in your LiveKit agent

Add the Cekura tracer to your LiveKit agent’s entrypoint:
What this does:
  • Captures transcripts, tool calls, metrics, and session logs
  • Automatically injects mock tools configured in Cekura
  • Automatically configures chat/text mode when running text-based tests
  • Exports data to Cekura for test analysis
3

Configure LiveKit provider and enable tracing

Navigate to your agent settings in the Cekura dashboard, select LiveKit as the provider, and enable tracing:LiveKit Agent SettingsRequired configuration:
  • LiveKit API Key: Your LiveKit API key
  • LiveKit API Secret: Your LiveKit API secret
  • LiveKit URL: Your LiveKit server URL (e.g., wss://your-server.livekit.cloud)
  • Agent Name: The specific agent name to dispatch in LiveKit
Optional configuration:
  • LiveKit Config (JSON): Additional room configuration parameters (accessible in agent code via get_simulation_data())
Testing connection types:LiveKit Connection TypesConfigure at least one connection type for voice-based testing:
  • WebRTC: Direct LiveKit room connection using the credentials configured above
  • Telephony: Phone-based testing if your LiveKit agent is connected to a phone system (requires Contact Number)
For text-based testing:
  • Chat: Select LiveKit to enable chat-based testing (uses the same WebRTC configuration, no additional setup required)
4

Run tests

Run tests using your preferred connection type:
  • WebRTC: Select WebRTC under Voice connections in the Configure Run dialog for WebRTC-based testing
  • Telephony: Select Telephony under Voice connections for phone-based testing
  • Chat: Select a chat connection for text-based testing
Run Tests Options
5

Analyze the call

Navigate to the Runs section to view your test results with enhanced data including transcripts, tool calls, session logs, and detailed performance metrics.

Enhanced Data in Cekura UI

With tracing enabled, you’ll see enriched information in the Cekura platform: The run now displays:
  • Room Session ID: Visible in the call provider ID field, allowing you to correlate Cekura test runs with specific LiveKit sessions
  • Complete Transcript: Full conversation history from the LiveKit agent, including tool/function call requests and responses
  • OpenTelemetry Traces: User and agent turns with STT, LLM, tool, and TTS spans
  • Provider Call Data: Detailed metadata accessible in the run details, including job information, room configuration, session logs, and raw performance metrics
Enhanced Data Display Provider Call Data contains the following information:
  • Job Information: Job ID, room name, participant details, and agent dispatch metadata
  • Room Information: Room configuration, participant count, session duration, and connection details
  • Session Logs: Captured agent session logs with timestamps, log levels, and messages for debugging
  • Raw Metrics:
    • STT (Speech-to-Text): Latency, duration, and transcription timing
    • TTS (Text-to-Speech): Generation time and audio synthesis metrics
    • LLM: Token usage, response time, and inference latency
    • EOU (End-of-Utterance): Detection timing and accuracy
  • Custom Metadata: Additional metadata passed to the SDK via the metadata parameter

OpenTelemetry Tracing

The Python SDK automatically exports LiveKit’s native OpenTelemetry spans to Cekura. The trace is correlated with the simulation run created by track_session() or the call log created by observe_session(), so the full execution timeline is available alongside the transcript, metrics, and, in observability mode, the recording.
OpenTelemetry trace export requires Cekura Python SDK 1.5.2 or later. Call track_session() or observe_session() before session.start() so tracing is configured before LiveKit starts the agent session.

Trace Structure

Each call produces a hierarchical trace containing the LiveKit spans emitted during user and agent turns:
The trace view groups LiveKit’s internal LLM and TTS spans into readable operations while retaining their timing and attributes. Incomplete trailing turns are also shown when a call ends before the next full turn completes.

How It Works

No separate LiveKit tracing configuration is required. When track_session() or observe_session() is called, the SDK:
  1. Configures LiveKit’s OpenTelemetry provider using your Cekura API key and agent ID
  2. Exports spans to Cekura’s OTLP/gRPC endpoint
  3. Captures the agent-session trace ID and sends it with the run or call-log payload
  4. Flushes pending spans when the LiveKit job shuts down
The endpoint can be overridden when using a custom Cekura environment:

Disabling OTel Traces

To disable OTel trace export entirely:
When disabled, no OTel provider is configured and no traces are exported. All other SDK features continue to work normally.

Automatic Chat Mode Support

The SDK automatically handles chat/text mode configuration when you run scenarios using “Run with Text” — no code changes required. When you run a text-based test, the SDK automatically patches your session to disable audio processing, enabling pure text-based interactions with your agent. This provides:
  • Targeted testing of your agent’s conversational logic without audio overhead
  • Cost savings by eliminating STT/TTS provider costs and reducing Cekura credit usage
  • Faster simulations compared to voice-based tests
Your track_session() / trackSession() integration works seamlessly for both voice and text modes.

Using Mock Tools with LiveKit Tracing

The SDK supports mock tools, allowing you to test your agent with predictable tool responses. This is useful for creating reproducible test scenarios without relying on live external services. To use mock tools:
  1. Create mock tools in Cekura: Set up your mock tool configurations in the Cekura dashboard. See the Mock Tools guide for detailed instructions.
  2. SDK handles the rest: Once mock tools are configured, the SDK automatically routes tool calls to Cekura’s mock endpoints during testing - no additional code changes needed.
  3. Test with predictable data: Your agent will receive the mock responses you configured, making it easy to test specific scenarios and edge cases.

Best Practices

  1. Use the right method for your environment: Use track_session() / trackSession() in your test/UAT environments for simulation testing with mock tools. Use observe_session() / observeSession() in your production environment for monitoring live calls with audio recording.
  2. Use environment variables for credentials: Don’t hardcode API keys in your code
  3. Keep the SDK updated: Periodically upgrade to the latest version for new features.
  4. Review tool calls regularly: Add the predefined metric Tool Call Success to your evaluators

SDK Reference

LiveKitTracer Initialization

track_session()

Tracks simulation/test calls with automatic mock tool injection and chat mode support. Collects transcripts, tool calls, session logs, and metrics.
Environment variables:
  • CEKURA_TRACING_ENABLED="false": Disable tracking entirely
  • CEKURA_MOCK_TOOLS_ENABLED="false": Disable only mock tool injection

observe_session()

Monitors production calls with dual-channel audio recording. Collects transcripts, tool calls, session logs, and metrics. Requires LiveKit credentials configured in Cekura.
Environment variables:
  • CEKURA_OBSERVABILITY_ENABLED="false": Disable observability entirely

get_simulation_data()

Extracts simulation data populated by Cekura when running simulation calls from the platform. Returns an empty object for phone-based calls.
Returns: Object with simulation metadata:
This data is ONLY available when using Option 2 (Automated LiveKit Testing) — running tests via WebRTC connection. Phone-based calls (Option 1) will return an empty object.

Next Steps