Micrometer is recommended for metrics with Quarkus 1.9

Though Quarkus offers extensions for MicroProfile, including metrics, we’re now recommending the use of the Micrometer extension for metrics in Quarkus with the release of 1.9.

Brief MicroProfile Metrics History

During the creation of the MicroProfile Metrics specification in 2017, Dropwizard Metrics was the most popular metrics library at that time. It was a natural fit for MicroProfile to use DropWizard Metrics as inspiration for a metrics specification.

The monitoring ecosystem for cloud environments has evolved considerably since then, and that has prompted a re-evaluation of how we approach working with metrics.

Why Micrometer?

During the last 3-4 years, there’s been a growing focus on the needs of Site Reliability Engineers (SREs) in monitoring the operations of many varied services. This focus leads to driving simplicity and ease of use to the SRE world. We don’t want make the life of an SRE harder!

The design and development of Micrometer focused on the needs of SREs from the very beginning. A key aspect to that approach is separating out the metric implementation into the registries, enabling different registries to customize how the metric export, aligning with a specific monitoring tool.

Micrometer was built to adapt to the changing cloud native landscape while presenting a steady API for applications and libraries to use. Each MeterRegistry implementation encapsulates its specific aggregation and reporting requirements. There are MeterRegistry implementations available for cloud monitoring systems like Prometheus and Statsd, as well as service providers like Datadog, New Relic or Stackdriver. You can include more than one of these registries at the same time, too.

While Micrometer has an API for applications to use, practical usage is more focused on the MeterBinder abstraction. MeterBinders allow instrumentation for application libraries to be added later. It is even better when your application framework can register discovered MeterBinders on your behalf.

Micrometer does follow different naming conventions than Dropwizard or MP Metrics, for a few reasons. First, it uses a dot notation for all metric names, e.g. my.metric.name. Each registry implementation can then apply its own naming convention to convert that name into something that matches its convention. The Prometheus MeterRegistry converts my.metric.name into my_metric_name, for example. Second, Micrometer was built around the notion of dimensional metrics, rather than adapting to it later.

Another benefit to using Micrometer is its usage in the wider Java ecosystem. Spring Boot and Micronaut both use Micrometer, amongst others. In an environment where SREs are monitoring instances of different Java frameworks, having them all produce metrics with the same names and dimensions is incredibly beneficial.

For example, we likely have a metric for an HTTP endpoint like below:

http_server_requests{method="GET", uri="/hello", status="200", outcome="SUCCESS"}
http_server_requests{method="GET", uri="/hello", status="500", outcome="SERVER_ERROR"}

With Quarkus, the Micrometer extension emits the same HTTP endpoint metric irrespective of whether it was created by JAX-RS, Vert.x, or Undertow without the developer needing to add anything to their code. The only effort required is to activate metrics.

The http metrics emitted by the Micrometer extension is the also same as what is emitted by Spring Boot and Micronaut, allowing SREs to work with aggregated http metrics regardless of which Java framework is used.

Can I still use MicroProfile Metrics?

The MicroProfile Metrics extension, quarkus-smallrye-metrics, is still available and usable by applications. For all the reasons outlined in Why Micrometer?, Quarkus no longer recommends applications use the extension.

In the short to medium term, we will be working with the MicroProfile Metrics community to evolve the specification to be aligned with Micrometer. What that means for the specification is not likely to be known until some time in 2021.

For those that prefer to retain compatibility with MicroProfile Metrics, despite the problems discussed in Why Micrometer?, that will remain possible, but at the discretion of application developers to make the informed choice.

Summary

Since 1.8 Quarkus offered two extensions for metrics, quarkus-micrometer and quarkus-smallrye-metrics. With the release of 1.9, Quarkus will be recommending quarkus-micrometer for use with metrics.

Come play with the extension, we love it for many reasons and hope you will too. Reach out if you have any issues using the Micrometer extension in Quarkus!