Skip to content

Update google genai instrumentation to work with latest semantic convention, allow for uploading content.#3772

Merged
aabmass merged 40 commits intoopen-telemetry:mainfrom
argaj:genai-instrumentation-semconv
Oct 13, 2025
Merged

Update google genai instrumentation to work with latest semantic convention, allow for uploading content.#3772
aabmass merged 40 commits intoopen-telemetry:mainfrom
argaj:genai-instrumentation-semconv

Conversation

@argaj
Copy link
Copy Markdown
Contributor

@argaj argaj commented Sep 22, 2025

Description

Accomodation of semantic conventions changes made in open-telemetry/semantic-conventions#2179.

Also, when logging the completion details, the upload hook is called, so if user has configured OTEL_INSTRUMENTATION_GENAI_UPLOAD_BASE_PATH and OTEL_INSTRUMENTATION_GENAI_UPLOAD_HOOK env vars, completion details will also be logged as refs (if appropriate capture content env var is set).

Type of change

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

How Has This Been Tested?

Unit tests, manual tests.

Does This PR Require a Core Repo Change?

No

Checklist:

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

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

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Sep 22, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@argaj argaj force-pushed the genai-instrumentation-semconv branch from e76d888 to d0d6f1a Compare September 25, 2025 13:30
@argaj argaj force-pushed the genai-instrumentation-semconv branch from d0d6f1a to ee911f5 Compare September 26, 2025 11:32
@argaj argaj force-pushed the genai-instrumentation-semconv branch from 5d0572a to 8583327 Compare September 29, 2025 09:23
@argaj argaj changed the title [WIP] Update google genai instrumentation to work with latest semantic convention, allow for uploading content. Update google genai instrumentation to work with latest semantic convention, allow for uploading content. Sep 30, 2025
@argaj argaj marked this pull request as ready for review September 30, 2025 17:36
@argaj argaj requested a review from a team as a code owner September 30, 2025 17:36
Copy link
Copy Markdown
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

Thank you, LGTM! Will merge once Dylan has finished reviewing/approved too.

@aabmass aabmass enabled auto-merge (squash) October 13, 2025 19:50
@aabmass aabmass merged commit c17e428 into open-telemetry:main Oct 13, 2025
638 checks passed
sightseeker added a commit to sightseeker/opentelemetry-python-contrib that referenced this pull request Mar 11, 2026
…ention, allow for uploading content. (open-telemetry#3772)

* Update google genai instrumentation to latest semantic convention.

Co-authored-by: Aaron Abbott <aaronabbott@google.com>

* fix: log roles as str, event attrs as objects.

* fix: proper event name

* refactor: remove unused message models.

* refactor: use OTel imported semconv attributes.

* refactor: Inject upload_hook in Instrumentor.

* refactor: rename upload hook to completion hook.

* test: add tests for non streaming case and tool_call_wrapper.

* test: add tool call instrumentation tests and nonstreaming recording in spans test.

* fix: remove print

* feature: add blobpart and filepart to message handling

* fix: encode bytes as base64 when dumping to json string.

* fix: always call completion hook, independently of recording settings.

* test: update requirements for instrumentation-google-genai oldest env

* test: bump google-genai lib version in -oldest test env.

* test: fix event recording test.

* Update FakeCredentials

* Fix tests

* fix lint issues

* fix: aggregate streaming messages into one event.

* fix: remove gen_ai.system from latest sem_conv

* refactor: import encoder from utils-genai

* build: update deps versions.

* refactor: deduplicate creating attributes, use gen_ai_json_dumps

* refactor: move blobpart and filedatapart to instrumentation-google-genai package.

* test: add comment for headers.

* test: fix span attributes formatting.

* fix: lint

* fix: use LogRecord instead of Event.

* docs: update changelog

* build: update uv.lock

* test: disable lint

* build: unpin opentelemetry-util-genai version

* test: add e2e completion_hook test

---------

Co-authored-by: Aaron Abbott <aaronabbott@google.com>
Co-authored-by: Dylan Russell <dylanrus@gmail.com>
Co-authored-by: DylanRussell <DylanRussell@users.noreply.github.com>
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.

7 participants