Describe the bug Feign metrics do not appear:
"feign.Client",
"feign.Client.http_response_code",
"feign.Feign",
"feign.codec.Decoder",
"feign.codec.Decoder.response_size",
Reason:
org.springframework.cloud.openfeign.FeignClientsConfiguration.MicrometerConfiguration#micrometerCapability is not being created because it can't find a MeterRegistry. Report shows
FeignClientsConfiguration.MicrometerConfiguration#micrometerCapability:
Did not match:
- @ConditionalOnBean (types: io.micrometer.core.instrument.MeterRegistry; SearchStrategy: all) did not find any beans of type io.micrometer.core.instrument.MeterRegistry (OnBeanCondition)
The weird is, I have everything on classpath spring-boot-starter-actuator, feign-micrometer and spring-cloud-starter-openfeign, and in fact a SimpleMeterRegistry is being created through org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration#simpleMeterRegistry.
To solve the issue I needed to add a bean myself:
@Bean
public SimpleMeterRegistry simpleMeterRegistry(Clock clock) {
return new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock);
}
With that everything works fine.
Sample
Simple app, a feign client, a config for importing @Import(FeignClientsConfiguration.class) (btw is that necessary?) :
@FeignClient(value = "numbersapi.com", url = "numbersapi.com")
public interface NumberFeignClient {
@GetMapping("/{number}")
String test(@PathVariable("number") int number);
}
@Configuration
@Import(FeignClientsConfiguration.class)
public class RegistryConfig2 {}
@Configuration
public class RegistryConfig {
// removing this bean makes it not work anymore
@Bean
public SimpleMeterRegistry simpleMeterRegistry(Clock clock) {
return new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock);
}
}
@RestController
public class WebController {
private final NumberFeignClient numberFeignClient;
public WebController(NumberFeignClient numberFeignClient) {
this.numberFeignClient = numberFeignClient;
}
@GetMapping("/hello")
public String hello() {
return numberFeignClient.test(new Random().nextInt(100));
}
}
Comment From: LeoKotschenreuther
I have the same issue, the proposed workaround solved it for me as well.
Comment From: OlgaMaciaszek
Hello @johnnywiller, do you have a micrometer-registry-{system} dependency in your build setup (for example, micrometer-registry-prometheus)?
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: johnnywiller
Sorry for the delay, so I tested with both including micrometer-registry-prometheus and without. Both yielded same result of not having feign metrics ootb.
Comment From: OlgaMaciaszek
Ok, @johnnywiller @LeoKotschenreuther please provide a minimal, complete, verifiable example that reproduces the issue - we'll look further into it then.
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-cloud-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.