org.apache.ignite.spi.metric

## Interface ReadOnlyMetricRegistry

- All Superinterfaces:
    Iterable<Metric>

      public interface ReadOnlyMetricRegistry
      extends Iterable<Metric>

  Read only metric registry.

  ## Java example

  See the example below of how the internal metrics can be obtained through your application using `ReadOnlyMetricRegistry`.

       JmxMetricExporterSpi jmxSpi = new JmxMetricExporterSpi();

       Ignite ignite = Ignition.start(new IgniteConfiguration()
           .setDataStorageConfiguration(new DataStorageConfiguration()
               .setDefaultDataRegionConfiguration(
                   new DataRegionConfiguration()
                       .setMaxSize(12_000_000)))
           .setIgniteInstanceName("jmxExampleInstanceName")
           .setMetricExporterSpi(jmxSpi));

       ReadOnlyMetricRegistry ioReg = jmxSpi.getSpiContext().getOrCreateMetricRegistry("io.dataregion.default");

       Set listOfMetrics = StreamSupport.stream(ioReg.spliterator(), false)
           .map(Metric::name)
           .collect(toSet());

       System.out.println("The list of available data region metrics: " + listOfMetrics);
       System.out.println("The 'default' data region MaxSize: " + ioReg.findMetric("MaxSize"));

  See Also:
    `JmxMetricExporterSpi`, `MetricExporterSpi`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `<M extends Metric> M` | `findMetric(String name)`
    `String` | `name()`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, iterator, spliterator`

- - ### Method Detail

    - #### name

          String name()

      Returns:
        Registry name.

    - #### findMetric

          @Nullable
          <M extends Metric> M findMetric(String name)

      Type Parameters:
        `M` - Type of the metric.
      Parameters:
        `name` - Name of the metric.
      Returns:
        Metric with specified name if exists. Null otherwise.

${current.year} Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.16.0
Release Date | : December 15 2023