0

I am using resilience4j circuitbreakers and am having trouble exporting the metrics with the prometheus servlet client. I am deploying to a jbossas7 server, but my /metrics endpoint doesn't show anything. Anyone any ideas? I am injecting the circuitbreaker into a bean, which works fine with the circuitbreaker initiation code below, which resides in a factory.

When I debug my code, I see the circuitbreaker being made and registered in the collectorRegistry. But when it is written in the servlet of the simpleclient servlet, nothing is written to the output. It just skips to the finally block in the client library code

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<servlet>
    <servlet-name>metrics</servlet-name>
    <servlet-class>io.prometheus.client.exporter.MetricsServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>metrics</servlet-name>
    <url-pattern>/metrics</url-pattern>
</servlet-mapping>

</web-app>

pom.xml dependencies

<dependency>
        <groupId>io.github.resilience4j</groupId>
        <artifactId>resilience4j-circuitbreaker</artifactId>
        <version>${resilience4j.version}</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>io.github.resilience4j</groupId>
        <artifactId>resilience4j-prometheus</artifactId>
        <version>0.13.1</version>
    </dependency>
    <dependency>
        <groupId>io.prometheus</groupId>
        <artifactId>simpleclient</artifactId>
        <version>0.5.0</version>
    </dependency>
    <dependency>
        <groupId>io.prometheus</groupId>
        <artifactId>simpleclient_servlet</artifactId>
        <version>0.5.0</version>
    </dependency>

circuitbreaker initiation

public CircuitBreaker getInjectedCircuitbreaker(InjectionPoint injectionPoint) {
    Circuitbreaker breaker = injectionPoint.getAnnotated().getAnnotation(Circuitbreaker.class);
    CircuitBreaker circuitBreaker = circuitBreakerRegistry.circuitBreaker(breaker.breakerName());
    collectorRegistry.register(CircuitBreakerExports.ofCircuitBreakerRegistry(circuitBreakerRegistry));
    return circuitBreaker;
}
bobK
  • 704
  • 2
  • 7
  • 24
  • hey there,did you find the answer ? ,as i am facing the same scenario.plz let me know if you have already find the answer. – Mahesh Nighut Jul 04 '19 at 08:23
  • Try calling your code a few times and see if it shows, I found that after a few calls I got a response – bobK Jul 05 '19 at 09:08

0 Answers0