-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhanced configurability for micrometer utilization in AbstractMessageListenerContainer #1459
Comments
Regarding the second issue (multiple registries), we recently fixed a similar problem in spring-kafka |
The AMLC already has a setter for /**
* Set to false to disable micrometer listener timers.
* @param micrometerEnabled false to disable.
* @since 2.2
*/
public void setMicrometerEnabled(boolean micrometerEnabled) {
this.micrometerEnabled = micrometerEnabled;
} If you are using factory.setContainerCustomizer(container -> container.setMicrometerEnabled(false)); |
Thank you very much for the quick response and the solution for the situation with multiple registries. Regarding your advice with using I guess we need to refactor our integration because currently we're using the |
...or adding the property micrometerEnabled also to the |
The Lines 183 to 184 in fe37e01
Yes, the LCFB should expose the property and/or setter for a customizer; I will add that. |
We should also move the micrometer initialization to |
Resolves #1459 * Add micrometer properties and container customizers to LCFB. * Use `ObjectProvider` to locate registry.
Resolves #1459 * Add micrometer properties and container customizers to LCFB. * Use `ObjectProvider` to locate registry.
Expected Behavior
It should be possible to configure the default behavior and disable utilization of micrometer in context of the AMQP integration, particularly the
AbstractMessageListenerContainer
, before it even attempts to establish the micrometer support via creating aMicrometerHolder
. A convenient way would be the possibility to configure the attributeAbstractMessageListenerContainer.micrometerEnabled
and set it to false during the initialization, if needed.If the case, that multiple instances of
MeterRegistry
s are available in the application context, is actually relevant and not just a theoretical case, it should be possible to specify the particularMeterRegistry
(instantiable) subclass via configuration.Current Behavior
Currently, the utilization of micrometer by the
AbstractMessageListenerContainer
is enabled by default when micrometer (or ratherio.micrometer.core.instrument.MeterRegistry
) is found on the classpath. So, when micrometer is used by any part of the application, it is also enabled by default for the *MessageListenerContainers, even if not wanted or not needed.Additionally, during instantiation of the
MicrometerHolder
there is an assumption that only a single instance ofMeterRegistry
can be present in the application context. Technically, it might be possible to have more than oneMeterRegistry
and in that case it is not possible to specify, which particularMeterRegistry
should be used and the message "No micrometer registry present" would also be misleading in that case.Context
In our application, we're collecting some business related metrics using an
InfluxMeterRegistry
which should not automatically be used in context of our RabbitMQ integration via spring-amqp. The most convenient way, at least for us, to avoid this utilization would be to makeAbstractMessageListenerContainer.micrometerEnabled
configurable, so we could just configure it to be false.Setting the
AbstractMessageListenerContainer.micrometerEnabled
attribute to false at the right moment during bean initialization via customized post-processing seems not to be possible, at least in our case, where theSimpleMessageListenerContainer
is created and also initialized (including afterPropertiesSet()) as part of the callinvokeInitMethods(beanName, wrappedBean, mbd);
insideAbstractAutowireCapableBeanFactory.initializeBean(...)
while the post-processings are applied right before and right after this whole step. Actually, a post-processing between creation and initialization, probably as a part of theListenerContainerFactoryBean
would be needed to programmatically set themicrometerEnabled
flag which seems to be currently not in place for the instantiation ofSimpleMessageListenerContainer
s.The text was updated successfully, but these errors were encountered: