Skip to content

Enable opentelemetry-api and opentelemetry-instrumentation-annotations even when default-enabled is false#18792

Merged
trask merged 1 commit into
open-telemetry:mainfrom
trask:default-instrumentation
May 19, 2026
Merged

Enable opentelemetry-api and opentelemetry-instrumentation-annotations even when default-enabled is false#18792
trask merged 1 commit into
open-telemetry:mainfrom
trask:default-instrumentation

Conversation

@trask

@trask trask commented May 18, 2026

Copy link
Copy Markdown
Member

Resolves #7201

@trask trask changed the title Enable API instrumentations under v3 preview Enable opentelemetry-api and opentelemetry-instrumentation-annotations even when default-enabled is false May 18, 2026
@trask
trask force-pushed the default-instrumentation branch 2 times, most recently from 67233a6 to 9bd7dcb Compare May 19, 2026 00:13
@trask
trask force-pushed the default-instrumentation branch 2 times, most recently from 222ea7d to 051868e Compare May 19, 2026 02:55
@trask
trask marked this pull request as ready for review May 19, 2026 02:56
@trask
trask requested a review from a team as a code owner May 19, 2026 02:57
Copilot AI review requested due to automatic review settings May 19, 2026 02:57

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 introduces a new internal helper, V3PreviewFallbackEnabledInstrumentationModule, that overrides defaultEnabled() to return true when the v3 preview flag (otel.instrumentation.common.v3-preview / declarative instrumentation.common.v3_preview) is enabled, in addition to the normal default-enabled check. The base class is then applied to every javaagent opentelemetry-api-* instrumentation module and to the opentelemetry-instrumentation-annotations-1.16 module, so that once a user opts into v3 preview these modules remain on even if otel.instrumentation.common.default-enabled=false. The helper is annotated @Deprecated for removal in 3.0.0, anticipating that the v3 behavior becomes the default.

Changes:

  • Add V3PreviewFallbackEnabledInstrumentationModule base class (overrides both defaultEnabled() and the deprecated defaultEnabled(ConfigProperties)).
  • Re-parent all OpenTelemetryApi*InstrumentationModule classes and AnnotationInstrumentationModule to the new base, with @SuppressWarnings("deprecation").
  • Add tests: distribution-config YAML enables v3_preview: true, a new test asserts AgentCommonConfig.isV3Preview(), and InstrumentationModuleInstallerTest covers the fallback path via a mocked ConfigProperties.

Reviewed changes

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

Show a summary per file
File Description
javaagent-extension-api/.../V3PreviewFallbackEnabledInstrumentationModule.java New deprecated helper base class with v3-preview fallback for defaultEnabled.
javaagent-tooling/.../testDistributionConfig/.../AgentDistributionConfigTest.java New test asserting isV3Preview() reflects YAML config.
javaagent-tooling/.../testDistributionConfig/resources/distribution-config.yaml Adds v3_preview: true under instrumentation/development > java > common.
javaagent-tooling/.../InstrumentationModuleInstallerTest.java Adds unit test of defaultEnabled(config) fallback and a TestInstrumentationModule subclass.
instrumentation/opentelemetry-instrumentation-annotations-1.16/.../AnnotationInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.0/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.10/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.15/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.27/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.31/.../incubator/OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.32/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.32/.../incubator/OpenTelemetryApiIncubatorInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.37/.../incubator/OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.38/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.38/.../incubator/OpenTelemetryApiIncubatorInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.4/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.40/.../incubator/OpenTelemetryApiIncubatorInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.42/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.42/.../incubator/OpenTelemetryApiIncubatorInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.47/.../incubator/OpenTelemetryApiIncubatorInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.50/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.50/.../incubator/OpenTelemetryApiIncubatorInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.56/.../incubator/OpenTelemetryApiIncubatorInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.57/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.
instrumentation/opentelemetry-api/opentelemetry-api-1.59/.../OpenTelemetryApiInstrumentationModule.java Re-parented to v3-preview-fallback module.

@trask
trask force-pushed the default-instrumentation branch from 051868e to da3f715 Compare May 19, 2026 03:27
@trask
trask force-pushed the default-instrumentation branch from da3f715 to faea1fc Compare May 19, 2026 04:14
@trask
trask merged commit 2f320b9 into open-telemetry:main May 19, 2026
95 checks passed
@trask
trask deleted the default-instrumentation branch May 19, 2026 14:11
SylvainJuge pushed a commit to SylvainJuge/opentelemetry-java-instrumentation that referenced this pull request May 20, 2026
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.

Enable opentelemetry-api and opentelemetry-instrumentation-annotations even when default-enabled is false

3 participants