-
Notifications
You must be signed in to change notification settings - Fork 917
Add id and finish_reason to OpenTelemetry instrumentation (closes #886) #1882
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: main
Are you sure you want to change the base?
Conversation
if response.vendor_id is not None: | ||
new_attributes['gen_ai.response.id'] = response.vendor_id | ||
if response.vendor_details is not None: | ||
new_attributes['gen_ai.response.finish_reasons'] = json.dumps(response.vendor_details) |
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.
vendor_details
can contain a lot more than just finish reasons, so we should just use the finish_reason
key.
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.
I also notice that https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-events/ requires finish_reasons
to be a list, and it lists some specific known values we should use:
- content_filter
- error
- length
- stop
- tool_calls
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.
It seems reasonable to add a new finish_reason
field to ModelResponse
that has those 5 values as Literal
and also allows any string. We should then update the finish_reason code in the Google and Gemini models to try to map to those values if possible.
@Deriverx2 Would you be up for implementing that?
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.
Yes sure @DouweM
Could you check it and provide whether this is ok for mapping in gemini, and provide some context on how to make changes in google model. @DouweM |
This PR addresses issue #886 by adding support for gen_ai.response.id and gen_ai.response.finish_reasons attributes to the OpenTelemetry instrumented.py implementation, in accordance with the OpenTelemetry semantic conventions.