[opentelemetry-util-genai] Deprecate should_emit_event, use private _should_emit_event, and support dataclass serialization - #746
Merged
lmolkova merged 2 commits intoSep 20, 2026
Conversation
Pull request dashboard statusMerged · refreshed 2026-09-20 05:25 UTC Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused changes preserve existing precedence behavior and include appropriate regression tests.
Review effort: Lite
Findings: None
What changed in this PR
Adds explicit content-capturing mode support to event emission and enables JSON serialization of dataclass message parts in the shared GenAI utility package.
Changes:
- Adds
content_capturing_modetoshould_emit_event(). - Serializes dataclass instances through
_GenAiJsonEncoder. - Adds unit tests for both behaviors.
| File | Description |
|---|---|
util/opentelemetry-util-genai/src/opentelemetry/util/genai/utils.py |
Implements explicit mode handling and dataclass serialization. |
util/opentelemetry-util-genai/tests/test_utils.py |
Tests explicit event modes and dataclass JSON output. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
lmolkova
force-pushed
the
refactor/utils-event-mode-and-json-dataclass
branch
from
September 19, 2026 07:36
daaffa8 to
762f233
Compare
…should_emit_event, and support dataclass serialization
lmolkova
force-pushed
the
refactor/utils-event-mode-and-json-dataclass
branch
from
September 19, 2026 07:47
762f233 to
92c55ed
Compare
eternalcuriouslearner
approved these changes
Sep 19, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change do?
Deprecates
should_emit_event()in docstring and replaces internal usages with_should_emit_event(content_capturing_mode: ContentCapturingMode). Also adds dataclass serialization support to_GenAiJsonEncoder.Why?
Avoids
os.environlookups on the hot path during_finish()and keeps event emission decisions internal toutil-genaiwhile preserving backward compatibility. This helps prepare for codegen (#702).