Package com.yahoo.metrics.simple
Class MetricReceiver
- java.lang.Object
-
- com.yahoo.metrics.simple.MetricReceiver
-
- Direct Known Subclasses:
MetricReceiver.MockReceiver
@Beta public class MetricReceiver extends java.lang.Object
The reception point for measurements. This is the class users should inject in constructors for declaring instances ofCounter
andGauge
for the actual measurement of metrics.- Author:
- Steinar Knutsen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MetricReceiver.MockReceiver
-
Field Summary
Fields Modifier and Type Field Description static MetricReceiver
nullImplementation
-
Constructor Summary
Constructors Constructor Description MetricReceiver(com.yahoo.concurrent.ThreadLocalDirectory<Bucket,Sample> metricsCollection, java.util.concurrent.atomic.AtomicReference<Bucket> currentSnapshot)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Counter
declareCounter(java.lang.String name)
Declare a counter metric without setting any default position.Counter
declareCounter(java.lang.String name, Point boundDimensions)
Declare a counter metric, with default dimension values as given.Gauge
declareGauge(java.lang.String name)
Declare a gauge metric with any default position.Gauge
declareGauge(java.lang.String name, Point boundDimensions)
Declare a gauge metric, with default dimension values as given.Gauge
declareGauge(java.lang.String name, java.util.Optional<Point> boundDimensions, MetricSettings customSettings)
Declare a gauge metric, with default dimension values as given.Bucket
getSnapshot()
Fetch the latest metric values, aggregated over all threads for the configured sample history (by default five minutes).PointBuilder
pointBuilder()
Create a PointBuilder instance with no default settings.void
update(Sample sample)
Update a metric.
-
-
-
Field Detail
-
nullImplementation
public static final MetricReceiver nullImplementation
-
-
Method Detail
-
update
public void update(Sample sample)
Update a metric. This API is not intended for clients for the simplemetrics API, declare a Counter or a Gauge usingdeclareCounter(String)
,declareCounter(String, Point)
,declareGauge(String)
, ordeclareGauge(String, Point)
instead.- Parameters:
sample
- a single simple containing all meta data necessary to update a metric
-
declareCounter
public Counter declareCounter(java.lang.String name)
Declare a counter metric without setting any default position.- Parameters:
name
- the name of the metric- Returns:
- a thread-safe counter
-
declareCounter
public Counter declareCounter(java.lang.String name, Point boundDimensions)
Declare a counter metric, with default dimension values as given. Create the point argument by using a builder frompointBuilder()
.- Parameters:
name
- the name of the metricboundDimensions
- dimensions which have a fixed value in the life cycle of the metric object or null- Returns:
- a thread-safe counter with given default values
-
declareGauge
public Gauge declareGauge(java.lang.String name)
Declare a gauge metric with any default position.- Parameters:
name
- the name of the metric- Returns:
- a thread-safe gauge instance
-
declareGauge
public Gauge declareGauge(java.lang.String name, Point boundDimensions)
Declare a gauge metric, with default dimension values as given. Create the point argument by using a builder frompointBuilder()
.- Parameters:
name
- the name of the metricboundDimensions
- dimensions which have a fixed value in the life cycle of the metric object or null- Returns:
- a thread-safe gauge metric
-
declareGauge
public Gauge declareGauge(java.lang.String name, java.util.Optional<Point> boundDimensions, MetricSettings customSettings)
Declare a gauge metric, with default dimension values as given. Create the point argument by using a builder frompointBuilder()
. MetricSettings instances are built usingMetricSettings.Builder
.- Parameters:
name
- the name of the metricboundDimensions
- an optional of dimensions which have a fixed value in the life cycle of the metric objectcustomSettings
- any optional settings- Returns:
- a thread-safe gauge metric
-
pointBuilder
public PointBuilder pointBuilder()
Create a PointBuilder instance with no default settings. PointBuilder instances are not thread-safe.- Returns:
- an "empty" point builder instance
-
getSnapshot
public Bucket getSnapshot()
Fetch the latest metric values, aggregated over all threads for the configured sample history (by default five minutes). The values will be less than 1 second old, and this method has only a memory barrier as side effect.- Returns:
- the latest five minutes of metrics
-
-