Trace Analytics for LLM and Agent Applications

Trace analytics is the practice of searching, aggregating, and mining the traces your LLM application or agent produces to find slow, expensive, failing, or low-quality requests. MLflow provides it in one open-source platform: trace search, an LLM trace dashboard for latency, errors, tokens, and cost, session grouping, quality assessments, and automatic issue detection.

Last updated: 2026-11-26

A single trace shows you what happened in one request. Analytics shows you what is happening across all of them. Once an agent handles thousands of requests a day, you cannot read traces one by one, so you need to filter them, aggregate them, and let tools point you at the patterns worth reading.

MLflow experiment Dashboard showing trace counts, latency percentiles, errors, token usage, and cost charts for an LLM application
The MLflow Dashboard charts trace volume, latency, errors, and token usage over time. Demo data.

Quick Navigation:

What Is Trace Analytics?

A trace is the record of one request through your application: the user input, each LLM call, tool call, and retrieval step as nested spans, plus timing, token counts, errors, and any tags or feedback attached to it. Trace analytics treats the collection of traces as a dataset you can query.

It sits between two related practices. AI observability is the broader goal of seeing what your system does; trace analytics is the part that answers questions across many traces. Evaluation scores quality on a fixed test set; trace analytics works on real production traffic and can feed failures back into that test set.

What Questions Can Trace Analytics Answer?

Most teams start with a handful of recurring questions. Each one maps to a feature in MLflow:

QuestionWhere to look in MLflow
Which requests are slow or failing?Filter on trace status and execution time in the Traces tab, or chart latency percentiles and error rate on the Dashboard.
Where do tokens and cost go?Token usage and cost charts on the Dashboard, and per-span token counts in the trace viewer.
Which tools does my agent call, and do they work?The Tool calls tab shows call counts, latency, and error rate for each tool.
How do multi-turn conversations go?Session and User columns in the Traces tab, and mlflow.search_sessions() in Python.
Which responses are low quality?Judge scores, code checks, and human feedback attached to traces as assessments, charted on the Quality tab.
What are the recurring failure patterns?Automatic issue detection groups related failures into named issues with evidence.

The Traces tab in the MLflow UI lists every trace in an experiment with its input, output, duration, state, token count, session, and assessment results. The filter bar uses the same SQL-like syntax as the Python API. You can filter on trace status, execution time, trace name, tags, metadata, span name and type, linked prompt versions, feedback, and expectations, and combine conditions with AND.

python
import mlflow
mlflow.set_experiment("my-agent")
# Slow production failures, newest first
traces = mlflow.search_traces(
filter_string="""
tag.environment = 'production'
AND trace.status = 'ERROR'
AND trace.execution_time_ms > 500
""",
order_by=["timestamp_ms DESC"],
max_results=100,
)

mlflow.search_traces() returns a pandas DataFrame by default, or a list of Trace objects with return_type="list". The DataFrame has columns such as state, execution_duration, inputs, outputs, tags, and assessments, so ordinary pandas code gives you custom analytics:

python
df = mlflow.search_traces(max_results=1000)
print(df["state"].value_counts())
print(df["execution_duration"].quantile([0.5, 0.95, 0.99]))

See the search traces documentation for the full list of fields and operators.

How Do I Build an LLM Trace Dashboard for Latency, Tokens, and Cost?

The experiment Dashboard aggregates traces over a time range you choose, with a selectable time unit. It has three tabs:

  • Usage: request counts, latency, errors, token usage, tokens per trace, and cost.
  • Quality: a summary and one chart per assessment type, built from the scorers and feedback attached to your traces.
  • Tool calls: total calls, average latency, success rate, and per-tool usage and error rate for agents.

Token usage and cost are recorded automatically for supported LLM providers, so the charts fill in without extra instrumentation. The dashboard needs a SQL-backed tracking store (SQLite, PostgreSQL, or MySQL); the default file store does not render the charts. See the dashboard documentation and the token usage and cost guide.

How Do I Track Sessions and Users?

Chat applications and agents handle conversations, not isolated requests. Tag each trace with a session ID and a user ID and MLflow groups them, so you can look at a whole conversation, filter by user, and analyze multi-turn behavior.

python
import mlflow
@mlflow.trace
def chat(message: str, user_id: str, session_id: str):
mlflow.update_current_trace(session_id=session_id, user=user_id)
return my_agent(message)
# Or wrap auto-instrumented code
with mlflow.tracing.context(session_id="session-123", user="user-456"):
agent.invoke("What is the capital of France?")
# Retrieve complete multi-turn sessions
sessions = mlflow.search_sessions(max_results=50)

The session_id and user arguments need MLflow 3.11.0 or later. On older versions, set the mlflow.trace.session and mlflow.trace.user metadata keys instead. Details are in the user and session tracking guide.

How Do I Measure Quality in Traces?

Latency and errors tell you whether a request ran. They do not tell you whether the answer was good. MLflow stores quality signals on the trace itself as assessments: feedback from LLM judges, code-based checks, or human reviewers, and expectations that record ground truth. Once attached, assessments are searchable and chartable like any other trace field.

python
from mlflow.entities import AssessmentSource, AssessmentSourceType
mlflow.log_feedback(
trace_id=trace_id,
name="rating",
value="positive",
rationale="Answer matched the retrieved policy document.",
source=AssessmentSource(
source_type=AssessmentSourceType.HUMAN,
source_id="reviewer@example.com",
),
)
# Later: find every trace a reviewer rated positively
good = mlflow.search_traces(filter_string="feedback.rating = 'positive'")

LLM judges can score traces automatically, and review queues let you route traces to human reviewers. Read more in the feedback collection guide.

How Does Automatic Issue Detection Work?

Filters and charts help when you know what to look for. Automatic issue detection helps when you do not. It analyzes a selection of traces with an LLM, groups related failures into named issues such as incorrect information or ungrounded claims, and attaches the traces and span-level evidence behind each one. You review an issue list instead of thousands of traces, and each issue links back to the traces that support it.

MLflow Issues page listing detected issues for an LLM application, with severity, category, and evidence from traces
Detected issues group related failures and link to evidence in the traces. Demo data.

Issue detection runs from the Traces tab and uses the model you choose, so it incurs LLM calls. See the automatic issue detection guide and AI issue discovery.

What Should I Look for in an LLM Trace Analytics Platform?

Many tools offer GenAI observability and LLM monitoring. When you compare platforms for LLM trace analytics, these criteria matter most, and they are where an open-source platform like MLflow is designed to help:

CriterionWhat to checkIn MLflow
Ownership of dataCan you self-host and keep traces in your own database?Open source under Apache 2.0, self-hosted on SQLite, PostgreSQL, or MySQL.
Framework coverageDoes tracing work across the LLM providers and agent frameworks you use?Automatic tracing integrations plus manual tracing for any Python code.
Search depthCan you filter on spans, tags, sessions, and quality scores as well as time?SQL-like filters on status, duration, spans, tags, metadata, feedback, and expectations.
Quality signalsDo judge scores and human feedback live next to the trace?Assessments attach to traces and chart on the Quality tab.
Evaluation loopCan production failures become test cases?Traces feed MLflow evaluation datasets and scorers in the same platform.

For a side-by-side look at specific tools, see top agent observability tools.

How Do I Get Started With Trace Analytics?

Trace analytics needs traces first. Enable tracing with one line for your framework, then open the experiment in the MLflow UI:

python
import mlflow
mlflow.set_tracking_uri("sqlite:///mlflow.db") # SQL store for the Dashboard
mlflow.set_experiment("my-agent")
mlflow.openai.autolog() # or langchain, anthropic, and other integrations
# Run your application, then start the UI:
# mlflow server --backend-store-uri sqlite:///mlflow.db

Open the experiment, then use Traces to search, Dashboard for trends, and Issues to review detected problems. The tracing quickstart walks through the setup, and production tracing covers sampling and deployment.

Frequently Asked Questions

Trace analytics is the practice of searching, aggregating, and mining the traces that an LLM application or agent produces, so you can find slow, expensive, failing, or low-quality requests and understand why they happened. A trace records every step of one request: prompts, model calls, tool calls, retrieved documents, latency, and token usage. Analytics works across thousands of those traces instead of reading them one at a time.

Related Resources