fix(otel): fall back user.id onto span extras when EVENT_ONLY key is missing - #6362
fix(otel): fall back user.id onto span extras when EVENT_ONLY key is missing#6362DmitriiK wants to merge 1 commit into
Conversation
…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
|
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. |
|
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 |
|
Hi @DmitriiK, Thank you for your contribution, Could you please share what's your use-case for Some trace backends don't play nice with PII, hence the preference for storing it in logs only, but admittedly it's not the cleanest solution. |
Summary
GENERATE_CONTENT_EVENT_ONLY_EXTRA_ATTRIBUTES_CONTEXT_KEYcannot be imported fromopentelemetry-instrumentation-google-genai, mergelog_only_extra_attributes(includinguser.id) intoGENERATE_CONTENT_EXTRA_ATTRIBUTES_CONTEXT_KEYinstead of silently dropping them.Context
opentelemetry-instrumentation-google-genaithrough 1.0b0 only exports the span extras key. ADK’sexcept (ImportError, AttributeError): passmeantsession.user_idnever reached Cloud Trace / GenAI spans on the instrumentor path (Vertex Agent Engine).Trade-off:
user.idlands ongenerate_contentspans 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
generate_contentspans includeuser.idfromsession.user_iduser.id=<value>ongenerate_contentspansMade with Cursor