SavitarC opened a new issue, #16109:
URL: https://github.com/apache/dubbo/issues/16109

   ### Pre-check
   
   - [x] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) 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](https://github.com/SavitarC/dubbo-support-prometheusmetrics)
   
   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:
   
   ```java
   if (PROTOCOL_PROMETHEUS.equals(metricsConfig.getProtocol()) && 
!MetricsSupportUtil.isSupportPrometheus()) {
       return;
   }
   ``` 
   The validation logic is as follows:
   ```java
   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?
   
   - [x] 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?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to