#REVIEW: What’s new in MicroProfile 3.1

Last Updated:  April 1, 2020 | Published: October 16, 2019

The third MicroProfile release of 2019 is now available: MicroProfile 3.1. With the last release of MicroProfile 3.0 in June, the MicroProfile community continues with its last release for this year. Both the Eclipse MicroProfile Metrics and MicroProfile Health specification got an update to version 2.1. Even though this release is a rather small one (compared to the release last June) I want to share with you the spec updates.

Update to MicroProfile 3.1

 

As of now, there is no application server, which implements MicroProfile 3.1. For a first impression of the updates with MicroProfile 3.1, you can use a development build of Open Liberty or wait until version 19.0.0.11.

Updates for Eclipse MicroProfile Metrics

The first update for Metrics is a clarification for the implementation of the MetricRegistry, as they now emphasize thread-safety:

The implementation must make sure that metric registries are thread-safe, in other words, concurrent calls to methods of MetricRegistry must not leave the registry in an inconsistent state.

Next, Gauge metrics must now return values that extend java.lang.Number:

In previous versions of Eclipse MicroProfile Metrics, the Gauge interface could return any value:

Furthermore, we now have a  reusable(boolean) method for the MetadataBuilder. In Metrics 2.0 there was only .notReusable() and .reusable(). If reusable is set to true, then you can register metrics multiple times under the same MetricID:

For metrics declared using annotations the default is false to prevent copy & paste errors. Programmatically created metrics are reusable by default. Keep in mind that Gauges are not reusable.

Further updates to the spec are the following:

  • Clarified that implementations can, for JSON export of scopes containing no metrics, omit them, or be present with empty values
  • TCKs are updated to use RestAssured 4.0
  • Exclusion of the transitive dependency on javax.el-api from the build of the specification. It wasn’t actually used anywhere in the build so there should be no impact
  • More text was added to the specification about programmatic (no annotations) creation of metrics

You can find the specification document for Eclipse MicroProfile Metrics 2.1 here.

Getting started with Eclipse MicroProfile Course Bundle

NEWS: Up-to-date with MicroProfile 3.3

All you need to know about MicroProfile

Looking for a resource to learn more about MicroProfile and all its specifications in-depth? Signup for the MicroProfile Course Bundle (E-Book & Video Course)

Updates for Eclipse MicroProfile Health

The first update targets out-of-the-box health check procedures. The specification says the following for proprietary health check provided e.g. by the application server vendor:

A producer SHOULD support reasonable out-of-the-box procedures

With MicroProfile Health 2.1 we now get a config variable to disable such out-of-the-box procedures:

Next, we get a new method to create a named HealthCheckResponse without using the builder. The HealthCheckResponse class now offers two static methods .up(name) and .down(name) to create a response more easily:

Further updates to the spec are the following:

  • The Javadoc for this specification got improvements
  • Several updates to the test setup
  • Removal of the duplicate Arquillian import
  • Remove EL API transitive dependency like in MicroProfile Metrics 2.1

You can find the specification document for Eclipse MicroProfile Health 2.1 here.

Last but not least, you can find the code examples on GitHub.

Have fun using MicroProfile 3.1,

Phil

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Sign up for Our Mailing List And Get

    the Testing Java Applications ($9) Cheat Sheet for Free

    Testing Java Applications Cheat Sheet Cover
    >