OpenTelemetry for Enterprise AI Agents: W3C Traceparent, MCP Spans & Data Custody
Connecting application spans, model API calls, Managed Agents sessions, and internal MCP servers into one W3C traceparent tree while avoiding auto-disable traps and ZDR/PII custody leaks.
- 01End-to-end agent tracing unites four layers—Application, Client SDK, Model Platform (
service.name = claude-platform), and internal MCP servers—by forwarding W3Ctraceparentinside MCPparams._meta. - 02Sending an incoming
traceparentheader with the sampled flag off (00) suppresses both the top-level API span and all nestedanthropic.mcp_tool_usespans. - 03OTLP/HTTP destinations require public-DNS
HTTPS 443without/v1/tracesmanually appended, and auto-disable immediately on3xxredirects, private IP resolution, or 24 hours of delivery failures. - 04Exported spans leave your model provider's Zero Data Retention (ZDR) boundary and enter your observability vendor's custody—default to
metadata_onlywhen ERP or PII payloads are in scope.
1. Four-Layer W3C Traceparent Propagation Into Internal MCP Servers
Debugging a multi-turn enterprise agent from flat HTTP logs is guesswork: an operator needs one unified trace showing the user request, every model reasoning turn, which MCP tool was selected, and how many milliseconds the downstream ERP replica or API spent.
- MCP
params._metaContext Handoff: Ontools/callinvocations, the platform injects atraceparentreferencinganthropic.mcp_tool_usedirectly intoparams._meta, letting internal MCP servers parent their database and validation spans seamlessly. - The Sampled-Off Suppression Trap: If an upstream gateway sends
traceparentwithsampled = 0, the platform emits zero spans for that turn; pin sampling to 100% on audited financial and shop-floor workflows.
[1] Enterprise App Span (W3C traceparent: 00-<traceId>-<spanId>-01)
└── [2] Client SDK Span (must include W3C TraceContext propagator alongside B3)
└── [3] Model Platform Span (service.name = "claude-platform")
├── anthropic.messages.create
└── anthropic.mcp_tool_use ──► forwards traceparent in params._meta!
└── [4] Internal Enterprise Ontology MCP Span (SQL / ERP BAPI latency)2. OTLP/HTTP Delivery Timeouts, Retries & Three Auto-Disable Triggers
While a default OpenTelemetry Collector listens on port 4318, cloud model push exporters require an HTTPS hostname on port 443 accepting protobuf OTLP/HTTP payloads:
- Base URL Hygiene & Compression Fallback: Supply the base prefix without
/v1/traces(the exporter appends/v1/tracesautomatically unless overridden). Payloads arrivegzip-compressed first and immediately retry uncompressed onHTTP 400or415. - Strict
5s / 5s / 10sBudget & Deduplication: Endpoints have5 secondsfor TLS handshake,5 secondsto response headers, and10 secondstotal including uncompressed fallback. Because delivery is at-least-once and best-effort, deduplicate in your SIEM/collector bytrace_id + span_id. - Three Silent Shutoff Triggers: Returning any
3xxredirect, resolving the collector hostname to a non-public IP, or failing all deliveries for24 hoursflips the destination toDisableduntil an administrator re-enables it.
3. Metadata-Only vs. Full Content, ZDR Eligibility & Data Custody
Observability pipelines frequently become accidental compliance leaks when Full content tracing is turned on indiscriminately:
- Custody & ZDR Boundaries: Once spans reach your third-party OTLP collector, they sit outside your LLM provider's custody and Zero Data Retention terms (and stateful Managed Agents sessions are not ZDR-eligible to begin with).
- Pair Best-Effort OTLP With Deterministic Ontology Audit Logs: Use
metadata_onlyOTLP spans for latency and token alerting, while recording immutable, caller-signed ERP read/write provenance inside your on-premise enterprise ontology keyed by the sharedtrace_id.
Best-effort OTLP exports can drop spans during collector maintenance without failing the agent turn. Keep authoritative approval and mutation logs inside your transactional ontology database.
Glossary Concepts Referenced in This Guide
Agent = Model + Harness) responsible for tool-calling loops, context compaction, retries, sandboxing, and execution traces.Free to reference in engineering docs, ADRs, articles, and course syllabi with attribution.
[OpenTelemetry for Enterprise AI Agents: W3C Traceparent, MCP Spans & Data Custody — Ontoloji.org](https://ontoloji.org/en/guides/opentelemetry-for-ai-agents-w3c-traceparent-mcp-spans-and-custody)