rabbitmq / rabbitmq-java-client

RabbitMQ Java client
https://www.rabbitmq.com/java-client.html
Other
1.25k stars 576 forks source link

Enhance the MetricsCollector to distinguish metrics for NACK (requeue = true) vs NACK (requeue = false) #1442

Closed matsev closed 5 days ago

matsev commented 1 month ago

Is your feature request related to a problem? Please describe.

To my understanding there are currently no metrics emitted that distinguish whether or not a message was requeued when it was NACK:ed by the consumer

Describe the solution you'd like

One suggestion is to enhance the MetricsCollector with a new methods:

    default public void basicNack(Channel channel, long deliveryTag, boolean requeue) {
    }

    default public void basicReject(Channel channel, long deliveryTag, boolean requeue) {
    }

These methods would then be called with the requeue parameter provided whenever a messages is NACK:ed. Moreover, existing implementation such as the MicrometerMetricsCollector should implement the methods so that the metrics emitted also has knowledge about the requeue state

Describe alternatives you've considered

Application developers can implement their own custom metrics

Additional context

Related question at Stack Overflow: https://stackoverflow.com/questions/79069702/reactive-rabbitmq-metrics-for-ack-nack-requeue-false-and-nack-requeue-t

acogoluegnes commented 1 month ago

This makes sense. The tricky part would be to maintain compatibility by keeping the nacked and rejected existing metrics without the requeue information, and new metrics with the requeue information.

PR welcome.

ohksj77 commented 1 week ago

Fixed PR: #1469

acogoluegnes commented 4 days ago

@matsev There is a new requeued message count metric, can you try out the snapshot and let us know if it is what you expected? Thanks to @ohksj77 for this contribution.

matsev commented 3 days ago

I did a quick test and I can verify that the new requeued metrics is emitted by the MicrometerMetricsCollector.

Thanks!