Design the observability stack for a production LLM application. What does a good trace look like?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Model the system as traces of spans, exactly like distributed tracing - because an LLM request is a distributed computation. One user request = one trace; each unit of work = a span with start/end times, attributes, and parent links:
flowchart TD
T["Trace: user request"] --> G["Span: input guardrail"]
T --> R["Span: retrieval<br/>(query, top-k IDs, scores)"]
T --> L1["Span: LLM call #1<br/>(model+version, params, tokens, TTFT)"]
L1 --> TC["Span: tool execution<br/>(name, args, result, status)"]
T --> L2["Span: LLM call #2 (final)"]
T --> P["Span: output guardrail"]
Full worked answer with diagram
Model the system as traces of spans, exactly like distributed tracing - because an LLM request is a distributed computation. One user request = one trace; each unit of work = a span with start/end times, attributes, and parent links:
flowchart TD
T["Trace: user request"] --> G["Span: input guardrail"]
T --> R["Span: retrieval<br/>(query, top-k IDs, scores)"]
T --> L1["Span: LLM call #1<br/>(model+version, params, tokens, TTFT)"]
L1 --> TC["Span: tool execution<br/>(name, args, result, status)"]
T --> L2["Span: LLM call #2 (final)"]
T --> P["Span: output guardrail"]
Per-span attributes: model and exact version (never just an alias), sampling params, rendered prompt and completion (or redacted pointers), input/output token counts, TTFT and total latency, cost, cache-hit status, finish reason, error details, prompt-template version, and for retrieval spans the chunk IDs + scores. Adopt OpenTelemetry GenAI semantic conventions (gen_ai.request.model, gen_ai.usage.input_tokens, etc.) so instrumentation is portable across backends and your LLM spans live in the same trace as your ordinary service spans - one trace from HTTP ingress through retrieval to token stream.
Layers on top of raw traces:
- Metrics/alerting: per-route dashboards for p50/p95 latency, TTFT, tokens per request, cost per session, error and guardrail-trigger rates, plus drift alarms on their trends.
- Feedback joins: thumbs, regenerations, escalations, and A/B arm assignment keyed to trace IDs - this join is what makes error analysis possible; without it the loop is dead.
- Online quality sampling: run cheap judges (e.g., faithfulness) on a sample of live traces asynchronously - quality monitoring, not just ops monitoring.
- Dataset export: one-click "send this trace to the eval set" - the mechanical link in the eval-driven development loop.
Governance: PII redaction at ingestion, retention limits, role-based access to raw prompt content, deletion-request support, and sampling policy (keep 100% of errors/negative-feedback traces, sample successes).
Tooling: LangSmith, Langfuse, Braintrust, W&B Weave, Arize Phoenix all implement this shape (tracing + datasets + eval runs) with different open-source/hosted tradeoffs - the architecture above matters more than the vendor.
What a good answer covers
- Model the system as traces of spans, exactly like distributed tracing - because an LLM request is a…
- Per-span attributes: model and exact version (never just an alias), sampling params, rendered prompt and…
- Adopt OpenTelemetry GenAI semantic conventions (gen_ai.request.model, gen_ai.usage.input_tokens, etc.)…
- Metrics/alerting: per-route dashboards for p50/p95 latency, TTFT, tokens per request, cost per session,…
- Feedback joins: thumbs, regenerations, escalations, and A/B arm assignment keyed to trace IDs - this…
Key terms: traces of spans · Per-span attributes · OpenTelemetry GenAI semantic conventions · Metrics/alerting · Feedback joins · Online quality sampling · Dataset export · Governance
In the glossary: TTFT · Drift · Error analysis · Judge (LLM-as-judge) · Faithfulness · Eval set
Interviewer follow-ups to expect
How do you trace streaming responses and attribute TTFT vs generation time?
What sampling policy keeps costs sane at 10M requests/day without losing the failures?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep