You are instrumenting a production agent with a planner, retrieval, tool calls and two model providers, and you want vendor-neutral traces. How would you use the OpenTelemetry GenAI semantic conventions, and what would you do about the fact that they are still marked Development?
Answer
Model answer, written in a candidate's voice
In short
- Use OTel spans as the vendor-neutral backbone: one agent invocation span containing retrieval, tool-execution and model-call spans, correlated by conversation/session id and links.
- Record operation name, provider/system, requested and returned model, input/output/cached token usage and error type; keep exact attribute names version-pinned.
- Treat prompt/completion content as opt-in: redact by default or store by reference with access controls and retention limits.
- Pin the GenAI conventions version, isolate mapping in a thin layer or collector transform, and avoid long-lived dashboards on unstable names.
- Tag traces with app/prompt/model-snapshot version and sample them for LLM-judge and human review; roll tokens up into cost per feature or tenant.
- Use tail-based sampling to keep all errors and slow traces plus a baseline of successes, with head sampling only for volume control.
In full
I would make the agent invocation the root span and put retrieval, tool-execution and model-call spans underneath it, correlated by a conversation/session id and by span links for async or cross-service work, so the trace is vendor-neutral even though the providers differ. I would record the operation name, provider/system, requested and returned model, input and output token counts including cached tokens, and error type, while treating prompt and completion content as opt-in: redact by default or store by reference in a controlled store with access controls and retention limits, because it often contains personal data. Because the GenAI conventions are still Development, I would pin the version, keep a thin mapping layer or collector transform, and avoid long-lived dashboards on unstable names; dashboards and alerts should be versioned and tested against schema changes. I would also tag traces with the app version, prompt template version and model snapshot, sample them for LLM-judge and human review, and roll token usage up into cost per feature or tenant. For sampling, I would prefer tail-based sampling in the collector that keeps all errors and slow traces plus a baseline of successful traces, using head sampling only to control volume.
What a strong answer covers
- Describes the span hierarchy: an agent invocation span containing model-call spans, tool-execution spans and retrieval spans, linked by a conversation or session id.
- Names the key attributes: operation name, provider, requested and returned model, input and output token counts (including cached tokens) and error type.
- Treats prompt and completion content as opt-in: redact or store by reference with access controls and retention limits, because it often contains personal data.
- Manages schema churn: pin the conventions version, keep a thin mapping layer or collector transform, and avoid building long-lived dashboards on unstable names.
- Links traces to quality and cost: tag traces with the app version (prompt, model snapshot), sample them for LLM-judge and human review, and roll token usage up into cost per feature or tenant.
- Chooses a sampling strategy, e.g. tail-based sampling that keeps all errors and slow traces.
Common mistakes
- Capturing full prompts and completions for every request by default.
- Using high-cardinality values such as user ids as agent names or metric labels.
Follow-ups
- How would you spot a regression caused by a provider’s silent model update using only traces?
- How do you attribute cost to tenants when several agents share one cached prefix?