Set instrumentation version on emitted Meter scopes#18866
Merged
Conversation
92e3c2c to
4233cd9
Compare
Test runner TelemetryDataUtil.assertScopeVersion only walked SpanData, so metric-only modules whose emitted scope name does not match the gradle module name slipped through CI. Broaden the assertion to also walk MetricData (gated by the existing startsWith("test") carve-out) and hook it into InstrumentationTestRunner.waitAndAssertMetrics(...) so the same protection covers meters.
Fix the in-tree metric-only sites that the broadened assertion catches:
* failsafe-3.0, dropwizard-metrics-4.0, iceberg-1.8, micrometer-1.5: scope already matches module name; switch getMeter(...) to meterBuilder(...) with EmbeddedInstrumentationProperties version lookup so the version actually flows through.
* oshi-5.0: scope was a pre-rename literal. The library module is alpha so flip its emitted scope directly to the module-name-aligned io.opentelemetry.oshi-5.0 (the existing version-properties lookup just works once the names match). The javaagent is stable so apply the CxfSingletons pattern: emit the legacy io.opentelemetry.oshi scope by default to preserve dashboards/filters, switch to the new scope under AgentCommonConfig.isV3Preview(). Add SystemMetrics/ProcessMetrics.registerObservers(Meter) overloads so the javaagent can inject a meter with the legacy scope while reusing the library observer-registration code.
* tomcat-jdbc-8.5: javaagent-only, no library. Apply the CxfSingletons pattern: legacy io.opentelemetry.tomcat-jdbc scope by default, new io.opentelemetry.tomcat-jdbc-8.5 under v3-preview, always look up version under the new module name. Add a DbConnectionPoolMetrics.create(Meter, String) overload so tomcat-jdbc can build its own meter and inject it.
* jmx-metrics: pre-existing scope mismatch (emits io.opentelemetry.jmx, module is jmx-metrics). Add a versionLookupName parameter to MetricRegistrar and pass io.opentelemetry.jmx-metrics from JmxMetricInsight so the emitted scope finally has a version.
4233cd9 to
905f9f4
Compare
Member
|
@trask should this still be in draft or is it ready for review? |
laurit
approved these changes
Jun 1, 2026
jaydeluca
approved these changes
Jun 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR ensures metric instrumentation scopes carry an instrumentation version (like spans already do), tightening CI checks so metric-only modules can’t silently emit unversioned/incorrect scope metadata after module renames.
Changes:
- Extend scope-version assertions to include
MetricDataand invoke the check fromInstrumentationTestRunner.waitAndAssertMetrics(...). - Update multiple instrumentations to build meters via
meterBuilder(...).setInstrumentationVersion(...)(usingEmbeddedInstrumentationProperties) so scope versions flow into emitted metrics. - Preserve legacy scope names for renamed javaagent instrumentations (e.g., OSHI and tomcat-jdbc) by default while switching to new scope names under
v3-preview, enabled by new/overloaded meter-based registration APIs.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/util/TelemetryDataUtil.java | Adds metric scope-version verification and shares span/metric checking logic. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/InstrumentationTestRunner.java | Hooks metric scope-version verification into metric test assertions. |
| smoke-tests-otel-starter/spring-boot-common/src/main/java/io/opentelemetry/spring/smoketest/OtelSpringStarterSmokeTestController.java | Uses a test* meter scope name to stay exempt from scope-version enforcement. |
| instrumentation/tomcat/tomcat-jdbc-8.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/jdbc/v8_5/TomcatConnectionPoolMetrics.java | Builds a versioned meter while preserving legacy scope name unless v3-preview is enabled. |
| instrumentation/runtime-telemetry/library/src/main/java/io/opentelemetry/instrumentation/runtimetelemetry/RuntimeTelemetryBuilder.java | Looks up meter version under the current module name even when emitting legacy scope names. |
| instrumentation/oshi-5.0/testing/src/main/java/io/opentelemetry/instrumentation/oshi/v5_0/AbstractSystemMetricsTest.java | Introduces a deprecated scopeName() bridge so library and javaagent tests can assert different scope names. |
| instrumentation/oshi-5.0/testing/src/main/java/io/opentelemetry/instrumentation/oshi/v5_0/AbstractProcessMetricsTest.java | Same scopeName() bridge for process metrics tests (and deprecation plumbing). |
| instrumentation/oshi-5.0/library/src/test/java/io/opentelemetry/instrumentation/oshi/v5_0/SystemMetricsTest.java | Pins library tests to the renamed io.opentelemetry.oshi-5.0 scope. |
| instrumentation/oshi-5.0/library/src/test/java/io/opentelemetry/instrumentation/oshi/v5_0/ProcessMetricsTest.java | Pins library tests to the renamed io.opentelemetry.oshi-5.0 scope. |
| instrumentation/oshi-5.0/library/src/main/java/io/opentelemetry/instrumentation/oshi/v5_0/SystemMetrics.java | Builds a versioned meter and adds a deprecated Meter overload for javaagent legacy-scope injection. |
| instrumentation/oshi-5.0/library/src/main/java/io/opentelemetry/instrumentation/oshi/v5_0/ProcessMetrics.java | Same as SystemMetrics for process metrics observers. |
| instrumentation/oshi-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/oshi/v5_0/SystemMetricsTest.java | Pins javaagent tests to the legacy io.opentelemetry.oshi scope. |
| instrumentation/oshi-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/oshi/v5_0/ProcessMetricsTest.java | Pins javaagent tests to the legacy io.opentelemetry.oshi scope. |
| instrumentation/oshi-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/oshi/v5_0/MetricsRegistration.java | Builds a versioned meter while switching scope name based on v3-preview, reusing library registration via meter overloads. |
| instrumentation/micrometer/micrometer-1.5/library/src/main/java/io/opentelemetry/instrumentation/micrometer/v1_5/OpenTelemetryMeterRegistryBuilder.java | Constructs a versioned meter for the Micrometer bridge registry. |
| instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/internal/engine/MetricRegistrar.java | Accepts a versionLookupName and builds a versioned meter for a possibly-legacy scope name. |
| instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/internal/engine/JmxMetricInsight.java | Supplies the module-aligned version lookup name for JMX metrics while keeping the legacy scope name. |
| instrumentation/iceberg-1.8/library/src/main/java/io/opentelemetry/instrumentation/iceberg/v1_8/IcebergMetricsReporter.java | Switches to a versioned meter construction. |
| instrumentation/failsafe-3.0/library/src/main/java/io/opentelemetry/instrumentation/failsafe/v3_0/FailsafeTelemetry.java | Uses a versioned meter for emitted metrics. |
| instrumentation/dropwizard/dropwizard-metrics-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/dropwizardmetrics/v4_0/DropwizardMetricsAdapter.java | Uses a versioned meter for Dropwizard metric bridging. |
| instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbConnectionPoolMetrics.java | Adds a deprecated create(Meter, String) overload to support legacy-scope javaagent meters while reusing the same metric definitions. |
| * @deprecated Exists only so the javaagent test can pin the pre-rename {@code | ||
| * io.opentelemetry.oshi} scope; to be removed in 3.0 once v3-preview becomes the default. | ||
| */ | ||
| @Deprecated // to be remove |
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.
Background
TelemetryDataUtil.assertScopeVersiononly walkedSpanData, so metric-only modules whose emitted scope name did not match the gradle module name slipped through CI. This is what allowed the recenttomcat-jdbc-8.5andoshi-5.0module renames (#18838, #18854) to ship while still emitting the pre-rename scope names \u2014 the docs telemetry parser noticed in #18860, but the agent's own test runner did not.Changes
assertScopeVersionto also walkMetricData(gated by the existingstartsWith("test")carve-out) and hook it intoInstrumentationTestRunner.waitAndAssertMetrics(...)so the same protection covers meters.failsafe-3.0,dropwizard-metrics-4.0,iceberg-1.8,micrometer-1.5: scope already matches the module name; switchgetMeter(...)tometerBuilder(...)withEmbeddedInstrumentationPropertiesversion lookup so the version actually flows through.oshi-5.0: scope was a pre-rename literal. The library module is alpha so flip its emitted scope directly to the module-name-alignedio.opentelemetry.oshi-5.0(the existing version-properties lookup just works once the names match). The javaagent is stable so apply theCxfSingletonspattern: emit the legacyio.opentelemetry.oshiscope by default to preserve dashboards/filters, switch to the new scope underAgentCommonConfig.get().isV3Preview(). AddSystemMetrics/ProcessMetrics.registerObservers(Meter)overloads so the javaagent can inject a meter with the legacy scope while reusing the library observer-registration code.tomcat-jdbc-8.5: javaagent-only, no library. Apply the CxfSingletons pattern: legacyio.opentelemetry.tomcat-jdbcscope by default, newio.opentelemetry.tomcat-jdbc-8.5under v3-preview, always look up version under the new module name. Add aDbConnectionPoolMetrics.create(Meter, String)overload so tomcat-jdbc can build its own meter and inject it.jmx-metrics: pre-existing scope mismatch (emitsio.opentelemetry.jmx, module isjmx-metrics). Add aversionLookupNameparameter toMetricRegistrarand passio.opentelemetry.jmx-metricsfromJmxMetricInsightso the emitted scope finally has a version.Does not include the docs allow-list overrides from #18860 \u2014 once this lands the
tomcat-jdbc-8.5entry can be dropped.