org.eclipse.microprofile.fault.tolerance.tck.metrics.util

## Class GaugeMetric

- java.lang.Object
- - org.eclipse.microprofile.fault.tolerance.tck.metrics.util.GaugeMetric

    public class GaugeMetric
    extends Object

Allows tests to get the value of a `Gauge<Long>` and compare it with a baseline.

Most methods on this class will treat a non-existent gauge 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

Constructors
Constructor and Description
`GaugeMetric(MetricRegistryProxy registry, org.eclipse.microprofile.metrics.MetricID metricId)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `baseline()` Capture the current counter value for later comparison with `delta()`
`long` `delta()` Return the difference between the current value of the metric and the value when `baseline` was called.
`Optional<org.eclipse.microprofile.metrics.Gauge<Long>>` `gauge()` Return the actual `Counter` object for the metric, if it exists.
`long` `value()` Get the counter value, or zero if the metric doesn't exist

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GaugeMetric

    public GaugeMetric(MetricRegistryProxy registry,
                       org.eclipse.microprofile.metrics.MetricID metricId)

### Method Detail

#### value

    public long value()

Get the counter value, or zero if the metric doesn't exist

This 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 with `delta()`

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 when `baseline` was called.

Returns:
  the difference between the metric value and the baseline

#### gauge

    public Optional<org.eclipse.microprofile.metrics.Gauge<Long>> gauge()

Return the actual `Counter` object for the metric, if it exists.

Returns:
  an `Optional` containing the `Counter`, or an empty `Optional` if the metric does not exist.