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

Default metrics provided by spring-boot-actuator don't work #296

Closed
chillleader opened this issue Dec 15, 2022 · 10 comments
Closed

Default metrics provided by spring-boot-actuator don't work #296

chillleader opened this issue Dec 15, 2022 · 10 comments
Assignees

Comments

@chillleader
Copy link
Contributor

Issue description

MetricsRecorder bean declaration in spring-zeebe-starter breaks the default metrics auto configurations provided by Spring Boot Actuator.

Apparently, the MeterRegistry bean is eagerly injected, which breaks the initialization of other metrics. As a result, for, example, the jvm metrics are missing in the actuator endpoint:
Screenshot 2022-12-15 at 13 46 25

Possible solution

  • Inject MeterRegistry bean with @Lazy

Similar issues with example solutions:

@berndruecker
Copy link
Contributor

berndruecker commented Dec 15, 2022

Awesome - can you provide a PR @chillleader or is this something we should give more thouht?

Feeling-wise, the whole auto configuration could be worth to have a concentrated look when doing #275

@chillleader
Copy link
Contributor Author

Yes, I can provide an immediate fix by adding @Lazy and maybe also take a concentrated look at this later while working on the new connector metrics.

@berndruecker
Copy link
Contributor

great stuff - from my perspective we can close this for now - I made a remark in #275 to have another look at it then

@chillleader
Copy link
Contributor Author

I encountered this again in 8.2.0-alpha1.

@chillleader chillleader reopened this Mar 13, 2023
@berndruecker
Copy link
Contributor

I can have a look at it - I think I have ideas why. Thanks for raising it!

@berndruecker
Copy link
Contributor

Ok - after trying out different things I have to confess I don't fully understand the problem ;-)

The fix proposed in spring-projects/spring-boot#26684 also works for us, so if I add the following configuration, I have all metrics back - even without @Lazy.

  @Bean
  InitializingBean forceMeterRegistryPostProcessor(BeanPostProcessor meterRegistryPostProcessor, MeterRegistry registry) {
    return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
  }

There were further quite some discussions/problems with such things with various Spring Boot 2.x versions. My proposal is that we simply apply this workaround and do not try to understand the big picture fully.

@berndruecker
Copy link
Contributor

grafik

@berndruecker
Copy link
Contributor

@chillleader Can you probably double check with latest main? Should be fixed with 1603539

@chillleader
Copy link
Contributor Author

Works like a charm ⭐ Thank you Bernd.
I'm also fine with this workaround.

@445990772
Copy link

i have the same problem,
spring-boot version : 2.7.8

when I debuged MeterRegistryPostProcessor#postProcessAfterInitialization,
debuger not jump into if(bean instance of MeterRegistry) ,then i found jvmMetrics does not bind to PrometheusMeterRegistry
image

then i try to solve the problem with this , but it doesn't works ,MeterRegistryPostProcessor can not be imported cause it's not public
what else can i do ?

Btw. for anyone else having this issue, this fixes it for now:

@configuration
public class FixPrometheusMetrics {
public FixPrometheusMetrics(MeterRegistryPostProcessor postProcessor, PrometheusMeterRegistry registry) {
postProcessor.postProcessAfterInitialization(registry, "");
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants