liveBook · Manning

MeterRegistry

As explained in Quarkus in Action

MeterRegistry is Micrometer's central registry for managing the meters and metrics in an application.

MeterRegistry is Micrometer’s global registry for application metrics. It manages the meters currently present and supports dynamically adding or removing them. section 10.3.4

Use it for programmatic instrumentation when annotations are insufficient or when metric creation needs more control. Calling counter("orders") uses get-or-create behavior: it creates the counter if necessary and returns it for updates. section 10.3.4

A typical imperative workflow is:

  • Inject MeterRegistry into the CDI bean that performs the measured operation. section 10.3.4
  • Obtain a counter with meterRegistry.counter("orders") and increment it after the relevant operation. section 10.3.4
  • Build the metric explicitly with Counter.builder(...) when a description or other metadata is required. section 10.3.4

Counting orders programmatically

@Inject MeterRegistry meterRegistry; public void orderPlaced(OrderDetails details) { // order processing logic meterRegistry.counter("orders").increment(); }

Register explicitly configured meters once, before updates begin, such as from a @PostConstruct method in a @Singleton bean. Annotation-based @Counted instrumentation remains shorter for straightforward method invocation counters. section 10.3.4 section 10.3.6

How Quarkus in Action covers it

How deep it goes
Explains global registry behavior, get-or-create counters, explicit metadata registration, and lifecycle timing, but not registry internals.
Examples
Uses an orders counter and a car-registration counter exposed through the metrics endpoint and visualized in Grafana.
What it assumes
Assumes CDI injection and basic metric concepts while contrasting programmatic registration with method annotations.
What you can do after
Apply Micrometer’s API to instrument application operations with counters and attach metadata when needed.
How it connects
Connects MeterRegistry with Micrometer, counters, CDI beans, annotations, Quarkus, Prometheus, and Grafana.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.