Skip to content

feat: add extension point to add custom attributes to generate_content spans in google genai instrumentor.#3961

Merged
aabmass merged 4 commits intoopen-telemetry:mainfrom
RKest:feature/extra-google-genai-attributes
Jan 14, 2026
Merged

feat: add extension point to add custom attributes to generate_content spans in google genai instrumentor.#3961
aabmass merged 4 commits intoopen-telemetry:mainfrom
RKest:feature/extra-google-genai-attributes

Conversation

@RKest
Copy link
Contributor

@RKest RKest commented Nov 20, 2025

Description

Introduces ability to add additional attributes to generate_content {model.name} spans to Google GenAI instrumentation.

Motivation behind this change is to add (non-semconv) gcp.vertex.agent.event_id attribute, to generate_content {model.name} spans, in order to correlate events with spans in google/adk-python.

Broader motivation is:

  • Currently in ADK we trace inference in both generate_content and legacy call_llm spans.
  • We want to migrate fully to generate_content spans and deprecate call_llm spans.
  • However call_llm spans contain gcp.vertex.agent.event_id attribute, and we still want to correlate events with spans.

Note: Event in ADK is not synonymous with event in OTEL. In ADK, Event == LLM Request/Response or Tool Call/Result, in OTEL IIUC Event == Log.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Tested using:

  • Automated unit tests.
  • Using opentelemetry-instrumentor-google-genai off my fork in ADK, and successfully adding custom attributes to target span
image

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • 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

@RKest RKest requested a review from a team as a code owner November 20, 2025 13:55
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 20, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: aabmass / name: Aaron Abbott (62136a6)

Copy link
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.

LGTM, it could probably be generalized more to other GenAI instrumentations if this proves useful. We can also use this to set the gen_ai.conversation.id from ADK 🙂

@aabmass
Copy link
Member

aabmass commented Dec 8, 2025

@RKest any blockers here?

@RKest RKest force-pushed the feature/extra-google-genai-attributes branch from d8cc094 to bbb8c9b Compare January 12, 2026 13:31
@RKest RKest force-pushed the feature/extra-google-genai-attributes branch from bbb8c9b to 2e18bc2 Compare January 12, 2026 13:38
@aabmass aabmass enabled auto-merge (squash) January 14, 2026 16:43
@aabmass aabmass merged commit 3a3981a into open-telemetry:main Jan 14, 2026
661 of 663 checks passed
aabmass added a commit to aabmass/opentelemetry-python-contrib that referenced this pull request Jan 14, 2026
I clicked auto merge and it went through before the checks passed. Presumably because the required checks are out of date.
aabmass added a commit that referenced this pull request Jan 14, 2026
I clicked auto merge and it went through before the checks passed. Presumably because the required checks are out of date.
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.

8 participants