Why AI agents need tracing: OpenTelemetry and LangSmith with FastAPI and LangGraph

The article explains how to instrument a FastAPI and LangGraph agent for observability in about 20 minutes. It recommends tracing the full request lifecycle with a single trace ID spanning intent classification, retrieval, tool execution, and retry loops. Key signals to log include per-step latency at P50 and P99, token count and cost, retrieval similarity scores, and tool error and retry counts. To avoid blocking user-facing latency, traces should be sent asynchronously via an SDK callback handler or an OpenTelemetry collector. Finally, failing production traces can be exported into pytest or RAGAS regression suites so each bug becomes a permanent test case.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in