Package org.eclipse.microprofile.fault.tolerance.tck.telemetryMetrics.util

# Class TelemetryMetricGetter

java.lang.Object
org.eclipse.microprofile.fault.tolerance.tck.telemetryMetrics.util.TelemetryMetricGetter

public class TelemetryMetricGetter 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
Description
`TelemetryMetricGetter(Class<?> clazz, String methodName)`

## Method Summary

Modifier and Type
Method
Description
`void`
`baselineMetrics()`
Calls `baseline()` on all relevant metrics.
`TelemetryCounterMetric`
`getBulkheadCalls(TelemetryMetricDefinition.BulkheadResult bulkheadResult)`
`TelemetryGaugeMetric`
`getBulkheadExecutionsRunning()`
`TelemetryGaugeMetric`
`getBulkheadExecutionsWaiting()`
`TelemetryHistogramMetric`
`getBulkheadRunningDuration()`
`TelemetryHistogramMetric`
`getBulkheadWaitingDuration()`
`TelemetryCounterMetric`
`getCircuitBreakerCalls(TelemetryMetricDefinition.CircuitBreakerResult cbResult)`
`TelemetryCounterMetric`
`getCircuitBreakerOpened()`
`TelemetryCounterMetric`
`getCircuitBreakerState(TelemetryMetricDefinition.CircuitBreakerState cbState)`
`TelemetryCounterMetric`
`getInvocations(TelemetryMetricDefinition.InvocationResult result, TelemetryMetricDefinition.InvocationFallback fallbackUsed)`
`TelemetryCounterMetric`
`getRetryCalls(TelemetryMetricDefinition.RetryRetried retried, TelemetryMetricDefinition.RetryResult result)`
`TelemetryCounterMetric`
`getRetryRetries()`
`static final TelemetryMetricDefinition.AttributeValue[][]`
`getTagCombinations(Class<? extends TelemetryMetricDefinition.AttributeValue>... tagValueClazzes)`
Computes all possible values for a set of tags.
`TelemetryCounterMetric`
`getTimeoutCalls(TelemetryMetricDefinition.TimeoutTimedOut timedOut)`
`TelemetryHistogramMetric`
`getTimeoutExecutionDuration()`

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

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

## Constructor Details

### TelemetryMetricGetter

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

## Method Details

### getInvocations

public TelemetryCounterMetric getInvocations(TelemetryMetricDefinition.InvocationResult result, TelemetryMetricDefinition.InvocationFallback fallbackUsed)

### getRetryCalls

public TelemetryCounterMetric getRetryCalls(TelemetryMetricDefinition.RetryRetried retried, TelemetryMetricDefinition.RetryResult result)

### getRetryRetries

public TelemetryCounterMetric getRetryRetries()

### getTimeoutCalls

public TelemetryCounterMetric getTimeoutCalls(TelemetryMetricDefinition.TimeoutTimedOut timedOut)

### getTimeoutExecutionDuration

public TelemetryHistogramMetric getTimeoutExecutionDuration()

### getCircuitBreakerCalls

public TelemetryCounterMetric getCircuitBreakerCalls(TelemetryMetricDefinition.CircuitBreakerResult cbResult)

### getCircuitBreakerOpened

public TelemetryCounterMetric getCircuitBreakerOpened()

### getCircuitBreakerState

public TelemetryCounterMetric getCircuitBreakerState(TelemetryMetricDefinition.CircuitBreakerState cbState)

### getBulkheadCalls

public TelemetryCounterMetric getBulkheadCalls(TelemetryMetricDefinition.BulkheadResult bulkheadResult)

### getBulkheadExecutionsRunning

public TelemetryGaugeMetric getBulkheadExecutionsRunning()

### getBulkheadExecutionsWaiting

public TelemetryGaugeMetric getBulkheadExecutionsWaiting()

### getBulkheadRunningDuration

public TelemetryHistogramMetric getBulkheadRunningDuration()

### getBulkheadWaitingDuration

public TelemetryHistogramMetric getBulkheadWaitingDuration()

### baselineMetrics

public void baselineMetrics()
Calls `baseline()` on all relevant metrics.

Extracts all of the `Counter` and `Gauge` metrics from `TelemetryMetricDefinition` and calls `TelemetryCounterMetric.baseline()` or `TelemetryGaugeMetric.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 TelemetryMetricDefinition.AttributeValue[][] getTagCombinations(Class<? extends TelemetryMetricDefinition.AttributeValue>... 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 `TelemetryMetricID`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