public class CounterMetric extends Object
Most methods on this class will treat a non-existent counter as having a value of zero to allow implementations to lazily create metrics.
Most tests should use MetricGetter
to create instances of this class.
Constructor and Description |
---|
CounterMetric(MetricRegistryProxy registry,
org.eclipse.microprofile.metrics.MetricID metricId) |
Modifier and Type | Method and Description |
---|---|
void |
baseline()
Capture the current counter value for later comparison with
delta() |
Optional<org.eclipse.microprofile.metrics.Counter> |
counter()
Return the actual
Counter object for the metric, if it exists. |
long |
delta()
Return the difference between the current value of the metric and the value when
baseline was called. |
long |
value()
Get the counter value, or zero if the metric doesn't exist
|
public CounterMetric(MetricRegistryProxy registry, org.eclipse.microprofile.metrics.MetricID metricId)
public long value()
This method will not create the metric if it does not exist.
public void baseline()
delta()
This method will not create the metric if it does not exist.
public long delta()
baseline
was called.public Optional<org.eclipse.microprofile.metrics.Counter> counter()
Counter
object for the metric, if it exists.Optional
containing the Counter
, or an empty Optional
if the metric does not
exist.Copyright © 2016 – 2022 Eclipse Foundation. All rights reserved.
Use is subject to license terms.