MicroProfile Metrics in Helidon 1.3

Santiago Pericas-Geertsen
Helidon
Published in
2 min readSep 30, 2019

Helidon 1.3 is out and the big news here is support for MicroProfile 3.0. This new version of MP includes a newer version of the Metrics API. Fortunately or unfortunately, depending on your perspective, this new Metrics 2.0 API is not backwards compatible with earlier versions.

Here is a summary of some of the non-compatible changes introduced:

  • Counters are now always monotonic
  • A new metric, concurrent gauges, exist to provide similar semantics to the old counters
  • Metadata is now an interface and a newMetadataBuilder class is provided
  • MetricID is the way to identify a metric and can be decorated with tags which are no longer part of Metadata

It follows that if your application uses any of the features listed above, and you update it to use the latest metrics library, it will mostly likely break. Despite many of these changes being “sound”, they do introduce problems when it comes to upgrading your services.

With this in mind, Helidon 1.3 has built-in support for the old Metrics 1.X and the new Metrics 2.0 APIs. How to select one or the other depends on what type of Helidon applications you have.

Helidon SE Services

Support for the new Metrics 2.0 features, at least those available in a Helidon SE environment, are available using the new dependency.

<groupId>io.helidon.metrics</groupId>
<artifactId>helidon-metrics2</artifactId>
<version>1.3.0</version>

Note that the artifact ID is helidon-metrics2 instead of helidon-metrics, while the version is the same as for all other Helidon 1.3 artifacts. If your application already depends on helidon-metrics it should continue to work unchanged.

Helidon MP Services

An existing MP application would likely already use one of the MP bundles provided by Helidon. Moving to the latest metrics is simply a matter of updating the 2.2 bundle to the latest 3.0 one:

<groupId>io.helidon.microprofile.bundles</groupId>
<artifactId>helidon-microprofile-3.0</artifactId>
<version>1.3.0</version>

Or by directly referencing to the new MP metrics implementation library:

<groupId>io.helidon.microprofile.metrics</groupId>
<artifactId>helidon-microprofile-metrics2</artifactId>
<version>1.3.0</version>

References

--

--