Package org.apache.sling.commons.metrics
Interface MetricsService
@ProviderType
public interface MetricsService
The
MetricsService
enables creation of various types of Metric
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final MetricsService
Dummy variant of MetricsService which does not collect any metric -
Method Summary
Modifier and TypeMethodDescription<A> A
Adapts the service to the specified type.Creates a newCounter
and registers it under the given name.<T> Gauge<T>
Creates a newGauge
and registers it under the given name.Creates a newHistogram
and registers it under the given name.Creates a newMeter
and registers it under the given name.Creates a newTimer
and registers it under the given name.boolean
unregister
(String name) Unregister a metric by its name
-
Field Details
-
NOOP
Dummy variant of MetricsService which does not collect any metric
-
-
Method Details
-
timer
Creates a newTimer
and registers it under the given name. If a timer with same name exists then same instance is returned- Parameters:
name
- the name of the metric- Returns:
- a new
Timer
-
histogram
Creates a newHistogram
and registers it under the given name. If a histogram with same name exists then same instance is returned.- Parameters:
name
- the name of the metric- Returns:
- a new
Histogram
-
counter
Creates a newCounter
and registers it under the given name. If a counter with same name exists then same instance is returned- Parameters:
name
- the name of the metric- Returns:
- a new
Counter
-
meter
Creates a newMeter
and registers it under the given name. If a meter with same name exists then same instance is returned- Parameters:
name
- the name of the metric- Returns:
- a new
Meter
-
gauge
Creates a newGauge
and registers it under the given name. If a gauge with teh same exists already the the same instance is returned.- Type Parameters:
T
- the type of the metric- Parameters:
name
- the name of the gaugesupplier
- provides the values which are returned by the gauge- Returns:
- the gauge
-
adaptTo
Adapts the service to the specified type. This can be used to get instance to underlyingMetricRegistry
- Type Parameters:
A
- The type to which this metric is to be adapted.- Parameters:
type
- Class object for the type to which this metric is to be adapted.- Returns:
- The object, of the specified type, to which this metric has been adapted or null if this metric cannot be adapted to the specified type.
-
unregister
Unregister a metric by its name- Parameters:
name
- the name of the metric- Returns:
- true if the metric was correctly unregistered, false otherwise.
-