Using attributes for chat history on gen_ai spans and events#2179
Merged
lmolkova merged 5 commits intoopen-telemetry:mainfrom Aug 19, 2025
Merged
Using attributes for chat history on gen_ai spans and events#2179lmolkova merged 5 commits intoopen-telemetry:mainfrom
lmolkova merged 5 commits intoopen-telemetry:mainfrom
Conversation
lmolkova
commented
Apr 24, 2025
lmolkova
commented
Apr 24, 2025
lmolkova
commented
Apr 24, 2025
aabmass
reviewed
Apr 30, 2025
Member
aabmass
left a comment
There was a problem hiding this comment.
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. |
aabmass
reviewed
May 13, 2025
060af49 to
d3712a6
Compare
lmolkova
commented
May 20, 2025
lmolkova
commented
May 20, 2025
lmolkova
commented
May 20, 2025
Cirilla-zmh
approved these changes
May 29, 2025
Cirilla-zmh
reviewed
May 29, 2025
aabmass
reviewed
Jun 3, 2025
Member
aabmass
left a comment
There was a problem hiding this comment.
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
6 tasks
This was referenced Aug 19, 2025
3 tasks
This was referenced Sep 8, 2025
5 tasks
1 task
trentm
added a commit
to trentm/opentelemetry-js-contrib
that referenced
this pull request
Oct 8, 2025
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.
6 tasks
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2010, #2179, #1913, #1621, #1912
Depends on #2588
Key points:
gen_ai.system.instructionsattribute. It's not necessarily a part of chat history (when dealing with server-side agents)gen_ai.input.messagesattribute, 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_refgen_ai.output.messages(orgen_ai.output.messages_ref)gen_ai.client.inference.operation.detailswhich 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.systemrename and migration plan)