Class MicrometerMetrics

java.lang.Object
com.jsgalactic.axiom.micrometer.MicrometerMetrics
All Implemented Interfaces:
Metrics

public final class MicrometerMetrics extends Object implements Metrics
Maps the dependency-free Metrics SPI to an application-owned Micrometer MeterRegistry. Counters become Micrometer counters, gauges become gauges backed by an AtomicLong, and timers become Micrometer timers whose service-level objectives are DEFAULT_BUCKETS, the bounds of the in-memory registry in axiom-metrics.

Micrometer publishes through whatever registry and exporters the application installs, so this adapter adds no renderer, Prometheus endpoint, StatsD client or JMX bridge. One instrument is registered per name and tag set and reused by later lookups; a name always has one kind and one set of tag keys, and using it otherwise throws IllegalArgumentException. Instances are thread-safe and can be shared across requests.

Tag values stay the caller's responsibility: Axiom's runtime tags only with route templates, methods and other fixed sets. The adapter does not truncate values or bound cardinality; use a registry filter when untrusted tags are possible.

  • Field Details

    • DEFAULT_BUCKETS

      public static final List<Duration> DEFAULT_BUCKETS
      Timer service-level objectives: 1 ms, 5 ms, 10 ms, 25 ms, 50 ms, 100 ms, 250 ms, 500 ms, 1 s, 2.5 s, 5 s and 10 s. They match the buckets of MetricsRegistry.DEFAULT_BUCKETS.
  • Method Details

    • create

      public static MicrometerMetrics create(io.micrometer.core.instrument.MeterRegistry registry)
      Creates an adapter that registers instruments in the supplied registry. The registry's lifecycle, naming conventions, filters and exporters remain the application's responsibility.
      Parameters:
      registry - meter registry that owns the instruments
      Returns:
      an empty adapter
    • counter

      public Metrics.Counter counter(String name, String... tags)
      Description copied from interface: Metrics
      Returns the monotonically increasing counter for a series, creating it if needed.
      Specified by:
      counter in interface Metrics
      Parameters:
      name - dotted lowercase metric name
      tags - alternating tag keys and values, possibly none
      Returns:
      a thread-safe counter; never null
    • gauge

      public Metrics.Gauge gauge(String name, String... tags)
      Description copied from interface: Metrics
      Returns the gauge for a series, creating it if needed. A gauge is a value that moves both ways, such as a queue depth. It is changed by deltas, so several components can share one series and the value stays the sum of their contributions.
      Specified by:
      gauge in interface Metrics
      Parameters:
      name - dotted lowercase metric name
      tags - alternating tag keys and values, possibly none
      Returns:
      a thread-safe gauge; never null
    • timer

      public Metrics.Timer timer(String name, String... tags)
      Description copied from interface: Metrics
      Returns the timer for a series, creating it if needed. A timer records durations and keeps their distribution, so latency percentiles can be derived from it.
      Specified by:
      timer in interface Metrics
      Parameters:
      name - dotted lowercase metric name
      tags - alternating tag keys and values, possibly none
      Returns:
      a thread-safe timer; never null