Trace breaks at queue boundary
Detect: Worker spans appear as unrelated roots.
Recover: Test context serialization and use links where parentage is inappropriate.
Connect agent decisions, retrieval, model calls, and tool effects into one causal execution record using interoperable trace context.
Distributed tracing represents a request as timed operations called spans, connected by parent relationships or explicit links. For agents, the important unit is not merely the HTTP call: planning iterations, queued jobs, retrieval, inference, validation, and external effects each contribute to the outcome. OpenTelemetry supplies instrumentation and export conventions while the application defines meaningful workflow boundaries.
Trace context should follow work across HTTP, messaging, and asynchronous execution. A retry needs its own attempt span under the same logical operation; a batch assembled from several requests can use span links. Trace data is operational evidence, not a license to store full prompts, credentials, customer documents, or private reasoning.
A prototype traces one successful turn and verifies that model and tool timing explain its total duration.
Production propagates context through queues, correlates logs, redacts attributes, and defines error classification and sampling.
Enterprise scale needs collector capacity, stable semantic naming, controlled cardinality, cross-team ownership, and sampling strategies that retain unusual failures without collecting every payload.
Creates spans around workflow stages and injects or extracts context at boundaries.
Transfers trace identifiers through request headers or message metadata.
Receives, filters, batches, and exports telemetry without coupling the agent to one backend.
Stores causal execution records and enables latency and error investigation.
Allow-lists attributes and protects sensitive prompt or tool data before export.
sequenceDiagram
participant G as Gateway
participant A as Agent
participant Q as Work queue
participant W as Tool worker
participant C as Collector
G->>A: Request with trace context
A->>Q: Task and context carrier
Q->>W: Deliver work
W->>W: Tool attempt span
W-->>A: Result and operation identifier
A-->>G: Validated answer
A-->>C: Agent spans
W-->>C: Linked worker spansCreate a root span carrying a stable task type, tenant classification, and workflow revision without raw personal data.
Inject context when calling tools or publishing work; extract it in the receiving process.
Separate retrieval, provider queueing, inference, validation, and side-effect commit timings.
Attach model revision, token usage, retry reason, and structured error category to the appropriate attempt.
Batch telemetry through a collector with bounded buffers and backpressure behavior that cannot block business work indefinitely.
Correlate a failed workflow with logs and metrics while distinguishing parallel work from critical-path latency.
Manufacturing · Illustrative enterprise scenario, not a reported customer outcome.
A plant assistant reads equipment alarms, retrieves manuals, and asks a maintenance API for recent work orders.
Operators report occasional slow answers, but aggregate model latency appears normal.
Locate the causal bottleneck without exporting proprietary manuals or machine credentials.
Instrumentation wraps retrieval and work-order calls, propagates context through a job queue, and exports only approved identifiers.
If the collector becomes unavailable, bounded local buffering drops telemetry according to policy while the assistant continues serving.
Track trace completeness, critical-path time, and dropped telemetry; the value is actionable diagnosis rather than a larger collection of disconnected logs.
| Decision | Benefit | Cost |
|---|---|---|
| Detailed stage spans | Reveal hidden queueing and retry costs. | Increase instrumentation and storage volume. |
| Tail sampling | Can retain traces with observed failures or unusual latency. | Requires buffering and more collector resources. |
| Payload-free attributes | Reduce privacy exposure. | May require protected application records for deeper reproduction. |
Detect: Worker spans appear as unrelated roots.
Recover: Test context serialization and use links where parentage is inappropriate.
Detect: Index size and query latency grow with unique raw values.
Recover: Replace uncontrolled labels with bounded categories or non-indexed approved identifiers.
Use an attribute allow-list and separate governed evidence storage.
Record each attempt and its reason under a logical operation.
Use bounded asynchronous export with explicit loss metrics.