Interface MetricsService

All Known Implementing Classes:
NoopMetricsService, PrometheusMetricsService, SwitchingMetricsService

public interface MetricsService
Service for creating and managing metrics in system.

Use this service to create metrics in system. All metric created with this service will be automatically exposed and exported. Any metric created without using this service will not be properly exported.

  • Method Details

    • createCounter

      Counter createCounter(MetricSettings settings)
      Parameters:
      settings - metric settings
      Returns:
      new instance of Counter metric
    • createGauge

      Gauge createGauge(MetricSettings settings)
      Parameters:
      settings - metric settings
      Returns:
      new instance of Gauge metric
    • createHistogram

      Histogram createHistogram(HistogramSettings settings)
      Parameters:
      settings - metric settings
      Returns:
      new instance of Histogram metric
    • createInfo

      Info createInfo(MetricSettings settings)
      Parameters:
      settings - metric settings
      Returns:
      new instance of Info metric
    • closeMetric

      void closeMetric(BasicMetric metric)
      Close instance of metric.

      Closed metric are no longer exported as part of snapshot. They will still be part of exposed metrics, but they are not stored in snapshot nor exported to external systems. Closed metric will be included in the nearest snapshot.

      Parameters:
      metric - metric to close. Must be metric created by the same instance of MetricsService
    • snapshot

      MetricsSnapshot snapshot()
      Gets snapshot state of metrics active in current moment.
      Returns:
      snapshot of metrics state in current moment
    • sample

      Get last known state of all metrics in system.
      Returns:
      collection of last known samples of all metrics in system