Class TestInMemoryMetricsRegistry

java.lang.Object
org.opensearch.test.telemetry.TestInMemoryMetricsRegistry
All Implemented Interfaces:
Closeable, AutoCloseable, org.opensearch.telemetry.metrics.MetricsRegistry

public class TestInMemoryMetricsRegistry extends Object implements org.opensearch.telemetry.metrics.MetricsRegistry
This is a simple implementation of MetricsRegistry which can be utilized by Unit Tests. It just initializes and stores counters/histograms within a map, once created. The maps can then be used to get the counters/histograms by their names.
  • Constructor Details

    • TestInMemoryMetricsRegistry

      public TestInMemoryMetricsRegistry()
      Constructor.
  • Method Details

    • getCounterStore

      public ConcurrentHashMap<String, TestInMemoryCounter> getCounterStore()
      Returns counterStore
      Returns:
    • getHistogramStore

      public ConcurrentHashMap<String, TestInMemoryHistogram> getHistogramStore()
      Returns the histogramStore.
      Returns:
    • createCounter

      public org.opensearch.telemetry.metrics.Counter createCounter(String name, String description, String unit)
      Specified by:
      createCounter in interface org.opensearch.telemetry.metrics.MetricsRegistry
    • createUpDownCounter

      public org.opensearch.telemetry.metrics.Counter createUpDownCounter(String name, String description, String unit)
      Specified by:
      createUpDownCounter in interface org.opensearch.telemetry.metrics.MetricsRegistry
    • createHistogram

      public org.opensearch.telemetry.metrics.Histogram createHistogram(String name, String description, String unit)
      Specified by:
      createHistogram in interface org.opensearch.telemetry.metrics.MetricsRegistry
    • createGauge

      public Closeable createGauge(String name, String description, String unit, Supplier<Double> valueProvider, org.opensearch.telemetry.metrics.tags.Tags tags)
      Specified by:
      createGauge in interface org.opensearch.telemetry.metrics.MetricsRegistry
    • createGauge

      public Closeable createGauge(String name, String description, String unit, Supplier<org.opensearch.telemetry.metrics.TaggedMeasurement> value)
      Specified by:
      createGauge in interface org.opensearch.telemetry.metrics.MetricsRegistry
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException