August 2019
Intermediate to advanced
256 pages
6h 43m
English
Applications can choose to expose metric data via a CDI programming model. This model was inspired by DropWizard Metrics, so that it is easier to transition applications to MP-Metrics. It also uses the annotations from DropWizard Metrics, which have been augmented to support metadata.
Let’s start with an example by defining a counter that is then incremented in code:
@Inject@Metric(absolute = true, description = "# calls to /health")Counter hCount; // This is the counter@GET@Path("/health")public Response getHealth() throws Exception { hCount.inc(); // It is increased in the application [...]}
In this example, we are registering a counter by getting it injected into the hCount variable:
The @Metric
Read now
Unlock full access