Skip to content

Set instrumentation version on emitted Meter scopes#18866

Draft
trask wants to merge 1 commit into
open-telemetry:mainfrom
trask:fix-emitted-scope-version
Draft

Set instrumentation version on emitted Meter scopes#18866
trask wants to merge 1 commit into
open-telemetry:mainfrom
trask:fix-emitted-scope-version

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented May 28, 2026

Background

TelemetryDataUtil.assertScopeVersion only walked SpanData, so metric-only modules whose emitted scope name did not match the gradle module name slipped through CI. This is what allowed the recent tomcat-jdbc-8.5 and oshi-5.0 module 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

  • Broaden assertScopeVersion to also walk MetricData (gated by the existing startsWith("test") carve-out) and hook it into InstrumentationTestRunner.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; 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.get().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.

Does not include the docs allow-list overrides from #18860 \u2014 once this lands the tomcat-jdbc-8.5 entry can be dropped.

@trask trask force-pushed the fix-emitted-scope-version branch 4 times, most recently from 9f285bb to c0fb2aa Compare May 28, 2026 22:24
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.
@trask trask force-pushed the fix-emitted-scope-version branch from c0fb2aa to 1096454 Compare May 28, 2026 23:08
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.

1 participant