Package com.yahoo.metrics.simple
Class MetricReceiver
java.lang.Object
com.yahoo.metrics.simple.MetricReceiver
- Direct Known Subclasses:
MetricReceiver.MockReceiver
The reception point for measurements. This is the class users should inject
in constructors for declaring instances of
Counter
and Gauge
for the actual measurement of metrics.- Author:
- Steinar Knutsen
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMetricReceiver
(com.yahoo.concurrent.ThreadLocalDirectory<Bucket, Sample> metricsCollection, AtomicReference<Bucket> currentSnapshot) -
Method Summary
Modifier and TypeMethodDescriptiondeclareCounter
(String name) Declare a counter metric without setting any default position.declareCounter
(String name, Point boundDimensions) Declare a counter metric, with default dimension values as given.declareGauge
(String name) Declare a gauge metric with any default position.declareGauge
(String name, Point boundDimensions) Declare a gauge metric, with default dimension values as given.declareGauge
(String name, Optional<Point> boundDimensions, MetricSettings customSettings) Declare a gauge metric, with default dimension values as given.Fetch the latest metric values, aggregated over all threads for the configured sample history (by default five minutes).Create a PointBuilder instance with no default settings.void
Update a metric.
-
Field Details
-
nullImplementation
-
-
Constructor Details
-
MetricReceiver
public MetricReceiver(com.yahoo.concurrent.ThreadLocalDirectory<Bucket, Sample> metricsCollection, AtomicReference<Bucket> currentSnapshot)
-
-
Method Details
-
update
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
Declare a counter metric without setting any default position.- Parameters:
name
- the name of the metric- Returns:
- a thread-safe counter
-
declareCounter
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
Declare a gauge metric with any default position.- Parameters:
name
- the name of the metric- Returns:
- a thread-safe gauge instance
-
declareGauge
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(String name, 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
Create a PointBuilder instance with no default settings. PointBuilder instances are not thread-safe.- Returns:
- an "empty" point builder instance
-
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
-