Skip to content

Minor utils cleanup: remove start and get_start_attributes methods, inline the code inside __init__ - #741

Merged
lmolkova merged 4 commits into
open-telemetry:mainfrom
DylanRussell:move_start_into_init
Sep 21, 2026
Merged

lmolkova merged 4 commits into
open-telemetry:mainfrom
DylanRussell:move_start_into_init

Conversation

@DylanRussell

Copy link
Copy Markdown
Contributor

Description

Remove the _start method from GenAIInvocation and _get_start_attributes from its subclasses, inlining span initialization into __init__. Make start_attributes a required public attribute on the base class initialized via super().__init__.

Just simplifies the code a bit.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

Unit tests

Checklist

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 18, 2026

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-09-21 14:35 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 _start and _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

  • AgentInvocation is also re-exported publicly, and this new required keyword breaks custom AgentInvocation subclasses 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.

Comment thread util/opentelemetry-util-genai/src/opentelemetry/util/genai/_invocation.py Outdated

@lmolkova lmolkova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice cleanup!! A few suggestions

Comment thread util/opentelemetry-util-genai/src/opentelemetry/util/genai/_invocation.py Outdated
Comment thread util/opentelemetry-util-genai/.changelog/741.changed Outdated
@lmolkova
lmolkova enabled auto-merge September 21, 2026 14:20
@lmolkova
lmolkova added this pull request to the merge queue Sep 21, 2026
Merged via the queue into open-telemetry:main with commit dc53f7a Sep 21, 2026
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants