0

I was upgrading spring boot to 2 in one of the project. I am facing issue with @Autowire metricRegistry:MetricRegistry

I had read upgrade guide where it is mentioned that Metrics are replaced by Micrometer's MeterRegistry.

Since, Dropwizard MetricRegistry is havely used in current project, it is difficult to replace it.

Is there any possibility to use Dropwizard MetricRegistry with spring boot 2 and @Autowire metricRegistry:MetricRegistry get work?

2
  • It isn't replaced with its own, it is replaced with the Micrometer version of the MeterRegistry. Moving to that shouldn't be to big of a change. Commented Mar 11, 2024 at 7:57
  • Hi @M. Deinum, Can you let me know how can it be replace in following? extractDataSource(@Autowire metricRegistry:MetricRegistry) { DataSource ds = ABC_Class.build(metricRegistry); } While ABC_Class has build method as follows HikariDataSource build(metricRegistry:Option[MetricRegistry]) { HikariDataSource ds.... metricRegistry.foreeach(ds.setMetricRegistry) } Commented Mar 11, 2024 at 9:56

1 Answer 1

1

Fyi: Spring Boot 2 reached its end of OSS support life a while ago, you should upgrade to the latest 3.x: https://spring.io/projects/spring-boot#support

You should take a look at DropwizardMeterRegistry, you can use it as:

@Bean DropwizardMeterRegistry dropwizardMeterRegistry(...) { return new DropwizardMeterRegistry(); } 

Then you can inject MeterRegistry (Micrometer's API) in new code and keep using MetricsRegistry (Dropwizard's API) in old code.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Jonatan, Thanks for reply! will try this and revert.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.