Skip to content

Conversation

artembilan
Copy link
Member

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.

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.
@artembilan
Copy link
Member Author

Note: this is some kind of breaking change and with provided workaround in the issue dictate us no back-port policy.
With that we also may reject the PR for current 5.5.x version and just defer it to the next major 6.0.
But still: we never advertise MicrometerMetricsCaptorRegistrar for end-user interaction.
Although another breaking change may be observed when MetricsCaptor bean and @EnableIntegrationManagement declared explicitly. Which is also not right way to have in the target project: or annotation or explicit beans.
Therefore my intention to have this fix on board for consistency with exiting annotation model in Spring Framework.

@garyrussell garyrussell merged commit 72b9e70 into spring-projects:main Oct 18, 2021
@artembilan artembilan added this to the 5.5.5 milestone Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No metrics with @EnableIntegrationManagement
2 participants