I am experimenting with Javax/JaxRs and I am using the WildFly 25 server, which I am not quite familiar with.
Searching for something similar to Spring's Actuator, I stumbled across the metrics & health endpoints the server exposes by default, and its ability to add custom counters, gauges etc. to application endpoints.
However, whatever I do, these custom endpoints are not exposed under the default http://localhost:9990/metrics URL.
I am following the guide provided by WildFly under the GitHub repository: https://github.com/wildfly/quickstart/tree/main/microprofile-metrics
There are some "red flags" on the tutorial that do not seem to be working with whatever I try to do.
Accepted: application/json
", which still returns the default Prometheus format, both in Postman and Curl.As far as the tutorial code is concerned, I tried running it on the Jakarta EE 8 Full & Web Distribution but it throws the following error:
Artifact microprofile-metrics:war exploded: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"microprofile-metrics.war\".undertow-deployment" => "java.lang.NoClassDefFoundError: org/eclipse/microprofile/metrics/Counter Caused by: java.lang.NoClassDefFoundError: org/eclipse/microprofile/metrics/Counter
I tried compiling the code with different versions of Java (1.8, 11, 17) hoping that it may fix the problem but to no avail.
However, using the WildFly Preview EE 9.1 Distribution seems to stop throwing the error, but the custom metrics still do not to work.
There are the subsystems that I added to both distributions during my tries (taken from standalone.xml):
<extension module="org.wildfly.extension.health"/>
<extension module="org.wildfly.extension.metrics"/>
<extension module="org.wildfly.extension.microprofile.config-smallrye"/>
<extension module="org.wildfly.extension.microprofile.fault-tolerance-smallrye"/>
<extension module="org.wildfly.extension.microprofile.health-smallrye"/>
<extension module="org.wildfly.extension.microprofile.jwt-smallrye"/>
<extension module="org.wildfly.extension.microprofile.metrics-smallrye"/>
<extension module="org.wildfly.extension.microprofile.openapi-smallrye"/>
<extension module="org.wildfly.extension.microprofile.opentracing-smallrye"/>
<extension module="org.wildfly.extension.undertow"/>
(others omitted for brevity)
I also tried enabling the statistics by creating the following bat and launching it:
call standalone.bat -Dwildfly.statistics-enabled=true
I am using IntelliJ, so I tried doing the same from within the IDE:
(the "enable statistics" option was added both to VM options & on the bat during launch to make sure it works)
Here are the dependencies that I am using, based on my server's version:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-microprofile</artifactId>
<version>25.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-jakartaee8-with-tools</artifactId>
<version>25.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Import the MicroProfile Metrics API, we use provided scope as the API is included in the server -->
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the CDI API, we use provided scope as the API is included in the server -->
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the Jakarta REST API, we use provided scope as the API is included in the server -->
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
John. I'm the Metrics/MP Metrics component lead for WildFly, so hopefully I can help get you sorted out.
Before I get too excited about digging through the WF source, can you confirm which configuration you're using? It looks like you're using standalone.xml configuration. While that does have a metrics extension, it's not MP Metrics. For that, you would need to use standalone-microprofile.xml.
Hopefully, your issue is as simple as that. If not, let me know, and we'll dig deeper. :)