-
Notifications
You must be signed in to change notification settings - Fork 273
Using attributes for chat history on gen_ai spans and events #2179
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
Using attributes for chat history on gen_ai spans and events #2179
Conversation
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.
Thanks for putting this together! What's need to take this out of draft?
e2facbb
to
1ce1548
Compare
Unfortunately had to skip today's meeting because of a conflict. Wanted to bring up some cases for sending the prompts and messages as events:
All of this is specifically important for non-purposely built solution, but for a bigger observability platforms. @lmolkova My proposal would be to keep the events optional, and keep them in the existing implementations enabled with an environment variable. |
060af49
to
d3712a6
Compare
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.
Here is a rough prototype of this PR for opentelemetry-instrumentation-google-genai
open-telemetry/opentelemetry-python-contrib@main...aabmass:opentelemetry-python-contrib:google-genai-message_ref
8113a4f
to
092db44
Compare
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.
Thanks for all your hard work and diligence @lmolkova !
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 wonder if we need first-class interaction with the JSON schema + weaver (e.g. live-check).
@lmolkova Have you already opened tickets in Weaver to make sure it also moves the same direction for supporting events here? (i.e. the 'nested' json schema approach), or are you considering something else going forward?
One complication was that in [email protected] 'interface ChatCompletionMessageToolCall' was changed to be: export type ChatCompletionMessageToolCall = | ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall; which complicated capturing 'tool_calls' info for the telemetry event. Note also that the GenAI semconv has since moved on. As of open-telemetry/semantic-conventions#2179 there is no longer a 'tool_calls' property in a captured event. This PR does *not* get into updating the semconv version used by this instrumentation. Unrelated, there was also a fix to a typo in the 'compile:with-dependencies' npm script for this package.
Fixes #2010, #2179, #1913, #1621, #1912
Depends on #2588
Key points:
gen_ai.system.instructions
attribute. It's not necessarily a part of chat history (when dealing with server-side agents)gen_ai.input.messages
attribute, format is defined in json schema (for now until we have tooling to define complex attributes). If uploading to an external storage, it's replaced withgen_ai.input.messages_ref
gen_ai.output.messages
(orgen_ai.output.messages_ref
)gen_ai.client.inference.operation.details
which captures all the details of the inference operation so that it can be useful if span is sampled out and/or if queries between spans and logs backends is problematic.Depends on #2046 (
gen_ai.system
rename and migration plan)