Class MultiGauge

java.lang.Object
io.micrometer.core.instrument.MultiGauge

@Incubating(since="1.1.0") public class MultiGauge extends Object
A virtual meter that manages a dynamic set of gauges with a common name and common tags.

A MultiGauge is not itself a Meter; it creates and removes individual Gauge meters as rows are registered. Each row contributes unique tags and a value function. Re-registering rows reconciles the gauges currently managed by this instance with the supplied rows.

Since:
1.1.0
  • Method Details

    • builder

      public static MultiGauge.Builder builder(String name)
      Parameters:
      name - The gauge's name.
      Returns:
      A new gauge builder.
    • register

      public void register(Iterable<? extends MultiGauge.Row<?>> rows)
      Register rows for this multi-gauge without replacing rows that have already been registered with the same tags. Rows that are no longer present are removed.
      Parameters:
      rows - rows to register
    • register

      public void register(Iterable<? extends MultiGauge.Row<?>> rows, boolean overwrite)
      Register rows for this multi-gauge.

      Each row is registered as a gauge using this multi-gauge's common name and tags, combined with the row's unique tags, after applying any configured MeterFilters.

      • Previously registered rows that are no longer present in rows are removed from the registry.
      • When overwrite is true, existing gauges are updated to track the new row values. If multiple rows in rows resolve to the same meter ID (either directly or after filter transformations), the last row in iteration order takes precedence.
      • When overwrite is false, previously registered rows are left unchanged. If multiple rows in rows resolve to the same meter ID, the first row in iteration order takes precedence.

      Note: If a MeterFilter removes or modifies tags such that multiple rows share the same mapped tags, those rows will contend for the same single gauge.

      Parameters:
      rows - rows to register
      overwrite - whether to update previously registered rows and overwrite duplicate rows within the batch