Skip to content

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

@SavitarC

Description

@SavitarC

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

Dubbo 3.3.6
JDK 21
Spring Boot 3.5.10

Steps to reproduce this issue

demo

  1. Start the application.
  2. Run curl -s http://127.0.0.1:18180/metrics | grep '^dubbo_' | sort — no output is returned.
  3. Change dubbo.metrics.protocol in application.properties to default.
  4. Run curl -s http://127.0.0.1:18180/metrics | grep '^dubbo_' | sort — all metrics are displayed normally.
  5. Restore dubbo.metrics.protocol to prometheus, comment the dependency dubbo-observability-spring-boot-starter, uncomment the dependency dubbo-spring-boot-observability-starter, and redeploy the application.
  6. Run curl -s http://127.0.0.1:18180/metrics | grep '^dubbo_' | sort — all metrics are displayed normally.

What you expected to happen

The class compatibility checks in MetricsSupportUtil should be updated to align with Spring Boot 3.3.x and the latest Prometheus client dependencies.
The metrics reporter should initialize successfully without being blocked by outdated class path validations.

Anything else

In org.apache.dubbo.config.deploy.DefaultApplicationDeployer#initMetricsReporter, when the protocol is set to prometheus, it checks whether Prometheus is supported:

if (PROTOCOL_PROMETHEUS.equals(metricsConfig.getProtocol()) && !MetricsSupportUtil.isSupportPrometheus()) {
    return;
}

The validation logic is as follows:

public class MetricsSupportUtil {

    public static boolean isSupportMetrics() {
        return isClassPresent("io.micrometer.core.instrument.MeterRegistry");
    }

    public static boolean isSupportPrometheus() {
        return isClassPresent("io.micrometer.prometheus.PrometheusConfig")
                && isClassPresent("io.prometheus.client.exporter.BasicAuthHttpConnectionFactory")
                && isClassPresent("io.prometheus.client.exporter.HttpConnectionFactory")
                && isClassPresent("io.prometheus.client.exporter.PushGateway");
    }

    private static boolean isClassPresent(String className) {
        return ClassUtils.isPresent(className, MetricsSupportUtil.class.getClassLoader());
    }
}

There are several issues with this validation logic:

  • io.micrometer.prometheus.PrometheusConfig no longer exists from Spring Boot 3.3.x onwards; it has been replaced by io.micrometer.prometheusmetrics.PrometheusConfig.

  • The io.prometheus.client.* classes are not included when using the dubbo-observability-spring-boot-starter in Dubbo 3.3.x. The relevant dependencies are only included in the 3.2.x version of dubbo-spring-boot-observability-starter, and they belong to Prometheus Client 0.16.0, which is deprecated.

Either of these issues will cause the validation to fail, which skips the reporter initialization and results in no metrics being output. Consequently, the subsequent initialization of org.apache.dubbo.metrics.prometheus.PrometheusMetricsReporter cannot proceed either.

Do you have a (mini) reproduction demo?

  • Yes, I have a minimal reproduction demo to help resolve this issue more effectively!

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedEverything needs help from contributorstype/bugBugs to being fixed

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions