Skip to content

Conversation

@DylanRussell
Copy link
Contributor

@DylanRussell DylanRussell commented Oct 29, 2025

Description

  • Fixes an issue where the instrumentation would crash when a pydantic.BaseModel class was passed as the response schema to GenerateContentConfig, the code expected a class instance for some reason (see BaseModel.model_dump() called on class instead of instance in opentelemetry-instrumentation-google-genai #3596).
  • Ensures the same Sem Conv attributes are added to the Log and the Span. The gen AI semantic conventions are basically the same for log events and spans. Adds the error.type sem conv attribute when there's an exception raised.
  • Moves the _maybe_log_completion_details( function call into the finally block for the 4 instrumentation variants (sync/async streaming/non). This ensures we always write the event and call the completion hook etc. even when there's an exception thrown.
  • Ensure the new gen_ai.client.inference.operation.details log event is written and completion upload hook are called when OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental.
  • Some code cleanup / refactoring.

Fixes # 3596

Type of change

Please delete options that are not relevant.

  • [ x] Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Unit tests

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • [ x] No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • [x ] Followed the style guidelines of this project
  • [x ] Changelogs have been updated
  • [ x] Unit tests have been added
  • Documentation has been updated

@DylanRussell DylanRussell requested a review from a team as a code owner October 29, 2025 20:24
@DylanRussell DylanRussell changed the title Fix a few bugs in gen AI instrumentation Fix a few bugs in the Google gen AI instrumentation Oct 29, 2025
@DylanRussell DylanRussell changed the title Fix a few bugs in the Google gen AI instrumentation Fix a few bugs in opentelemetry-instrumentation-google-genai instrumentation package Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants