Skip to content
mentoor

Topic 4 of 6 · 5 min read

Linking traces to sessions, versions and feedback

Goal: List the tags a trace needs so that a support ticket, a thumbs-down and a prompt version can each be traced back to the exact request.

Stamp every trace with the ids and versions you will later search by, because a trace you cannot find from a complaint is a trace you cannot use.

Check yourself · 1 of 3

A user reports a bad answer from yesterday. What lets you find that exact trace fastest?

Choose one answer

Why it matters

A production system produces thousands of traces a day. A user writes, "your bot told me the wrong refund policy yesterday afternoon." Without a shared id you scroll. With one, you paste it into the search box. The same tags also answer bigger questions: did the answers get worse after the prompt change on Tuesday? Do thumbs-down cluster on one model version?

The tags to add

Put these on the root span (or as trace-level attributes), and pass them down with the trace context:

  1. Request id. One id per user request. Return it to the client and show it in the error or help screen so the user can quote it to support.
  2. Session or conversation id. Groups all turns of one chat. OTel uses gen_ai.conversation.id.
  3. User or tenant id. An internal id, not an email address. Needed to find one customer's traces and to delete them on request.
  4. Prompt version. The template name and version or hash, such as support@v7. Without it you cannot compare two prompt changes.
  5. Model snapshot. The model that actually answered, from the response, not just the alias in your config.
  6. Release or deploy id. Ties the trace to the code that ran.
  7. Feature name. Separates the summariser from the support bot when they share a backend.
  8. Feedback. When the user clicks thumbs-down, attach the score to the trace using the request id. Most tracing tools have a score or annotation field for this.

Keep tags consistent

Use fixed names and lower-cardinality values. prompt.version = "support@v7" filters well. A free-text value such as the whole system prompt does not. Write the tag list once, in a shared helper, so every service uses the same keys.

Before and after

Before: the trace has a timestamp and a model name. Feedback is stored in a separate table with only a user id and a time. Matching them is guesswork.

After:

{
  "request.id": "req_8f3a21",
  "gen_ai.conversation.id": "conv_5521",
  "tenant.id": "t_204",
  "prompt.version": "support@v7",
  "gen_ai.response.model": "model-2026-03",
  "release": "2026.12.1",
  "feedback.score": 0
}

The thumbs-down event carries req_8f3a21, so one query lands on the exact trace.

What goes wrong

  • Ids that exist only in the trace. The user and support never see them, so nobody can search.
  • Personal data as an id. Use internal ids so traces can be searched and deleted without exposing an email.
  • Prompt version missing. After a change, quality shifts and you cannot say which version caused it.

Examples

From ticket to trace

A support ticket quotes req_8f3a21 from the error screen. One search in the tracing tool opens the trace: retrieval returned the old refund page, and the prompt version was support@v7. The fix points at the index, not the prompt.

A before-and-after on a prompt change

The thumbs-down rate is higher on support@v7 traces than on support@v6. This comparison is only possible because the version is a tag. Filter by it, open five bad traces, and the cause is usually in the first two.

Key points

  • Give every request one id, return it to the client, and tag the trace with it.
  • Tag traces with session, tenant, prompt version, model snapshot and release so you can filter and compare.
  • Attach feedback to the trace by request id so a thumbs-down opens the exact request.
  • Use internal ids, not email addresses, so traces can be searched and deleted per user.
  • Define the tag names once in a shared helper so every service uses the same keys.

Common mistakes

  • Showing no request id to the user, so support has nothing to search.
  • Using an email address as the user tag.
  • Recording the model alias from config instead of the model named in the response.
  • Putting the full prompt text in a tag instead of a version id.

Check yourself · 2 of 3

Why tag each trace with the prompt version?

Choose one answer

Check yourself · 3 of 3

Which tag value is best for filtering traces by user?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic