Class MetricGetter
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
Callsbaseline()
on all relevant metrics.getBulkheadCalls
(MetricDefinition.BulkheadResult bulkheadResult) Optional<org.eclipse.microprofile.metrics.Histogram>
Optional<org.eclipse.microprofile.metrics.Histogram>
getInvocations
(MetricDefinition.InvocationResult result, MetricDefinition.InvocationFallback fallbackUsed) getRetryCalls
(MetricDefinition.RetryRetried retried, MetricDefinition.RetryResult result) static final MetricDefinition.TagValue[][]
getTagCombinations
(Class<? extends MetricDefinition.TagValue>... tagValueClazzes) Computes all possible values for a set of tags.Optional<org.eclipse.microprofile.metrics.Histogram>
-
Constructor Details
-
MetricGetter
-
-
Method Details
-
getInvocations
public CounterMetric getInvocations(MetricDefinition.InvocationResult result, MetricDefinition.InvocationFallback fallbackUsed) -
getRetryCalls
public CounterMetric getRetryCalls(MetricDefinition.RetryRetried retried, MetricDefinition.RetryResult result) -
getRetryRetries
-
getTimeoutCalls
-
getTimeoutExecutionDuration
-
getCircuitBreakerCalls
-
getCircuitBreakerOpened
-
getCircuitBreakerState
-
getBulkheadCalls
-
getBulkheadExecutionsRunning
-
getBulkheadExecutionsWaiting
-
getBulkheadRunningDuration
-
getBulkheadWaitingDuration
-
baselineMetrics
public void baselineMetrics()Callsbaseline()
on all relevant metrics.Extracts all of the
Counter
andGauge
metrics fromMetricDefinition
and callsCounterMetric.baseline()
orGaugeMetric.baseline()
on them.This allows us to check how they've changed later in the test using the
CounterMetric.delta()
orGaugeMetric.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]
andbar=[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
-