How do I centrally trace AI agents and MCP tools?
Summary
- To centrally trace AI agents and MCP tools, send every model call and every MCP tool call through one gateway that writes OpenTelemetry spans to one governed table, then add the agents' own client-side spans to the same table.
- On Databricks, Unity Gateway's unified trace table (Beta) captures requests across all Unity Gateway model services and MCP services in one Unity Catalog table, after a one-time setup by a metastore admin.
- Agents add their own spans three ways: supported coding agents through the Unity Gateway CLI, your applications through an OTLP endpoint (Beta), and MLflow Tracing for agent code.
- Central tracing needs central access control. The trace table is readable only by its creator until access is granted, and Databricks recommends ABAC row filter policies and a retention policy before production use.
How do I centrally trace AI agents and MCP tools?
Send every model call and every MCP tool call through one gateway that writes OpenTelemetry spans to one governed table, then add your agents' client-side spans to that same table so a single trace shows what the agent did and what the gateway served. "Central" means one setup, one schema and one access model, instead of a log per endpoint and a tracing backend per team. On Databricks, the unified trace table in Unity Gateway (Beta) does this in Unity Catalog, and MLflow Tracing covers the agent code itself.
What central tracing requires
| Requirement | Why it matters |
|---|---|
| One collection point for model and tool traffic | No blind spots from services that never turned logging on |
| An open span format | OpenTelemetry spans can be read by any compatible tool |
| Client-side and gateway spans in one place | Agent reasoning and the calls it caused appear together |
| Trace context propagation | Joins an agent's spans to the gateway spans they produced |
| Row-level access control | Teams see their own traces without exposing everyone's prompts |
| A retention policy | Trace tables grow without limit unless you prune them |
How Databricks approaches central tracing
Gateway spans. Unity Gateway governs model services and MCP services as Unity Catalog securables. The unified trace table (Beta) captures every request and response across those services in one Unity Catalog table in OpenTelemetry format. An account admin enables the Enhanced Unity Gateway preview. A metastore admin then sets up tracing once, under Govern > Traces > Set up tracing, by choosing a catalog and schema. After that, all Unity Gateway traffic from workspaces attached to the metastore is logged with no per-endpoint setup. The docs recommend it over inference tables for new deployments, since inference tables are configured per endpoint.
Each row is one span, in an MLflow-compatible OpenTelemetry schema that MLflow tools can read directly. Model spans carry gen_ai.request.model, enduser.id and token usage. MCP spans carry mcp.method.name, gen_ai.tool.name, tool arguments and results, and rpc.response.status_code. The events column records a policy_evaluated event for each evaluated policy and phase (schema reference).
Agent spans. Three routes put client-side activity in the same table:
- Coding agents. Admins add
"tracing": {"enabled": true}to each supported agent's configuration and publish it. Developers who launch through the Unity Gateway CLI then send client-side traces of tool and skill use to the trace table (Monitor coding agent activity). - Your applications. Any OpenTelemetry SDK can export spans to
https://<workspace-url>/ai-gateway/otel/v1/traces, which accepts OTLP over HTTP with binary protobuf encoding only. Client-side span ingestion is in Beta and is enabled per workspace by your Databricks account team. - Linked traces. If your application propagates W3C trace context (the
traceparentheader), gateway request spans join that trace. Gateway trace linking is a separate Beta, also enabled per workspace. The gateway doesn't forward trace context to the upstream model provider.
Agent code. MLflow Tracing, part of open-source MLflow and managed on Databricks, instruments agent frameworks with mlflow.<framework>.autolog(). Traces stored in Unity Catalog use OpenTelemetry format and are queryable with SQL (Store traces in Unity Catalog).
Govern access. By default, only the metastore admin who creates the trace table can read it. Databricks recommends an ABAC row filter policy before granting SELECT, so endpoint owners see only their own services' traces, or a separate copy with PII redacted for wider access. The docs advise defining retention before production use, for example with auto time-to-live, because Databricks doesn't manage the table's lifecycle.
How teams use a central trace table
- Debugging. Filter by
trace_idto replay every step of a failed agent run, or byservice_nameandstatus.codeto find every error on one endpoint. - Security review. Each span records the requester identity, endpoint name and request payload, which you can feed into security tooling.
- Audit support. Review AI activity for one user, endpoint or time range. Audit logs remain the system of record for compliance, because trace delivery is best-effort.
FAQs
Do I need to change my MCP servers?
No. Gateway traces capture model and MCP requests handled by Unity Gateway, so tool calls are traced at the gateway once the MCP server is registered there.
Can I see a full multi-hop agent trace?
Partly. All hops land in one table, and trace linking (Beta) joins your application's spans to the gateway spans when you propagate trace context. The docs list shared trace IDs for reconstructing a full multi-hop trace as not yet available.
Is Unity Gateway itself in Beta?
No. The docs state that Unity Gateway is generally available and that its Beta capabilities, including the unified trace table, are enabled separately.
Can I query traces without writing SQL?
Yes. The Traces view under Govern filters by service, principal, service type, state and execution time, and Genie Code can write SQL against the trace table for you.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.