1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →
What should you log and trace for LLM requests? What is OpenTelemetry's role?
30-second answerSay your answer out loud first, then reveal.
Per LLM span (example attributes)
gen_ai.system / provider, gen_ai.request.model, gen_ai.response.model
gen_ai.request.temperature, gen_ai.request.max_tokens
gen_ai.usage.input_tokens, gen_ai.usage.output_tokens (+ cached tokens if available)
latency_ms, ttft_ms, finish_reason, error_type
app.prompt_version, app.feature, app.tenant_id (non-PII), trace_id
payload: prompt / completion (redacted, sampled per policy)Practices
- Correlate: propagate trace IDs from frontend to backend to providers' request IDs.
- Redact PII before export; restrict access to payloads.
- Sample payloads (keep all errors and flagged requests) to control storage cost.
- Link feedback (thumbs, edits) to the trace ID.
- Metrics from traces: derive latency, cost and error dashboards.
Why OpenTelemetry: avoids lock-in to one observability vendor and integrates LLM traces with existing APM for the rest of the stack.
Related
Slow is fine. Stopping is the only problem.