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 Summary
Modifier and TypeMethodDescriptionvoid
closeMetric
(BasicMetric metric) Close instance of metric.createCounter
(MetricSettings settings) createGauge
(MetricSettings settings) createHistogram
(HistogramSettings settings) createInfo
(MetricSettings settings) sample()
Get last known state of all metrics in system.snapshot()
Gets snapshot state of metrics active in current moment.
-
Method Details
-
createCounter
- Parameters:
settings
- metric settings- Returns:
- new instance of
Counter
metric
-
createGauge
- Parameters:
settings
- metric settings- Returns:
- new instance of
Gauge
metric
-
createHistogram
- Parameters:
settings
- metric settings- Returns:
- new instance of
Histogram
metric
-
createInfo
- Parameters:
settings
- metric settings- Returns:
- new instance of
Info
metric
-
closeMetric
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 ofMetricsService
-
snapshot
MetricsSnapshot snapshot()Gets snapshot state of metrics active in current moment.- Returns:
- snapshot of metrics state in current moment
-
sample
Collection<MetricSamples> sample()Get last known state of all metrics in system.- Returns:
- collection of last known samples of all metrics in system
-