Skip to content

Restrict span annotations to methods - #20787

Open
trask with Copilot wants to merge 5 commits into
mainfrom
copilot/annotation-splitting-pr-20775
Open

trask with Copilot wants to merge 5 commits into
mainfrom
copilot/annotation-splitting-pr-20775

Conversation

Copilot AI commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Annotation-only replacement for #20775, independent of its messaging changes. Completes the 3.0 source-contract cleanup: @WithSpan and @AddingSpanAttributes target methods only; method instrumentation is unchanged.

Remove either annotation from constructors:

// Before
@WithSpan
Example() {}

// After
Example() {}

// Method annotations remain supported
@WithSpan
void work() {}
  • API: Restrict both targets to ElementType.METHOD and update Javadoc.
  • Tests: Replace constructor fixtures and tests with method-only target assertions; preserve method-instrumentation coverage.
  • Migration: Add the annotation breaking-change entry under stable breaking changes.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-10-21 02:45 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Co-authored-by: trask <218610+trask@users.noreply.github.com>
Copilot AI changed the title [WIP] Add annotation implementation from PR #20775 Restrict span annotations to methods Oct 20, 2026
Copilot AI requested a review from trask October 20, 2026 21:34
@trask
trask requested a balanced review from Copilot October 20, 2026 21:36

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.

🟢 Approval recommended

The focused annotation-contract change preserves method coverage and has no blocking findings.

1 open issue
What changed in this PR

Restricts the span annotations to methods for the 3.0 API cleanup, without changing method instrumentation.

Changes:

  • Updates annotation targets and Javadoc.
  • Replaces constructor tests and fixtures with method-only target assertions.
  • Documents the source-breaking change.
File Description
instrumentation/​opentelemetry-instrumentation-annotations-1.16/​javaagent/​src/​test/​java/​io/​opentelemetry/​test/​annotation/​WithSpanInstrumentationTest.java Asserts method-only targeting.
instrumentation/​opentelemetry-instrumentation-annotations-1.16/​javaagent/​src/​test/​java/​io/​opentelemetry/​test/​annotation/​TracedWithSpan.java Removes annotated constructor fixture.
instrumentation/​opentelemetry-instrumentation-annotations-1.16/​javaagent/​src/​test/​java/​io/​opentelemetry/​test/​annotation/​ConstructorOnlyAddingSpanAttributes.java Deletes constructor-only fixture.
instrumentation/​opentelemetry-instrumentation-annotations-1.16/​javaagent/​src/​test/​java/​io/​opentelemetry/​test/​annotation/​ConstructedWithAddingSpanAttributes.java Deletes mixed constructor/method fixture.
instrumentation/​opentelemetry-instrumentation-annotations-1.16/​javaagent/​src/​test/​java/​io/​opentelemetry/​test/​annotation/​AddingSpanAttributesInstrumentationTest.java Replaces constructor tests with target assertion.
instrumentation-annotations/​src/​main/​java/​io/​opentelemetry/​instrumentation/​annotations/​WithSpan.java Restricts target and updates Javadoc.
instrumentation-annotations/​src/​main/​java/​io/​opentelemetry/​instrumentation/​annotations/​AddingSpanAttributes.java Restricts target and updates Javadoc.
CHANGELOG.md Records the annotation API breaking change.

Review effort: Balanced

Comment thread CHANGELOG.md Outdated
Clarify breaking changes in opentelemetry-instrumentation-annotations.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread CHANGELOG.md Outdated
@trask
trask marked this pull request as ready for review October 20, 2026 21:54
@trask
trask requested a review from a team as a code owner October 20, 2026 21:54

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.

🟢 Approval recommended

The focused, intentional 3.0 contract change preserves method instrumentation and coverage, with no unresolved findings.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Record the method-only annotation targets in the generated API comparison so the build's committed-report check stays current.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟢 Approval recommended

The focused, documented 3.0 source-contract change leaves method instrumentation unchanged and has no unresolved findings.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants