Repository navigation
feat: correlate telemetry spans with the conversation - #7533
Conversation
c90da2f to
9f782ff
Compare
Co-authored-by: Sanjay Kukadiya <43816307+SanjuMLGeek@users.noreply.github.com>
9f782ff to
735f51e
Compare
There was a problem hiding this comment.
Note
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| if (conv := _conversation_id()) is not None: | ||
| attrs[trace_types.ATTR_GEN_AI_CONVERSATION_ID] = conv |
There was a problem hiding this comment.
🟡 External GenAI spans lose conversation grouping
When an integrator calls set_tool_attributes on a span from their own tracer, it no longer receives a conversation ID. Only the LiveKit tracer injects that ID, so external tool spans disappear from conversation-grouped views.
Learn more
The exported GenAI attribute setters accept any OpenTelemetry span. Previously, set_tool_attributes attached the room SID to a recording span even if another tracer created it. The LiveKit tracer now adds that attribute at span creation, but an SDK tracer obtained from a provider does not pass through that wrapper. The same loss affects the request, agent, and workflow setters when used with external spans. An integrator using the public setters with an SDK tracer therefore emits GenAI spans without conversation grouping.
Example: Inside a job for room RM_42, an integration creates span = provider.get_tracer("custom").start_span("function_tool"), then calls gen_ai.set_tool_attributes(span, name="lookup"). The exported span has gen_ai.tool.name, but no gen_ai.conversation.id; previously it carried RM_42.
Recommended fix: Preserve a fallback in all four GenAI setters for spans without an existing conversation ID. Ensure that fallback does not overwrite an explicit ID already present on a span created through the LiveKit tracer or supplied by its caller.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
external tracer will have to take care of conversation id themselves when choosing not to use ours
Spans from speech processing and tools need the same conversation ID for session grouping. Attach the room SID through the LiveKit tracer, preserve explicit IDs, and omit the field outside a job.
Adapts @SanjuMLGeek’s proposal in #7396 and handles positional attributes without mutating caller mappings.
Stacked on #7532.
Addresses AGT-3603
Request summary and agent context
Model: GPT-6-Astra
Split the proposed telemetry improvements into focused PRs that are easy to review and revert. Use general problem summaries and omit customer details.