Skip to content

[opentelemetry-instrumentation-google-genai] Add response id attribute, cleanup dictutil code#119

Open
DylanRussell wants to merge 11 commits into
open-telemetry:mainfrom
DylanRussell:add_resp_id
Open

[opentelemetry-instrumentation-google-genai] Add response id attribute, cleanup dictutil code#119
DylanRussell wants to merge 11 commits into
open-telemetry:mainfrom
DylanRussell:add_resp_id

Conversation

@DylanRussell

@DylanRussell DylanRussell commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

Add response id attribute to inference span and completion event for Google GenAi...

See https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/

I also drastically cleaned up the dict_util code which converts the GenerateContentConfig object into OTEL Attributes dictionary.. I deleted some unused functionality and cleaned up the code.

Type of change

  • [ x] New feature (non-breaking change which adds functionality)

How has this been tested?

Unit tests

Checklist

See CONTRIBUTING.md
for the style guide, changelog guidance, and more.

  • [x ] Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • [ x] Unit tests added
  • [ x] Documentation updated

@DylanRussell DylanRussell changed the title Add response id attribute to inference span and completion event. [opentelemetry-instrumentation-google-genai] Add response id attribute to inference span and completion event. Jun 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds gen_ai.response.id propagation for Google GenAI generate_content so the response id can be attached to the inference span and the completion event, aligning with the GenAI semantic conventions.

Changes:

  • Extract response_id from GenerateContentResponse and attach it to the util-genai InferenceInvocation.
  • Update non-streaming tests to assert gen_ai.response.id presence/absence on spans/events.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
instrumentation/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/generate_content.py Captures response attributes (including response id) into the invocation for span/event emission.
instrumentation/opentelemetry-instrumentation-google-genai/tests/generate_content/nonstreaming_base.py Adds non-streaming assertions validating the gen_ai.response.id attribute behavior.

@DylanRussell DylanRussell changed the title [opentelemetry-instrumentation-google-genai] Add response id attribute to inference span and completion event. [opentelemetry-instrumentation-google-genai] Add response id attribute, cleanup dictutil code Jun 10, 2026
@DylanRussell

Copy link
Copy Markdown
Contributor Author

@eternalcuriouslearner @lmolkova mind taking another look ? Ended up doing a bunch of code cleanup after noticing some messy code here..

@DylanRussell

Copy link
Copy Markdown
Contributor Author

The failing tests In the CI will be fixed by #117 and or #133

@DylanRussell

Copy link
Copy Markdown
Contributor Author

I think this PR should be good to be merged now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants