-
Notifications
You must be signed in to change notification settings - Fork 578
feat(gen_ai): add function set_conversation_id and managing functions on the Scope and apply it on the Span on .finish()
#5362
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
91776d8
7bd8455
51f9467
30f025c
80b15e5
bba9174
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 |
|---|---|---|
|
|
@@ -676,6 +676,17 @@ def finish( | |
| self.timestamp = datetime.now(timezone.utc) | ||
|
|
||
| scope = scope or sentry_sdk.get_current_scope() | ||
|
|
||
| # Copy conversation_id from scope to span data if this is an AI span | ||
| conversation_id = scope.get_conversation_id() | ||
| if conversation_id: | ||
| has_ai_op = "gen_ai.operation.name" in self._data | ||
|
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. Hardcoded string used instead of existing constantLow Severity The code uses a hardcoded string |
||
| is_ai_span_op = self.op is not None and ( | ||
| self.op.startswith("ai.") or self.op.startswith("gen_ai.") | ||
| ) | ||
| if has_ai_op or is_ai_span_op: | ||
| self.set_data("gen_ai.conversation.id", conversation_id) | ||
|
|
||
| maybe_create_breadcrumbs_from_span(scope, self) | ||
|
|
||
| return None | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.