-
Notifications
You must be signed in to change notification settings - Fork 1.1k
No metrics with @EnableIntegrationManagement #3643
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
Comments
Possible WorkaroundThere seems to be a workaround for people who need Instead of using the @Bean(name = IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public IntegrationManagementConfigurer managementConfigurer(MeterRegistry meterRegistry) {
IntegrationManagementConfigurer configurer = new IntegrationManagementConfigurer();
configurer.setDefaultLoggingEnabled(false);
configurer.setMetricsCaptor(new MicrometerMetricsCaptor(meterRegistry));
return configurer;
} |
Just for your info: you must not test against those old versions since every single next includes the previous. Now to clarify the problem: Thank you for understanding! |
Here is another work around - omit the annotation and add this to configure the framework's bean... @Bean
ApplicationRunner runner(IntegrationManagementConfigurer imc) {
imc.setDefaultLoggingEnabled(false);
return args -> {
};
} (You don't really need a runner; this can be done in any bean definition). |
@artembilan Since that's the sole remaining property on that annotation, maybe we should deprecate it too, and support the setting via WDYT? |
Yeah... We can do that, but it won't help with the problem over here.
Removing such an annotation would be more complicated, than just advice do not use in Spring Boot. |
I wasn't suggesting removing the annotation, just all of its properties. |
Well, then it is going to be confusing for end-user: they have to declare an annotation and property. It is really probably only the way to fix it via property on Spring Boot side for consistency and convenience of configuration on convention. Or... I can play with However in the end we could do both 😄 |
Ended up with a solution for the framework like this:
Plus:
Slightly breaking change, but having a workaround we are not going to back-port it to other versions. |
@artembilan Thanks for the quick reply and analysis of the issue. To answer your initial question: Yes, exactly: As soon as a We use the About the versions i tested: I was just curious if the issue was introduced with a recent combination of Spring Integration and Spring Boot, or if a workaround could have been to just use a slightly older version combination 😄 @garyrussell Thanks for the other workaround! |
Fixes spring-projects#3643 The `ImportBeanDefinitionRegistrar` register its bean definition in the early phase. It causes a problem with Spring Boot when an explicit `@EnableIntegrationManagement` is declared: the `MeterRegistry` is provided later on via auto-configuration and `MicrometerMetricsCaptor` has no knowledge about `MeterRegistry` at the `ImportBeanDefinitionRegistrar` phase. * Reworks `MicrometerMetricsCaptorRegistrar` to the `MicrometerMetricsCaptorConfiguration` and use special conditional `MicrometerMetricsCaptorImportSelector` for that `@EnableIntegrationManagement`. This way a `MicrometerMetricsCaptor` `@Bean` consults `ObjectProvider<MeterRegistry>` on its creating time and returns `null` if no `MeterRegistry` beans at all.
See also relevant change in Spring Boot: spring-projects/spring-boot#28355 |
Fixes #3643 The `ImportBeanDefinitionRegistrar` register its bean definition in the early phase. It causes a problem with Spring Boot when an explicit `@EnableIntegrationManagement` is declared: the `MeterRegistry` is provided later on via auto-configuration and `MicrometerMetricsCaptor` has no knowledge about `MeterRegistry` at the `ImportBeanDefinitionRegistrar` phase. * Reworks `MicrometerMetricsCaptorRegistrar` to the `MicrometerMetricsCaptorConfiguration` and use special conditional `MicrometerMetricsCaptorImportSelector` for that `@EnableIntegrationManagement`. This way a `MicrometerMetricsCaptor` `@Bean` consults `ObjectProvider<MeterRegistry>` on its creating time and returns `null` if no `MeterRegistry` beans at all.
In what version(s) of Spring Integration are you seeing this issue?
5.5.4 (Spring Boot 2.5.5)
5.5.3 (Spring Boot 2.5.4)
5.5.2 (Spring Boot 2.5.3)
5.5.1 (Spring Boot 2.5.2)
5.5.0 (Spring Boot 2.5.1)
5.4.11 (Spring Boot 2.4.10)
5.4.10 (Spring Boot 2.4.10)
5.4.9 (Spring Boot 2.4.9)
5.4.8 (Spring Boot 2.4.9)
5.4.7 (Spring Boot 2.4.7)
5.4.6 (Spring Boot 2.4.5)
5.4.5 (Spring Boot 2.4.4)
(did not test earlier 5.4.x versions)
5.3.9.RELEASE (Spring Boot 2.3.12.RELEASE)
5.3.8.RELEASE (Spring Boot 2.3.12.RELEASE)
5.3.7.RELEASE (Spring Boot 2.3.10.RELEASE)
5.3.6.RELEASE (Spring Boot 2.3.9.RELEASE)
(did not test earlier 5.3.x versions)
maybe also on earlier versions, but did not test.
Describe the bug
If
@EnableIntegrationManagement
annotation is added to the application configuration to disable logging, Spring Integration no longer provides metrics.This is probably related to the fixed bug #3420
If the
@EnableIntegrationManagement
annotation is present, Spring Integration tries to set up theMicrometerMetricsCaptor
before spring boot provides theMeterRegistry
bean.To Reproduce
Add
@EnableIntegrationManagement
annotation to Spring Integration application that provides metrics.Expected behavior
If a
MeterRegistry
bean is present (provided through Spring Boot), Spring Integration should provide metrics as described in documentation even if a@EnableIntegrationManagement
annotation is present.Sample
https://github.com/MartinHochstrasser/spring-integration-metrics-issue
The text was updated successfully, but these errors were encountered: