Review one span from a new instrumentation branch

L3SeniorCode reading12 minCodingDesign review

RolesAI Evaluation and ReliabilityInference EngineeringAI Data Systems

The question

A colleague opens a review that adds tracing to the agent. The branch emits this span for every model call. List every problem you find before you approve it.

json
{
  "traceId": "abcdefabcdefabcdefabcdefabcdefab",
  "spanId": "abcdefabcdefabcd",
  "parentSpanId": "",
  "name": "chat",
  "kind": "INTERNAL",
  "attributes": {
    "gen_ai.operation.name": "chat",
    "gen_ai.request.model": "our_smart_model",
    "gen_ai.usage.prompt_tokens": 500,
    "gen_ai.content.prompt": "You are a support agent. The customer's card number is ..."
  }
}

Answer it first, aloud or on paper. Then open the answer.

The answer

Show short answer

The span marks a model call as INTERNAL, has no parent, and uses an old attribute name for the input tokens. It omits the provider, the output tokens, the response model and the response id, and it writes the prompt text, with a card number in it, into the trace. Fix the kind and the parent link, use the current attribute names, add the missing attributes, and move the content out of the span.

Show full answer

The problems, in order of damage

LineProblemFix
parentSpanId: ""an orphan span; no backend can show which agent step made the callpass the parent context from the invoke_agent span
kind: INTERNALa model call crosses a process boundaryCLIENT
gen_ai.content.promptprompt text with customer data in a store that operators readcapture off by default; store content outside and put a reference id on the span
gen_ai.usage.prompt_tokensthe attribute was renamed; backends read gen_ai.usage.input_tokensuse the current name and add gen_ai.usage.output_tokens
no gen_ai.provider.namecost and error dashboards cannot split by providerset it on every model span
no gen_ai.response.modelwith routing, the served model can differ from the requested aliasrecord what the provider returned
no gen_ai.response.idno way to match the span to the provider's own logrecord the response id

Why the content line is the one to fight over

The conventions say instrumentations should not capture inputs and outputs by default. Capture is opt-in through an environment variable, and the production pattern stores content in your own log store and records a pointer on the span. A prompt with a card number in a trace backend is a data leak with a retention policy you did not choose.

Why the renamed attribute will come back

The GenAI conventions are still marked as in development, and they have renamed attributes before. Pin the conventions version you emit, set the stability opt-in, and test the attribute names of emitted spans, or the next SDK upgrade reopens this review.

Follow-ups

  1. L3SeniorWhy does the empty parent matter more than the wrong kind?

    Show expected answer

    with no parent the span is an orphan, the trace is no longer a tree, and you cannot see which step made the call.

  2. L3SeniorThe team needs the prompt text to debug failures. What do you offer?

    Show expected answer

    store prompts in a separate store with access control and put a reference id on the span, which is the pattern the conventions recommend for production.

  3. L4StaffHow do you keep the old attribute name from returning after an upgrade?

    Show expected answer

    pin the conventions version, set the stability opt-in variable, and add a test that asserts the attribute names on emitted spans.

Wrong answers

Show the wrong answers that interviewers hear
  • “It has a trace id and a model name, so it is fine.”

    A trace id alone does not link the span to its parent, and a model name without a provider cannot be attributed.

  • “Keep the prompt in the span, it is useful.”

    Prompts carry personal data and secrets into a store that operators read. The default is off, and production stores content outside the span.

  • “The two token names are synonyms.”

    Backends read the current name. The old one lands in an unknown attribute, and the token dashboard shows nothing.

Taught in

The OpenTelemetry GenAI lesson lists the required attributes, the conventions lesson gives the content-capture rule, and the capstone traces lesson notes the renamed token attribute.