public class MetricGetter extends Object
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 and Description |
---|
MetricGetter(Class<?> clazz,
String methodName) |
public CounterMetric getInvocations(MetricDefinition.InvocationResult result, MetricDefinition.InvocationFallback fallbackUsed)
public CounterMetric getRetryCalls(MetricDefinition.RetryRetried retried, MetricDefinition.RetryResult result)
public CounterMetric getRetryRetries()
public CounterMetric getTimeoutCalls(MetricDefinition.TimeoutTimedOut timedOut)
public Optional<org.eclipse.microprofile.metrics.Histogram> getTimeoutExecutionDuration()
public CounterMetric getCircuitBreakerCalls(MetricDefinition.CircuitBreakerResult cbResult)
public CounterMetric getCircuitBreakerOpened()
public GaugeMetric getCircuitBreakerState(MetricDefinition.CircuitBreakerState cbState)
public CounterMetric getBulkheadCalls(MetricDefinition.BulkheadResult bulkheadResult)
public GaugeMetric getBulkheadExecutionsRunning()
public GaugeMetric getBulkheadExecutionsWaiting()
public Optional<org.eclipse.microprofile.metrics.Histogram> getBulkheadRunningDuration()
public Optional<org.eclipse.microprofile.metrics.Histogram> getBulkheadWaitingDuration()
public void baselineMetrics()
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.
@SafeVarargs public static final MetricDefinition.TagValue[][] getTagCombinations(Class<? extends MetricDefinition.TagValue>... tagValueClazzes)
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).
tagValueClazzes
- the set of tagsCopyright © 2020 Eclipse Foundation. All rights reserved.