Skip to content

RabbitMetricsAutoConfiguration is instantiated too late #12855

@mzakes

Description

@mzakes

Hi,

Micrometer metrics for RabbitMQ are instantiated too late which leads that metrics are never updated. Instead a NoOpMetricsCollector is used and it's methods are invoked. It seems that rabbitmq connection is created before in com.rabbitmq.client.ConnectionFactory.

    public Connection newConnection(ExecutorService executor, AddressResolver addressResolver, String clientProvidedName)
        throws IOException, TimeoutException {
        if(this.metricsCollector == null) {
            this.metricsCollector = new NoOpMetricsCollector();
        }

Workaround that works for me now is to create a RabbitMQConfiguration class with:

@PostConstruct
public void init() {
  com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = this.connectionFactory.getRabbitConnectionFactory();
  rabbitConnectionFactory.setMetricsCollector(new MicrometerMetricsCollector(registry));
}

spring-boot: 2.0.1.RELEASE

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions