microscopic-dress-75199
09/29/2025, 4:36 PMtall-airline-16756
09/29/2025, 4:36 PMtall-airline-16756
09/29/2025, 4:37 PMmicroscopic-dress-75199
09/29/2025, 4:37 PMtall-airline-16756
09/29/2025, 4:38 PMsetup_langfuse() function. It configures the OpenTelemetry tracer with Langfuse, initializing a TracerProvider with a BatchSpanProcessor that batches and exports spans asynchronously—helping keep things efficient.
2. Initialize Tracing in the Agent Entrypoint: Just call setup_langfuse() right at the start of your agent’s entrypoint function. This way, all agent activities are traced from the get-go.
3. Ensure Asynchronous Export: Thanks to the BatchSpanProcessor, spans are exported in the background, so your real-time operations won’t be blocked. You can also register a shutdown callback to make sure all traces are flushed when the agent exits.
Langfuse will capture traces for important agent activities like session starts, agent turns, LLM and TTS node executions, and more. These insights are really helpful for evaluations and performance analysis.
If you’d like to see everything in action, feel free to check out the LangFuse trace example in the LiveKit Agents GitHub repository. It’s a great resource to guide you through the process.
Sources: Agent Testing & Evaluation | livekit/livekit_composite | DeepWiki | examples/voice_agents/README.md | Docs::Agentstall-airline-16756
09/29/2025, 8:31 PMlogging module to capture important lifecycle events like tool invocation and response results. Here's how you can configure logging:
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("mcp-agent-tools")
This will help you track logs such as tool invocation, connection status, and any errors that come up.
1. RPC-Level Logging (Go): You might want to enable logging interceptors like WithClientLogger or WithServerLogger. These will log all client and server RPC calls, including requests and responses, along with structured metadata.
2. JavaScript SDK Logging: Using setLogExtension is a great way to capture and redirect logs, including MCP responses or other API interactions. Here's a quick example:
setLogExtension((level, msg, context) => {
console.log(level, msg, { ...context, timestamp: Date.now() });
});
For a complete working example, you can check out the basic-mcp GitHub repository. If you have any questions or need further help, please don’t hesitate to reach out—I’m here for you!
Sources: examples/voice_agents/mcp/mcp-agent.py | Logs, metrics, and telemetry | LiveKit Docs | livekit/livekit_agent_dispatch.twirp.go | How to Send Logs from the JavaScript SDK to Providers like Datadog | plugins/google/src/beta/realtime/realtime_api.ts