翻篇收录说明
翻篇网页快照

LLM Observability for Production AI Agents | Pydantic Logfire

https://pydantic.dev/logfire/llm-observability

最近抓取:2026-12-04 21:07:07(北京时间)

最近内容变化:2026-12-02 08:34:19(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

LLM observability for production AI agents: trace model calls, tool calls, and database queries in one OpenTelemetry trace, and query tokens and cost with SQL.

正文摘录

Observe LLM observability that traces below the model call Trace every LLM call, tool invocation, and database query in one place, from local dev to production. Free for 10 million records a month. Send your first trace Start free Read the docs Why observability AI apps break quietly Two failures can look identical to a user waiting on an answer. One agent stalls on a failed GitHub API request, another spends its whole runtime in a slow SELECT. The model call alone cannot explain either one.Instrument the agent framework, HTTP client, and database driver, and Pydantic Logfire records the request, model, tool, external API, and database work as one trace. Degraded dependency is visible instead of inferred from timestamps across separate tools. How it works The trace is the shape of your code Instrument One line per library logfire.instrument_openai() Nest Each call opens a span inside the call that made it Follow One trace ID crosses services, queues and background tasks Extend Anything already speaking OpenTelemetry joins the same trace 5 POST /v1/chat $0.0142 2.92s 4 invoke_agent billing_agent $0.0142 2.92s chat gpt-4o $0.0095 537ms 1 execute_tool check_stock 1.85s SELECT user_id, SUM(total) FROM orders WHERE user_id = $1 1.81s chat gpt-4o $0.0047 533ms What you get Every run, end to end Full-stack context 37 integrations: web frameworks, eight databases, HTTP clients, task queues, hosts, Kubernetes and Docker. Dashboards and alerts Prebuilt dashboards for cost, latency, and exceptions. Alert from a template for exceptions, 5xx, slow queries, or LLM errors, or customize with your own SQL. Tokens and cost per model Query tokens and cost by model, provider, and agent alongside latency, error rate, output tokens/sec, cache reads, and tool-call rate. Live view with SQL search Search the live stream with a WHERE clause, or ask in plain English and let AI write the query. Standard PostgreSQL over the same table your traces live in, so nothing new to learn. Service levels Set a target on availability, latency, LLM calls or AI quality. Logfire tracks the error budget and alerts on burn rate before you spend it. Scrubbing on by default 18 patterns redact passwords, tokens, keys and PII before data leaves the machine. On by default. Start free Read docs Use cases Questions you can finally answer Was it the tool or the model? When an agent gives a bad answer, the model usually gets blamed. The trace shows the tool call, what returned, and where the run went wrong. Debug a slow tool call Where is the time going? Sort a slow run by duration, open the longest span, and follow it down to the exact SQL statement or API call behind it. Find the slow endpoint Ask your coding agent what broke One command connects Claude Code or Cursor to the Logfire MCP server. It queries production itself and comes back with the trace. Set up the MCP server Customer stories Teams who stopped guessing How Dosu cut time to root cause across 54 agents 90% Less debugging time, using the Logfire MCP How AutonomyAI let its agents check their own work “Most of our engineers and our internal systems now use the Logfire MCP for basically everything” Tammuz Dubnov Co-founder & CTO How Sophos surfaced silent production failures “We can see the whole conversation thread, the LLM call, and every API hop, all in one go” Peter Kim Principal Software Engineer FAQs What is LLM observability? LLM observability is the practice of recording what an LLM application did on each request: the prompts and responses, the tool calls, the tokens and cost, and the latency of every step. It lets a team work out afterwards why an answer was wrong or slow, which a status code and a response time cannot show. How do I trace an AI agent end to end? Install the Logfire SDK, call logfire.configure(), and instrument your framework — one line for Pydantic AI, LangChain, the OpenAI SDK, and 40+ others. From then on, every agent run is captured as a single trace: the model calls, tool calls, retrieval steps, and the database and API calls around them, nested in the order they ran. You watch it locally as you build and in production without changing the setup. Does Logfire trace the whole request, or just the LLM call? The whole request. Most LLM observability tools stop at the model call: prompt, response, tokens. Logfire traces the full application: the FastAPI request, the Postgres query, the vector search, the tool call, and the model call, in one waterfall. That matters because production failures usually aren't in the model call itself. They're in the retry logic, the query that fed the prompt, or the tool that timed out. Do I still need Logfire if I already use Datadog or Sentry? If you're shipping AI in production, yes. Logfire connects agent runs, model calls, tools, and application spans in one trace, with purpose-built AI views and SQL over the same data. Because it's OpenTelemetry-native, you can run it alongside Datadog or Sentry without changing your current instrumentation. How does Logfire help with RAG pipelines? RAG failures are rarely just the LLM's fault. They hide in retrieval: slow vector searches, mismatched embeddings, irrelevant context passed to the model. Because Logfire traces your full application, you can see retrieval latency, database queries, and LLM calls in the same trace, which makes it much easier to locate the real bottleneck. How does Logfire handle sensitive data and PII? Logfire automatically scrubs known sensitive fields such as passwords, tokens, keys, and common PII patterns, before data leaves your application. You can configure additional scrubbing rules for anything specific to your use case. For teams with stricter requirements, the enterprise self-hosted option keeps all data within your own infrastructure. Does tracing add latency to my agents? No. Spans are batched and exported asynchronously on a background thread, so instrumentation stays out of the request path. For high-volume services, head and tail sampling let you keep every failed or slow run while sampling the routine ones, so you control the data volume without losing the traces that matter.