Repository navigation
[google-genai, util-genai] Decouple event emission and set event severity to DEBUG (#619) - #836
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The fallback can mishandle internal TypeErrors, and new tests depend on ambient environment state.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Decouples GenAI event emission from Google GenAI instrumentation configuration and adds DEBUG severity/filtering support.
Changes:
- Removes global event-enabling environment mutation.
- Checks logger enablement before constructing events.
- Adds severity, filtering, and configuration-preservation tests.
| File | Description |
|---|---|
_inference_invocation.py |
Adds DEBUG severity and logger filtering. |
test_utils_events.py |
Tests severity and logger enablement. |
generate_content.py |
Removes environment mutation. |
test_instrumentor.py |
Verifies environment preservation. |
nonstreaming_base.py |
Explicitly enables an expected test event. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Pull request dashboard statusMerged · refreshed 2026-10-29 06:08 UTC Status above doesn't look right?
|
|
Pushed commit 6f39257 with the remaining CI fixes:
All local pre-commit checks and unit tests pass cleanly. /dashboard route:reviewers |
b0ef28b to
7430c80
Compare
|
Rebased cleanly onto latest /dashboard route:reviewers |
|
Thanks @DylanRussell and @lmolkova — pushed commit
|
|
/dashboard route:reviewers |
|
@somuai, this pull request was routed to reviewers. The handoff remains active across pushes until newer actionable human feedback arrives. Top-level feedback through this request will not return; unresolved review threads remain open. |
…rity to DEBUG (open-telemetry#619) Signed-off-by: Soumyajit Ghosh <[email protected]>
…across workspace Signed-off-by: Soumyajit Ghosh <[email protected]>
…ign test deps with otel 1.45 Signed-off-by: Soumyajit Ghosh <[email protected]>
…uring mode Signed-off-by: Soumyajit Ghosh <[email protected]>
3f33f35 to
f978023
Compare
…test_e2e Signed-off-by: Soumyajit Ghosh <[email protected]>
|
Thanks @DylanRussell and @lmolkova — addressed all review feedback in commit
All 8 tests in |
lmolkova
left a comment
There was a problem hiding this comment.
a couple more nits and we should be good to go
…e and bump qwenpaw api Signed-off-by: Soumyajit Ghosh <[email protected]>
|
Thanks @lmolkova — addressed both nits in commit
All 8 tests in |
Signed-off-by: Soumyajit Ghosh <[email protected]>
|
/dashboard route:reviewers |
|
@somuai, your reviewer-routing request was recorded; this pull request has the approvals it needs and is now waiting on maintainers. The handoff remains active across pushes until newer actionable human feedback arrives. Top-level feedback through this request will not return; unresolved review threads remain open. |
lmolkova
left a comment
There was a problem hiding this comment.
LGTM with a few cosmetic suggestions. Thanks!
Signed-off-by: Soumyajit Ghosh <[email protected]>
Signed-off-by: Soumyajit Ghosh <[email protected]>
This comment has been minimized.
This comment has been minimized.
# Conflicts: # tox.ini # util/opentelemetry-util-genai/src/opentelemetry/util/genai/_inference_invocation.py # uv.lock
…mance pins to 1.45.1

Which problem is this PR solving?
Fixes #619
This PR implements the long-term decoupled GenAI event emission architecture requested by @DylanRussell:
opentelemetry-util-genai:
InferenceInvocation._maybe_create_event()to check if the event is disabled viaself._logger.enabled(context=self._span_context, severity_number=SeverityNumber.DEBUG, event_name=event_name)(with graceful fallback for custom loggers whoseenabled()does not acceptseverity_number). If disabled, log record creation and emission are skipped.LogRecord'sseverity_numbertoSeverityNumber.DEBUGper GenAI semantic conventions.opentelemetry-instrumentation-google-genai:
os.environ["OTEL_INSTRUMENTATION_GENAI_EMIT_EVENT"] = "true"ininstrument_generate_content(), eliminating global process environment mutation and preserving explicit user configuration andOTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENTdefaults.Tests:
opentelemetry-util-genaiverifying event DEBUG severity, suppression whenlogger.enabledreturnsFalse, emission whenlogger.enabledreturnsTrue, and signature backwards compatibility.opentelemetry-instrumentation-google-genaiverifying thatinstrument()does not mutate or overwriteOTEL_INSTRUMENTATION_GENAI_EMIT_EVENT.Type of change
How Has This Been Tested?
pytest util/opentelemetry-util-genai/tests/test_utils_events.py(15/15 passed)pytest instrumentation/opentelemetry-instrumentation-google-genai/tests/test_instrumentor.py(3/3 passed)pytest instrumentation/opentelemetry-instrumentation-google-genai/tests/generate_content/(124 passed)pytest instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/(344 passed)