Overview
RDK integrates seamlessly with FastAPI. This guide shows how to set up tracing in a production FastAPI application.Basic Setup
Use FastAPI’s lifespan handler to initialize and shutdown RDK:Complete Example
Here’s a full FastAPI application with RDK tracing:Agent Endpoint
Add an endpoint with tool calling:Request Tracking
Add request IDs to traces for debugging:Error Handling
RDK captures errors automatically, but you can add context:Running the App
Testing
Disable tracing in tests usingmode="test" or enabled=False:
Production Considerations
- Set appropriate batch size — Higher values reduce network calls
- Configure flush interval — Balance latency vs. data freshness
- Use PII redaction — Required for compliance
- Monitor flush endpoint — Useful for debugging trace delivery
See Also
- Testing Guide — Writing tests for LLM apps
- init() — All configuration options

