Minor utils cleanup: remove start and get_start_attributes methods, inline the code inside __init__ - #741
Merged
Conversation
Pull request dashboard statusMerged · refreshed 2026-09-21 14:35 UTC Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Required constructor arguments break existing public callers and subclasses.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Refactors GenAI invocation initialization by inlining span and start-attribute setup into constructors.
Changes:
- Removes
_startand_get_start_attributes. - Exposes initialized
start_attributes. - Updates invocation types and tests.
File summaries
| File | Summary |
|---|---|
util/opentelemetry-util-genai/tests/test_utils.py |
Tests start-attribute initialization. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_workflow_invocation.py |
Updates workflow initialization. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_tool_invocation.py |
Updates tool attributes and context handling. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_retrieval_invocation.py |
Updates retrieval initialization. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_invocation.py |
Initializes spans and attributes in the base class. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_inference_invocation.py |
Inlines inference attributes and reuses them. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_fetch_response_invocation.py |
Updates fetch-response initialization. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_embedding_invocation.py |
Updates embedding initialization. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_agent_invocation.py |
Updates agent initialization. |
Review details
Suppressed comments (1)
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_agent_invocation.py:60
AgentInvocationis also re-exported publicly, and this new required keyword breaks customAgentInvocationsubclasses that previously called this constructor with the existing arguments. Keep the new data flow internal or provide a backward-compatible default/derivation before making it required.
span_kind: SpanKind,
start_attributes: dict[str, AttributeValue],
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
lmolkova
reviewed
Sep 19, 2026
lmolkova
left a comment
Member
There was a problem hiding this comment.
nice cleanup!! A few suggestions
lmolkova
approved these changes
Sep 21, 2026
lmolkova
enabled auto-merge
September 21, 2026 14:20
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.
Description
Remove the
_startmethod fromGenAIInvocationand_get_start_attributesfrom its subclasses, inlining span initialization into__init__. Makestart_attributesa required public attribute on the base class initialized viasuper().__init__.Just simplifies the code a bit.
Type of change
Please delete options that are not relevant.
How has this been tested?
Unit tests
Checklist