spring-projects / spring-amqp

Spring AMQP - support for Spring programming model with AMQP, especially but not limited to RabbitMQ
https://spring.io/projects/spring-amqp
Apache License 2.0
806 stars 619 forks source link

"observationEnabled" defaults to TRUE #1549

Open cero-t opened 1 year ago

cero-t commented 1 year ago

Expected Behavior

I want the auto-configuration to set the observationEnabled parameter of RabbitTemplate and AbstractRabbitListenerContainerFactory to true by default.

Current Behavior

Micrometer Tracing does not work out of the box because the default value of their observationEnabled are now set to false.

Context

Spring Boot 3.0 provides auto-configuration for Micrometer Tracing, and it works out of the box with Spring Web and Spring Cloud Stream, but it doesn't work with Spring AMQP. I found Spring Cloud Stream (binder-rabbitmq) sets it true. I think Spring AMQP should also be friendly towards Micrometer Tracing.

garyrussell commented 1 year ago

It is false by default by design; adding observation is quite expensive, especially for those who only want metrics (and not tracing). When observation is not enabled, we maintain Micrometer timers outside of observation, avoiding its overhead.

We could consider setting it based on an environment property, but we cannot set it to true by default.

artembilan commented 1 year ago

Don't we need to expose such an auto-configuration property, @garyrussell , in Spring Boot? RabbitProperties.Template and RabbitProperties.Listener . For Spring Integration I did via spring.integration.management.observationPatterns

garyrussell commented 1 year ago

It could be done there, yes; but, again, I would not want it to default to true.

artembilan commented 1 year ago

Right, false by default, but still easy to configure by convention instead of some customizers and so on.

cero-t commented 1 year ago

Thank you, I understand the design. I hope it can be set by an environment or auto-configuration property.

garyrussell commented 1 year ago

You could open a request against Boot, but I don't know if the Boot team will add new properties in patch releases.