Class CounterMetric
java.lang.Object
org.eclipse.microprofile.fault.tolerance.tck.metrics.util.CounterMetric
Allows tests to get the value of a counter and compare it with a baseline.
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 Summary
ConstructorsConstructorDescriptionCounterMetric(MetricRegistryProxy registry, org.eclipse.microprofile.metrics.MetricID metricId) -
Method Summary
Modifier and TypeMethodDescriptionvoidbaseline()Capture the current counter value for later comparison withdelta()Optional<org.eclipse.microprofile.metrics.Counter>counter()Return the actualCounterobject for the metric, if it exists.longdelta()Return the difference between the current value of the metric and the value whenbaselinewas called.longvalue()Get the counter value, or zero if the metric doesn't exist
-
Constructor Details
-
CounterMetric
public CounterMetric(MetricRegistryProxy registry, org.eclipse.microprofile.metrics.MetricID metricId)
-
-
Method Details
-
value
public long value()Get the counter value, or zero if the metric doesn't existThis method will not create the metric if it does not exist.
- Returns:
- the counter value, or zero if the metric doesn't exist
-
baseline
public void baseline()Capture the current counter value for later comparison withdelta()This method will not create the metric if it does not exist.
-
delta
public long delta()Return the difference between the current value of the metric and the value whenbaselinewas called.- Returns:
- the difference between the metric value and the baseline
-
counter
Return the actualCounterobject for the metric, if it exists.- Returns:
- an
Optionalcontaining theCounter, or an emptyOptionalif the metric does not exist.
-