Package com.yahoo.jdisc
Interface Metric
-
- All Known Implementing Classes:
MockMetric
public interface Metric
This interface provides an API for writing metric data to the configured
MetricConsumer
. If noProvider
for the MetricConsumer class has been bound by the application, all calls to this interface are no-ops. The implementation of this interface uses thread local consumer instances, so as long as theMetricConsumer
is thread-safe, so is this.An instance of this class can be injected anywhere.
- Author:
- Simon Thoresen Hult
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Metric.Context
Declares the interface for the arbitrary context object to pass to both theset(String, Number, Context)
andadd(String, Number, Context)
methods.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(java.lang.String key, java.lang.Number val, Metric.Context ctx)
Add to a metric value.Metric.Context
createContext(java.util.Map<java.lang.String,?> properties)
Creates aMetricConsumer
-specificMetric.Context
object that encapsulates the given properties.void
set(java.lang.String key, java.lang.Number val, Metric.Context ctx)
Set a metric value.
-
-
-
Method Detail
-
set
void set(java.lang.String key, java.lang.Number val, Metric.Context ctx)
Set a metric value. This is typically used with histogram-type metrics.- Parameters:
key
- The name of the metric to modify.val
- The value to assign to the named metric.ctx
- The context to further describe this entry.
-
add
void add(java.lang.String key, java.lang.Number val, Metric.Context ctx)
Add to a metric value. This is typically used with counter-type metrics.- Parameters:
key
- the name of the metric to modifyval
- the value to add to the named metricctx
- the context to further describe this entry
-
createContext
Metric.Context createContext(java.util.Map<java.lang.String,?> properties)
Creates aMetricConsumer
-specificMetric.Context
object that encapsulates the given properties. The returned Context object should be passed along every future call toset(String, Number, Context)
andadd(String, Number, Context)
where the properties match those given here.- Parameters:
properties
- the properties to incorporate in the context- Returns:
- the created context
-
-