Skip to content

Implementation / Field notes

Trace a multi-step LLM request across services

Find broken trace continuity across a gateway, retrieval service, and model call using parent IDs and a reproducible orphan-span example.

By DriftRail · Updated

Trace an LLM request across services by preserving its trace context at each boundary and recording each operation’s parent or explicit causal link. Begin at the first disconnected operation, rather than assuming that every missing span is a model failure.

A retrieval call disappears from the request

Consider a gateway that calls a retrieval service, which then calls a model. All three services emit spans, but the model operation starts a new trace. Searching the gateway trace therefore looks as though generation never happened. The operation may exist under another trace identifier; distinguish broken correlation from dropped telemetry.

Inspect the boundary in order

  1. Choose one synthetic request with a known request identifier and note every expected service.
  2. Compare outgoing and incoming context at the retrieval-to-model boundary. Check proxies, queues, and asynchronous execution separately.
  3. Check whether the instrumentation extracted incoming context before starting the next operation.
  4. Verify exporter delivery and sampling independently after context continuity is understood.

Read the orphan-span example

The example has a gateway span and a valid retrieval child. A model span names a parent that is absent from the same trace. Its assertion identifies the model span as an orphan, then checks that linking it to the retrieval span repairs the synthetic tree. This is a check of the records, not a full implementation of W3C header validation.

What a successful investigation leaves behind

Retain the affected service boundary, instrumentation versions, sanitized context identifiers, and a before/after trace. If work intentionally begins another trace, record the causal link and explain the boundary instead of forcing an inaccurate parent relationship. A complete-looking tree still does not prove that every application operation was instrumented.

Run the worked example

Save the synthetic Node.js example and run node trace-llm-requests-across-services.mjs with Node.js 22 or newer. The assertions check the illustrated records and calculations; they do not test a deployed provider, SDK, or access control. No credentials or network connection are needed.

// Synthetic teaching fixture. No credentials, network calls, or production verification.
import assert from 'node:assert/strict';

const spans = [
  { trace: 'request-a', id: 'gateway', parent: null },
  { trace: 'request-a', id: 'retrieval', parent: 'gateway' },
  { trace: 'request-a', id: 'model', parent: 'missing-parent' },
];
const orphans = rows => rows.filter(span => span.parent &&
  !rows.some(parent => parent.trace === span.trace && parent.id === span.parent));
assert.deepEqual(orphans(spans).map(s => s.id), ['model']);
const repaired = spans.map(s => s.id === 'model' ? { ...s, parent: 'retrieval' } : s);
assert.equal(orphans(repaired).length, 0);
console.log('Missing parent: model; repaired trace: no orphan spans.');

References and further reading

Maintained by DriftRail. AI assisted the October 2026 content and template revision. Examples are illustrative; they are not measured product benchmarks. Suggest a correction.

From understanding to evidence

Observe your AI in production.

Explore event logging, detections, and review workflows in DriftRail.

Open DriftRail ↗Read the documentation →