Skip to content

Run @WithSpan instrumetnation after other instrumentations#18874

Merged
laurit merged 1 commit into
open-telemetry:mainfrom
laurit:withspan-order
Jun 3, 2026
Merged

Run @WithSpan instrumetnation after other instrumentations#18874
laurit merged 1 commit into
open-telemetry:mainfrom
laurit:withspan-order

Conversation

@laurit

@laurit laurit commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Run @WithSpan and other similar instrumetnation after other instrumentations. Based on the comments this seems to be the intended behavior. Running after other instrumentations allows for example adding attributes to the spans created by some other instrumentation.

@laurit
laurit requested a review from a team as a code owner June 1, 2026 13:02
Copilot AI review requested due to automatic review settings June 1, 2026 13:02

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.

Pull request overview

This PR changes the javaagent ordering of annotation-based instrumentation modules so they run after other instrumentations, enabling them to observe and enrich spans that were started earlier by “automatic” instrumentations.

Changes:

  • Updated the OpenTelemetry instrumentation-annotations module ordering from early to late execution.
  • Added explicit late ordering for the OpenTelemetry extension-annotations and external-annotations modules.
  • Updated the kotlinx-coroutines annotation instrumentation module ordering to run late as well.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/v1_16/AnnotationInstrumentationModule.java Changes module order to run after other instrumentations.
instrumentation/opentelemetry-extension-annotations-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/extensionannotations/v1_0/WithSpanInstrumentationModule.java Adds module order override to run after other instrumentations.
instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/v1_0/instrumentationannotations/AnnotationInstrumentationModule.java Changes module order to run after other instrumentations.
instrumentation/external-annotations/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/external/annotations/ExternalAnnotationInstrumentationModule.java Adds module order override to run after other instrumentations.

@laurit
laurit merged commit 46466e2 into open-telemetry:main Jun 3, 2026
182 of 184 checks passed
@laurit
laurit deleted the withspan-order branch June 3, 2026 06:22
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.

4 participants