Not getting metrics in actuators, spring-boot-2
See original GitHub issueResilience4j version: ‘1.3.0’
Java version: 1.8 Here is the build.gradle file
repositories {
mavenCentral()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.0.4.RELEASE'
}
}
plugins {
id 'org.springframework.boot' version '2.1.5.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
bootJar {
archiveBaseName = 'control-service'
version = '1.0.0'
}
group = 'in.dreamplug.legos'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
maven {
url "http://nexus.infra.dreamplug.net/repository/maven-public"
}
mavenCentral()
}
ext {
resilience4jVersion = '1.3.0'
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile "org.projectlombok:lombok:1.18.8"
compileOnly 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.8'
testCompile 'org.projectlombok:lombok:1.18.8'
testImplementation 'org.projectlombok:lombok:1.18.8'
compile 'com.netflix.hystrix:hystrix-core:1.5.18'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix', version: '2.1.1.RELEASE'
compile 'com.google.code.gson:gson:2.8.5'
compile group: 'com.ibm.icu', name: 'icu4j', version: '64.2'
compile group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '2.7.0'
compile group: 'in.dreamplug.legos', name: 'commons-springboot', version: '1.0.21'
compile group: 'in.dreamplug.legos', name: 'commons-core', version: '1.0.21'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-params:5.3.1'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.21.0'
testCompile group: 'org.mockito', name: 'mockito-junit-jupiter', version: '2.23.0'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.0.2.RELEASE'
compile group: 'com.datadoghq', name: 'dd-trace-api', version: '0.40.0'
//resilience4j
compile("io.github.resilience4j:resilience4j-spring-boot2:${resilience4jVersion}")
compile("io.github.resilience4j:resilience4j-all:${resilience4jVersion}")
compile('org.springframework.boot:spring-boot-starter-aop')
compile "io.micrometer:micrometer-registry-prometheus"
}
this is my config file
package in.dreamplug.legos.control.clients;
import java.time.Duration;
import org.springframework.context.annotation.Configuration;
import io.github.resilience4j.bulkhead.Bulkhead;
import io.github.resilience4j.bulkhead.BulkheadConfig;
import io.github.resilience4j.bulkhead.BulkheadRegistry;
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig;
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
import io.github.resilience4j.core.IntervalFunction;
import io.github.resilience4j.micrometer.tagged.TaggedCircuitBreakerMetrics;
import io.github.resilience4j.timelimiter.TimeLimiter;
import io.github.resilience4j.timelimiter.TimeLimiterConfig;
import io.github.resilience4j.timelimiter.TimeLimiterRegistry;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
@Configuration
public class Resilience4jConfig {
private static int executionTimeoutInMillis = 2000;
private static Integer failureRateThresholdPercentage = 50;
private static CircuitBreaker defaultCircuitBreaker;
private static CircuitBreakerRegistry defaultCircuitBreakerRegistry;
Resilience4jConfig() {
CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig.custom().failureRateThreshold(failureRateThresholdPercentage)
.permittedNumberOfCallsInHalfOpenState(5)
// exponential backoff
.waitIntervalFunctionInOpenState(IntervalFunction.of(2000)).build();
defaultCircuitBreakerRegistry = CircuitBreakerRegistry.of(circuitBreakerConfig);
defaultCircuitBreaker = defaultCircuitBreakerRegistry.circuitBreaker("default-control");
}
public static CircuitBreakerConfig getDefaultCircuitBreakerConfig() {
return defaultCircuitBreakerRegistry.getDefaultConfig();
}
public static CircuitBreaker getDefaultCircuitBreaker() {
return defaultCircuitBreaker;
}
public static CircuitBreaker createCircuitBreaker(CircuitBreakerConfig circuitBreakerConfig, String circuitBreakerName) {
CircuitBreaker circuitBreaker = defaultCircuitBreakerRegistry.circuitBreaker(circuitBreakerName, circuitBreakerConfig);
TaggedCircuitBreakerMetrics.ofCircuitBreakerRegistry(defaultCircuitBreakerRegistry).bindTo(new SimpleMeterRegistry());
return circuitBreaker;
}
}
then using the above things to do the following
public CircuitBreaker getCircuitBreaker() {
CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig.from(Resilience4jConfig.getDefaultCircuitBreakerConfig())
.enableAutomaticTransitionFromOpenToHalfOpen().build();
return Resilience4jConfig.createCircuitBreaker(circuitBreakerConfig, "statement-service");
}
public Supplier<CredScan> getDecoratedSupplier() {
Supplier<CredScan> decorate = Decorators.ofSupplier(this::getApiResponseSupplier)
.withCircuitBreaker(getCircuitBreaker())
.decorate();
return decorate;
}
Result execute(){
Supplier<T> decoratedSupplier = getDecoratedSupplier();
Try<T> tryResult = Try.ofSupplier(decoratedSupplier).recover(this::fallbackMethod);
return tryResult.get();
}
application.yaml file
management.endpoints.web.exposure.include: '*'
management.endpoint.health.show-details: always
management.health.circuitbreakers.enabled: true
management.health.ratelimiters.enabled: true
I am not wrting confing in application.yml insted just making configuration through code and storing in Register, retriving it and using it. I am not getting metics on http://localhost:9018/actuator/metrics
, the list here doesnot has resilience4j Metrics. Am I missing something?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Spring Boot 2 - Actuator Metrics Endpoint not working
Endpoints like /health , /metrics etc. are no longer available at the default root context. They are available from now on at http://{host}:{port}/actuator...
Read more >Spring Boot Actuator | Baeldung
As we can see, there are no actual metrics as we got in 1.x. To get the actual value of a specific metric,...
Read more >Production-ready Features - Spring
Auditing, health, and metrics gathering can also be automatically applied to your application. 1. Enabling Production-ready Features. The spring-boot-actuator ...
Read more >Spring Boot Actuator Not Working – Troubleshoot - Yawin Tutor
Spring Boot Actuator is not working because the spring boot actuator dependency is incorrect or the actuator isn't configured properly in ...
Read more >Spring Boot Actuator Endpoints - Health check and Metrics
Let's learn to configure Spring boot 2 actuator endpoints. ... candidates and the reason why they 'were' or 'were not' applied.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This works. with
@Autowired
CircuitBreakerRegistry it worked. Thankyou so much.You have to inject the CircuitBreakerRegistry which is created by the AutoConfiguration, but you must not create your own instance. If you can’t inject it, then you don’t have any chance to get it working.