Skip to content

fix(otel): fall back user.id onto span extras when EVENT_ONLY key is missing#6362

Open
DmitriiK wants to merge 1 commit into
google:mainfrom
DmitriiK:fix/user-id-event-only-fallback
Open

fix(otel): fall back user.id onto span extras when EVENT_ONLY key is missing#6362
DmitriiK wants to merge 1 commit into
google:mainfrom
DmitriiK:fix/user-id-event-only-fallback

Conversation

@DmitriiK

Copy link
Copy Markdown

Summary

Context

opentelemetry-instrumentation-google-genai through 1.0b0 only exports the span extras key. ADK’s except (ImportError, AttributeError): pass meant session.user_id never reached Cloud Trace / GenAI spans on the instrumentor path (Vertex Agent Engine).

Trade-off: user.id lands on generate_content spans when the event-only channel is unavailable (slightly broader than “log-only”), which is preferable to dropping identity entirely until instrumentation ships the EVENT_ONLY key (opentelemetry-python-genai#24).

Test plan

  • With instrumentor active and EVENT_ONLY constant absent, generate_content spans include user.id from session.user_id
  • With a mock that provides EVENT_ONLY key, behavior unchanged (attrs go to event-only channel)
  • Manual: Agent Engine / local run + Trace Explorer filter user.id=<value> on generate_content spans

Made with Cursor

…missing

opentelemetry-instrumentation-google-genai (through 1.0b0) does not export
GENERATE_CONTENT_EVENT_ONLY_EXTRA_ATTRIBUTES_CONTEXT_KEY, so ADK silently
dropped session user.id. Merge log-only attributes into the existing span
extras context key as a fallback.

Fixes google#6361
@google-cla

google-cla Bot commented Jul 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@rohityan rohityan self-assigned this Jul 10, 2026
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Jul 10, 2026
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @DmitriiK , Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you!

@rohityan rohityan added eval [Component] This issue is related to evaluation tracing [Component] This issue is related to OpenTelemetry tracing and removed eval [Component] This issue is related to evaluation labels Jul 10, 2026
@DmitriiK

Copy link
Copy Markdown
Author

@rohityan
submitted.
thanks

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

Labels

request clarification [Status] The maintainer need clarification or more information from the author tracing [Component] This issue is related to OpenTelemetry tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

user.id silently dropped when GENERATE_CONTENT_EVENT_ONLY_EXTRA_ATTRIBUTES_CONTEXT_KEY is missing

2 participants