public interface Metric
This interface provides an API for writing metric data to the configured MetricConsumer
. If no Provider
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 the MetricConsumer
is
thread-safe, so is this.
An instance of this class can be injected anywhere.
Modifier and Type | Interface and Description |
---|---|
static interface |
Metric.Context
Declares the interface for the arbitrary context object to pass to both the
set(String, Number, Context) and add(String, Number, Context) methods. |
Modifier and Type | Method and Description |
---|---|
void |
add(String key,
Number val,
Metric.Context ctx)
Add to a metric value.
|
Metric.Context |
createContext(Map<String,?> properties)
Creates a
MetricConsumer -specific Metric.Context object that encapsulates the given properties. |
void |
set(String key,
Number val,
Metric.Context ctx)
Set a metric value.
|
void set(String key, Number val, Metric.Context ctx)
Set a metric value. This is typically used with histogram-type metrics.
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.void add(String key, Number val, Metric.Context ctx)
Add to a metric value. This is typically used with counter-type metrics.
key
- The name of the metric to modify.val
- The value to add to the named metric.ctx
- The context to further describe this entry.Metric.Context createContext(Map<String,?> properties)
Creates a MetricConsumer
-specific Metric.Context
object that encapsulates the given properties. The
returned Context object should be passed along every future call to set(String, Number, Context)
and
add(String, Number, Context)
where the properties match those given here.
properties
- The properties to incorporate in the context.Copyright © 2017. All rights reserved.