Search code examples
javaspring-bootspring-rabbit

SpringBoot 2.0.2.RELEASE with amqp misses metrics actuator endpoint


I have a small Spring Boot application which creates a RabbitListener and does stuff with the messages (all successful so far). I would like to see the default metrics of the Service (f.e. http://localhost:8082/demo/metrics/jvm.memory.max) within my defined management endpoints, but as soon as I add the dependency

<dependency>
    <groupId>org.springframework.amqp</groupId>
    <artifactId>spring-rabbit</artifactId>
    <version>2.0.2.RELEASE</version>
</dependency>

the default "/metrics" endpoint is not exposed any more. I am using version 2.0.2.RELEASE on spring-boot spring-boot-configuration-processor, spring-boot-starter-web, spring-boot-starter-actuator and spring-rabbit dependencies. I can reproduce this behavior within a starter spring boot application by adding/removing the dependency.

I have included all endpoints to be exposed and only denied a few one within my application.yml. In there, I also set the management.server.port to 8082 and the management.server.servlet.context-path to "/demo". If I run the application (within IntelliJ) without the dependency, I get 9 exposed endpoints (including metrics), but if I add the dependency, I only get 8 exposed endpoints and metrics are not available any more.

Is this a know/wanted behavior? Do I have to / Can I enable the simpleMeterRegistry again? Within debug logs I can see that the entry

MetricsEndpointAutoConfiguration#metricsEndpoint matched:
  - @ConditionalOnBean (types: io.micrometer.core.instrument.MeterRegistry; SearchStrategy: all) found bean 'simpleMeterRegistry'; @ConditionalOnMissingBean (types: org.springframework.boot.actuate.metrics.MetricsEndpoint; SearchStrategy: all) did not find any beans (OnBeanCondition)

is missing when amqp dependency is added, but I did not find a howTo to add it again.

Thanks for mentioning it: The full condition evaluation report can be found here: https://gist.github.com/dkrones/222c096770a79d9cb69d09c4e40c33b6


Solution

  • In pom, try moving the amqp dependency below the actuator dependency, so that maven resolves actuator dependency before amqp dependency. It will resolve the issue.