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

## Class MetricGetter

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

    public class MetricGetter
    extends Object

Retrieves metrics for a specific method

The MetricGetter facilitates testing of metrics by providing helper methods for retrieving metrics defined by the faulttolerance spec for a specific class and method name.

This class will never create a metric which does not already exist.

### Constructor Summary

Constructors
Constructor and Description
`MetricGetter(Class<?> clazz, String methodName)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `baselineMetrics()` Calls `baseline()` on all relevant metrics.
`CounterMetric` `getBulkheadCalls(MetricDefinition.BulkheadResult bulkheadResult)`
`GaugeMetric` `getBulkheadExecutionsRunning()`
`GaugeMetric` `getBulkheadExecutionsWaiting()`
`Optional<org.eclipse.microprofile.metrics.Histogram>` `getBulkheadRunningDuration()`
`Optional<org.eclipse.microprofile.metrics.Histogram>` `getBulkheadWaitingDuration()`
`CounterMetric` `getCircuitBreakerCalls(MetricDefinition.CircuitBreakerResult cbResult)`
`CounterMetric` `getCircuitBreakerOpened()`
`GaugeMetric` `getCircuitBreakerState(MetricDefinition.CircuitBreakerState cbState)`
`CounterMetric` `getInvocations(MetricDefinition.InvocationResult result, MetricDefinition.InvocationFallback fallbackUsed)`
`CounterMetric` `getRetryCalls(MetricDefinition.RetryRetried retried, MetricDefinition.RetryResult result)`
`CounterMetric` `getRetryRetries()`
`static MetricDefinition.TagValue[][]` `getTagCombinations(Class<? extends MetricDefinition.TagValue>... tagValueClazzes)` Computes all possible values for a set of tags.
`CounterMetric` `getTimeoutCalls(MetricDefinition.TimeoutTimedOut timedOut)`
`Optional<org.eclipse.microprofile.metrics.Histogram>` `getTimeoutExecutionDuration()`

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

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

### Constructor Detail

#### MetricGetter

    public MetricGetter(Class<?> clazz,
                        String methodName)

### Method Detail

#### getInvocations

    public CounterMetric getInvocations(MetricDefinition.InvocationResult result,
                                        MetricDefinition.InvocationFallback fallbackUsed)

#### getRetryCalls

    public CounterMetric getRetryCalls(MetricDefinition.RetryRetried retried,
                                       MetricDefinition.RetryResult result)

#### getRetryRetries

    public CounterMetric getRetryRetries()

#### getTimeoutCalls

    public CounterMetric getTimeoutCalls(MetricDefinition.TimeoutTimedOut timedOut)

#### getTimeoutExecutionDuration

    public Optional<org.eclipse.microprofile.metrics.Histogram> getTimeoutExecutionDuration()

#### getCircuitBreakerCalls

    public CounterMetric getCircuitBreakerCalls(MetricDefinition.CircuitBreakerResult cbResult)

#### getCircuitBreakerOpened

    public CounterMetric getCircuitBreakerOpened()

#### getCircuitBreakerState

    public GaugeMetric getCircuitBreakerState(MetricDefinition.CircuitBreakerState cbState)

#### getBulkheadCalls

    public CounterMetric getBulkheadCalls(MetricDefinition.BulkheadResult bulkheadResult)

#### getBulkheadExecutionsRunning

    public GaugeMetric getBulkheadExecutionsRunning()

#### getBulkheadExecutionsWaiting

    public GaugeMetric getBulkheadExecutionsWaiting()

#### getBulkheadRunningDuration

    public Optional<org.eclipse.microprofile.metrics.Histogram> getBulkheadRunningDuration()

#### getBulkheadWaitingDuration

    public Optional<org.eclipse.microprofile.metrics.Histogram> getBulkheadWaitingDuration()

#### baselineMetrics

    public void baselineMetrics()

Calls `baseline()` on all relevant metrics.

Extracts all of the `Counter` and `Gauge` metrics from `MetricDefinition` and calls `CounterMetric.baseline()` or `GaugeMetric.baseline()` on them.

This allows us to check how they've changed later in the test using the `CounterMetric.delta()` or `GaugeMetric.delta()` methods, without having to explicitly baseline every metric ourselves up front.

#### getTagCombinations

    @SafeVarargs
    public static final MetricDefinition.TagValue[][] getTagCombinations(Class<? extends MetricDefinition.TagValue>... tagValueClazzes)

Computes all possible values for a set of tags.

Given an array of TagValue enums, this method find every combination of values from across this set of tags.

For example, if we had two tags `foo=[a|b]` and `bar=[x|y]`, this method would return

     [[foo=a, bar=x],
      [foo=a, bar=y],
      [foo=b, bar=x],
      [foo=b, bar=y]]

We can use this to iterate across all of the `MetricID`s which could be created for a metric which has multiple tags.

If called with no arguments, this method returns an array containing an empty array (indicating the only possible combination the the one with no tag values at all).

Parameters:
  `tagValueClazzes` - the set of tags
Returns:
  every possible combination when taking one value for each of the given tags