Last updated:
LLM observability is the practice of recording what your LLM application does on every request (prompts, model responses, retrieval results, tool calls, latency, token usage, and cost) as structured traces, and using that data to debug failures, measure quality, and monitor production behavior. LLM applications are non-deterministic, so the same input can produce different outputs. Logs and uptime metrics cannot tell you why an answer was wrong. A trace can.
MLflow Tracing is an open source way to get LLM observability. One line of code captures every LLM call, and the MLflow UI lets you search traces, inspect each step, track token cost, and score quality with LLM judges. It is compatible with OpenTelemetry, works with any LLM provider or agent framework, and stores your data where you choose. This page covers how LLM observability works and how to set it up. For a deep dive into the tracing layer itself, see LLM tracing.
Quick Navigation:
Traditional observability answers "is the service up and how fast is it?" LLM observability adds the questions that matter for language model applications: what exactly did the model see, what did it return, which documents were retrieved, which tools were called, how many tokens did it cost, and was the answer any good?
It is built on traces. A trace is the record of one request through your application. It is made of nested spans, one per step: an LLM call, a retrieval, a tool call, or a function of your own. Each span stores its inputs, outputs, timing, and attributes such as model name and token counts. Reading a trace top to bottom shows what the application did and where it went wrong.
| Practice | Question it answers | Main data |
|---|---|---|
| LLM observability | Why did the application behave this way? | Traces with spans, inputs, outputs, tokens |
| LLM monitoring | Did something change in production? | Aggregated latency, errors, cost, quality scores |
| LLM evaluation | Is the output good enough? | Scores from LLM judges, code checks, and human feedback |
The three work as a loop. Traces give evaluation realistic data to score, evaluation turns traces into quality signals, and monitoring watches those signals over time and points you back to the traces that need attention.
A useful trace records more than the final answer. These are the signals that explain most production problems:
The full input and output of every LLM call, including system prompts, parameters such as temperature, and the model name.
Retrieved documents, tool calls with their arguments and results, and agent decisions, recorded as nested spans.
Time spent in each step, input and output token counts, and cost per request, so you can find slow or expensive steps.
Exceptions with the span that raised them, plus user, session, and application version so you can filter and compare.
Start an MLflow tracking server (mlflow server), then enable automatic tracing for your LLM library. MLflow supports one-line tracing for many providers and frameworks, including OpenAI, Anthropic, LangChain, LangGraph, LlamaIndex, CrewAI, and DSPy.
import mlflowfrom openai import OpenAImlflow.set_tracking_uri("http://localhost:5000")mlflow.set_experiment("my-llm-app")# One line: every OpenAI call is now captured as a tracemlflow.openai.autolog()client = OpenAI()client.chat.completions.create(model="gpt-4o-mini",messages=[{"role": "user", "content": "What is LLM observability?"}],)
Automatic tracing covers library calls. For your own logic, such as retrieval, business rules, or custom tools, add the @mlflow.trace decorator or wrap a block in mlflow.start_span(). The two approaches combine into a single trace.
import mlflowfrom mlflow.entities import SpanType@mlflow.trace(span_type=SpanType.RETRIEVER)def retrieve(query: str) -> list[str]:return search_index(query) # your retrieval code@mlflow.tracedef answer(question: str) -> str:docs = retrieve(question)# Add a custom span around any block of codewith mlflow.start_span(name="build_prompt") as span:prompt = f"Context: {docs}\n\nQuestion: {question}"span.set_inputs({"question": question, "num_docs": len(docs)})return call_llm(prompt) # auto-traced if you enabled autolog
To make traces searchable by who and what produced them, attach session, user, and tags to the current trace. In the UI you can then filter to one customer, one conversation, or one app version.
import mlflow@mlflow.tracedef chat(message: str, session_id: str, user_id: str) -> str:# Group traces by conversation and user so you can filter by them latermlflow.update_current_trace(session_id=session_id,user=user_id,tags={"app_version": "2.3.1", "environment": "production"},)return run_agent(message)
See the tracing quickstart for a complete walkthrough, or manual tracing for the full decorator and span API.
Open any trace in the MLflow UI to see the span tree on the left and the inputs, outputs, and attributes of the selected span on the right. Typical questions this answers in minutes:

MLflow records token counts on LLM spans and rolls them up to the trace. Cost in USD is calculated from token usage and model pricing when the model has a known price. Both are available in code and charted in the experiment Overview dashboard, along with request volume, latency percentiles, and error rates.
import mlflowtrace = mlflow.get_trace(mlflow.get_last_active_trace_id())print(trace.info.token_usage) # input_tokens, output_tokens, total_tokensprint(trace.info.cost) # input_cost, output_cost, total_cost in USD

Token usage and cost depend on what the provider returns, so some models report no usage. See token usage and cost tracking and the dashboard guide for details. To enforce rate limits and budgets rather than only observe spend, see the AI Gateway.
Latency and cost are easy to measure. Quality is the hard part, and observability is what makes it measurable: once requests are traces, you can run LLM judges over them. Pass traces to mlflow.genai.evaluate() with built-in scorers such as Safety and RelevanceToQuery, or write custom judges for your own criteria.
import mlflowfrom mlflow.genai.scorers import Safety, RelevanceToQuery# Pull recent production traces...traces = mlflow.search_traces(experiment_ids=["<your-experiment-id>"],max_results=100,return_type="list",)# ...and score them with built-in LLM judgesresults = mlflow.genai.evaluate(data=traces,scorers=[Safety(), RelevanceToQuery()],)
You can also configure judges to score a sample of production traces automatically, so quality shows up next to latency and cost. Add human feedback to the same traces to calibrate the judges. See LLM evaluation and automatic evaluations.
Tracing should not slow down or destabilize your application. For production deployments:
MLFLOW_TRACE_SAMPLING_RATIO to a value below 1.0 to export only a fraction of traces for high-volume services.The full checklist is in the production tracing guide.
The best LLM observability platform for your team is one that traces your stack with little code, speaks open standards, lets you own your data, and connects traces to quality. MLflow is an open source LLM observability platform that does all four. When comparing any tools, these questions matter most:
MLflow is Apache 2.0 licensed and hosted by the Linux Foundation, so you can run it yourself at no license cost. For side-by-side comparisons, see the top agent observability tools, or the Langfuse, LangSmith, and Arize Phoenix comparisons.