Skip to content

Fix #16109: support Micrometer 1.13+ Prometheus package in MetricsSupportUtil#16205

Closed
barry3406 wants to merge 1 commit intoapache:3.3from
barry3406:fix/metrics-support-util-prometheus-classes
Closed

Fix #16109: support Micrometer 1.13+ Prometheus package in MetricsSupportUtil#16205
barry3406 wants to merge 1 commit intoapache:3.3from
barry3406:fix/metrics-support-util-prometheus-classes

Conversation

@barry3406
Copy link
Copy Markdown

What is the purpose of the change?

Fixes #16109. MetricsSupportUtil.isSupportPrometheus() currently only looks for io.micrometer.prometheus.PrometheusConfig, which was renamed to io.micrometer.prometheusmetrics.PrometheusConfig in Micrometer 1.13 (Spring Boot 3.3+), and also hard-requires the legacy io.prometheus.client.exporter.* classes that are no longer pulled in by dubbo-observability-spring-boot-starter in Dubbo 3.3.x. The net effect is that Prometheus reporter initialization is silently skipped for recent Spring Boot users, exactly matching the reproducer in the issue.

This change updates the check to accept either the legacy io.micrometer.prometheus package or the new io.micrometer.prometheusmetrics package, and drops the legacy io.prometheus.client.* requirements. Those are only needed in Pushgateway mode, and PrometheusMetricsReporterFactory already handles their absence via NoClassDefFoundError, so the extra isClassPresent hop here was just producing false negatives for scrape-only deployments.

Per @RainYuY's note on the issue that a compatible path is what's needed, this keeps the fix minimal and strictly scoped to the detection util so older Spring Boot 3.2.x / Micrometer < 1.13 users keep working.

Checklist

  • Make sure there is a GitHub_issue field for the change. (Fixes [Bug] Prometheus metrics reporter initialization fails due to outdated class checks in MetricsSupportUtil #16109)
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. MetricsSupportUtilTest covers the four classpath layouts (legacy only, new only, both, neither) by stubbing ClassUtils with mockito-inline, so detection is exercised regardless of which Micrometer Prometheus registry happens to be on the test runtime classpath.
  • Make sure gitHub actions can pass. Locally ran mvn -pl dubbo-metrics/dubbo-metrics-api -am -Psources,skip-spotless,checkstyle clean install -Dmaven.test.skip=true, mvn -pl dubbo-metrics/dubbo-metrics-api -Pjacoco,skip-spotless test verify, mvn -pl dubbo-metrics/dubbo-metrics-prometheus -Pjacoco,skip-spotless test verify, plus mvn -pl dubbo-config/dubbo-config-api -Dtest=DefaultApplicationDeployerTest test and mvn spotless:check on JDK 21 — all green.

…icsSupportUtil

Update isSupportPrometheus() to recognize both the legacy
io.micrometer.prometheus.PrometheusConfig and the new
io.micrometer.prometheusmetrics.PrometheusConfig introduced in
Micrometer 1.13 (Spring Boot 3.3+). Drop the hard requirement on the
io.prometheus.client.exporter.* classes: they are only exercised in
Pushgateway mode and PrometheusMetricsReporterFactory already guards
against their absence via NoClassDefFoundError handling, so requiring
them here produced false negatives for scrape-only deployments that
ship with dubbo-observability-spring-boot-starter in Dubbo 3.3.x.

Add a MetricsSupportUtilTest that exercises each classpath layout
(legacy only, new only, both, neither) by stubbing ClassUtils so the
detection is verified regardless of which Prometheus registry is on
the test runtime classpath.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.79%. Comparing base (8814afa) to head (e1b89bd).

Additional details and impacted files
@@            Coverage Diff            @@
##                3.3   #16205   +/-   ##
=========================================
  Coverage     60.79%   60.79%           
- Complexity    11751    11756    +5     
=========================================
  Files          1953     1953           
  Lines         89119    89116    -3     
  Branches      13444    13441    -3     
=========================================
  Hits          54177    54177           
- Misses        29368    29376    +8     
+ Partials       5574     5563   -11     
Flag Coverage Δ
integration-tests-java21 32.16% <0.00%> (+0.03%) ⬆️
integration-tests-java8 32.22% <0.00%> (+0.05%) ⬆️
samples-tests-java21 32.17% <0.00%> (+<0.01%) ⬆️
samples-tests-java8 29.72% <0.00%> (-0.11%) ⬇️
unit-tests-java11 59.04% <100.00%> (+0.02%) ⬆️
unit-tests-java17 58.53% <100.00%> (-0.02%) ⬇️
unit-tests-java21 58.51% <100.00%> (-0.02%) ⬇️
unit-tests-java25 58.46% <100.00%> (-0.01%) ⬇️
unit-tests-java8 59.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@barry3406
Copy link
Copy Markdown
Author

Closing this — sorry, I didn't notice that #16110, #16128, and #16132 (from the original reporter @SavitarC) were already open for the same issue. The minimal-fix approach is already covered by #16110, and shouldn't have added a fourth competing PR. The unit tests might be a useful follow-up to whichever of those ends up being merged.

@barry3406 barry3406 closed this Apr 11, 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.

[Bug] Prometheus metrics reporter initialization fails due to outdated class checks in MetricsSupportUtil

2 participants