-
Notifications
You must be signed in to change notification settings - Fork 567
Make OpenAI span data OTel compatible #4613
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
Make OpenAI span data OTel compatible #4613
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## antonpirker/openai-overhaul #4613 +/- ##
===============================================================
+ Coverage 80.68% 80.72% +0.04%
===============================================================
Files 156 156
Lines 16579 16612 +33
Branches 2814 2830 +16
===============================================================
+ Hits 13376 13410 +34
- Misses 2311 2313 +2
+ Partials 892 889 -3
|
| if finish_span: | ||
| span.__exit__(None, None, None) |
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.
Looks like we have this check in each branch (maybe I'm mistaken), can we just move it after the whole if branch?
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.
Actually, can we move it out of this function altogether and end the span after the call to this function? I'd not expect _set_output_data to do any actual span lifecycle management. And _set_input_data also doesn't start spans, so it's a bit inconsistent.
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.
unfortunately we can not move this out. because the span is finished in the generators defined in this function. if we move the finish outside the span will be finished too early and not only after the decorator is finished iterating over.
Co-authored-by: Ivana Kellyer <[email protected]>
fbbb5c4
into
antonpirker/openai-overhaul
Make sure all OpenTelemetry semantic conventions for AI clients and also the Sentry Conventions are adhered to.
Also cleans up the code a bit for better readability/maintenance.