[opentelemetry-instrumentation-google-genai] Add response ID attribute to the interactions API telemetry (inference span and event)#233
Conversation
…oogle GenAI instrumentation
opentelemetry-instrumentation-google-genai] Add conversation ID attribute to the interactions API telemetry (inference span and event)
There was a problem hiding this comment.
Pull request overview
Adds support for the GenAI semantic convention gen_ai.conversation.id in the shared opentelemetry-util-genai inference invocation, and wires it into the opentelemetry-instrumentation-google-genai Interactions API by mapping previous_interaction_id to that attribute.
Changes:
- Add
conversation_idtoInferenceInvocationand include it in span + inference-operation-details event attributes. - Populate
invocation.conversation_idforinteractions.create(sync + async) fromprevious_interaction_id/ config. - Add unit tests and changelog fragments for both the util and google-genai instrumentation packages.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| util/opentelemetry-util-genai/tests/test_utils.py | Adds a unit test for InferenceInvocation.conversation_id on spans (suggested to also assert the emitted event). |
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/_inference_invocation.py | Adds conversation_id field and emits gen_ai.conversation.id via _get_attributes() (affecting span + event). |
| util/opentelemetry-util-genai/.changelog/233.added | Changelog entry for util-genai conversation_id support. |
| instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/base.py | Adds a test asserting gen_ai.conversation.id is set from previous_interaction_id (suggested to also assert the event). |
| instrumentation/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/interactions.py | Sets invocation.conversation_id from previous_interaction_id for sync/async interactions.create. |
| instrumentation/opentelemetry-instrumentation-google-genai/.changelog/233.added | Changelog entry for google-genai interactions telemetry including conversation.id. |
|
This PR has review comments. Review suggestions, whether from maintainers or automated reviewers, aren't always correct or required. Please evaluate each comment on its merits, then make sure each thread has a clear outcome. For example, link to the commit if you applied a suggestion, explain why it wasn't applied, or ask a follow-up question. Automation flags a PR for human review once every review thread has a reply or is marked as resolved. Status across open PRs is visible on the pull request dashboard. |
opentelemetry-instrumentation-google-genai] Add conversation ID attribute to the interactions API telemetry (inference span and event)opentelemetry-instrumentation-google-genai] Add response ID attribute to the interactions API telemetry (inference span and event)
Description
Set response id attribute to interactions.id
Type of change
Please delete options that are not relevant.
How has this been tested?
Unit tests
Checklist
See CONTRIBUTING.md
for the style guide, changelog guidance, and more.