-
Notifications
You must be signed in to change notification settings - Fork 580
feat(integration): add gen_ai.conversation.id if available
#5307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
e5ad308
8884375
c446c35
ca2b9ba
e5d0ffa
5e0d558
5f73e4f
b09e718
635606f
fcd77a7
c67deeb
621766c
852402e
0f8c7ec
bc43364
2359f29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ def update_ai_client_span( | |
| span: "sentry_sdk.tracing.Span", | ||
| response: "Any", | ||
| response_model: "Optional[str]" = None, | ||
| agent: "Optional[Agent]" = None, | ||
| ) -> None: | ||
| """Update AI client span with response data (works for streaming and non-streaming).""" | ||
| if hasattr(response, "usage") and response.usage: | ||
|
|
@@ -59,3 +60,9 @@ def update_ai_client_span( | |
| span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, response_model) | ||
| elif hasattr(response, "model") and response.model: | ||
| span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, str(response.model)) | ||
|
|
||
| # Set conversation ID from agent if available | ||
| if agent: | ||
| conv_id = getattr(agent, "_sentry_conversation_id", None) | ||
| if conv_id: | ||
| span.set_data(SPANDATA.GEN_AI_CONVERSATION_ID, conv_id) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Callers don't pass agent to update_ai_client_spanMedium Severity The |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,3 +51,8 @@ def update_execute_tool_span( | |
|
|
||
| if should_send_default_pii(): | ||
| span.set_data(SPANDATA.GEN_AI_TOOL_OUTPUT, result) | ||
|
|
||
| # Add conversation ID from agent | ||
| conv_id = getattr(agent, "_sentry_conversation_id", None) | ||
| if conv_id: | ||
| span.set_data(SPANDATA.GEN_AI_CONVERSATION_ID, conv_id) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated pattern for setting conversation ID on spansLow Severity The same 3-line pattern for extracting and setting |
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing conversation_id on workflow span in async runner
Medium Severity
In
_create_run_wrapper, the comment says "Set conversation ID on workflow span early" but the code only storesconversation_idon the agent object (agent._sentry_conversation_id). Unlike the streaming version_create_run_streamed_wrapper, there's no call toset_data(SPANDATA.GEN_AI_CONVERSATION_ID, conversation_id)on the workflow span itself. The workflow span (transaction) will be missing thegen_ai.conversation.idfield when usingRunner.run().