Skip to content
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

MeterRegistryCustomizer not called if Spring Data is in the classpath #26675

Closed
samcontesse opened this issue May 26, 2021 · 2 comments
Closed
Labels
status: duplicate A duplicate of another issue

Comments

@samcontesse
Copy link

Hello!

It seems that the newly introduced RepositoryMetricsAutoConfiguration (Spring Boot 2.5.0) triggers the creation of the MeterRegistry bean during the initialization of the bean post processor. This leaves no chance for MeterRegistryPostProcessor#postProcessAfterInitialization to customize the registry with MeterRegistryCustomizer.
The call stack shows some registerBeanPostProcessors when the registry is instanciated which is not the case when RepositoryMetricsAutoConfiguration is not loaded.

I created a minimal sample repo to reproduce the issue.

If you run it, you can see that MetricsCustomizerNotCalledApplication#meterRegistryCustomizer is never called. If spring-boot-starter-data-jpa is removed from dependencies, it is called as expected.

A ugly workaround would be to call it again afterwards with something like:

    @Bean
    public InitializingBean forceMeterPostProcessor(BeanPostProcessor meterRegistryPostProcessor, MeterRegistry registry) {

        return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
    }

Thanks for your help.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 26, 2021
@izeye
Copy link
Contributor

izeye commented May 26, 2021

This seems to be a duplicate of #26630.

@scottfrederick
Copy link
Contributor

scottfrederick commented May 26, 2021

Running the sample against Spring Boot 2.5.1-SNAPSHOT results in the expected message being shown. Marking as duplicate of #26630.

@scottfrederick scottfrederick added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants