@Singleton
public class MetricsManager
extends java.lang.Object
startReporting(String, Props) to
start reporting AZ metrics to remote metrics server.| Constructor and Description |
|---|
MetricsManager(com.codahale.metrics.MetricRegistry registry) |
| Modifier and Type | Method and Description |
|---|---|
com.codahale.metrics.Counter |
addCounter(java.lang.String name)
A
Counter is just a gauge for an AtomicLong instance. |
<T> void |
addGauge(java.lang.String name,
java.util.function.Supplier<T> gaugeFunc)
A
Gauge is an instantaneous reading of a particular value. |
com.codahale.metrics.Histogram |
addHistogram(java.lang.String name)
A
Histogram measures the statistical distribution of values in a stream of data. |
com.codahale.metrics.Meter |
addMeter(java.lang.String name)
A
Meter measures the rate of events over time (e.g., “requests per second”). |
com.codahale.metrics.Timer |
addTimer(java.lang.String name)
A
Timer measures both the rate that a particular piece of code is called and the
distribution of its duration. |
void |
startReporting(java.lang.String reporterName,
Props props)
reporting metrics to remote metrics collector.
|
@Inject public MetricsManager(com.codahale.metrics.MetricRegistry registry)
public com.codahale.metrics.Meter addMeter(java.lang.String name)
Meter measures the rate of events over time (e.g., “requests per second”).public <T> void addGauge(java.lang.String name,
java.util.function.Supplier<T> gaugeFunc)
Gauge is an instantaneous reading of a particular value. This method leverages
Supplier, a Functional Interface, to get Generics metrics values. With this support, no matter
what our interesting metrics is a Double or a Long, we could pass it to Metrics Parser.
E.g., in CommonMetrics#setupAllMetrics(), we construct a supplier lambda by having a
AtomicLong object and its get method, in order to collect dbConnection metric.public com.codahale.metrics.Counter addCounter(java.lang.String name)
Counter is just a gauge for an AtomicLong instance.public com.codahale.metrics.Histogram addHistogram(java.lang.String name)
Histogram measures the statistical distribution of values in a stream of data. In
addition to minimum, maximum, mean, etc., it also measures median, 75th,
90th, 95th, 98th, 99th, and 99.9th percentiles.public com.codahale.metrics.Timer addTimer(java.lang.String name)
Timer measures both the rate that a particular piece of code is called and the
distribution of its duration.public void startReporting(java.lang.String reporterName,
Props props)