Class MethodFaultToleranceMetrics
- java.lang.Object
-
- fish.payara.microprofile.faulttolerance.service.MethodFaultToleranceMetrics
-
- All Implemented Interfaces:
FaultToleranceMetrics
public final class MethodFaultToleranceMetrics extends Object implements FaultToleranceMetrics
- Author:
- Jan Bernitt
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface fish.payara.microprofile.faulttolerance.FaultToleranceMetrics
FaultToleranceMetrics.FallbackUsage
-
-
Field Summary
-
Fields inherited from interface fish.payara.microprofile.faulttolerance.FaultToleranceMetrics
DISABLED, NO_TAGS
-
-
Constructor Summary
Constructors Constructor Description MethodFaultToleranceMetrics(org.eclipse.microprofile.metrics.MetricRegistry registry, String canonicalMethodName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToHistogram(String metric, long duration, org.eclipse.microprofile.metrics.Tag... tags)
Histogram:FaultToleranceMetrics
boundTo(FaultToleranceMethodContext context, FaultTolerancePolicy policy)
The first thread calling creates the metrics all thread calling the same method work with.FaultToleranceMetrics.FallbackUsage
getFallbackUsage()
void
incrementCounter(String metric, org.eclipse.microprofile.metrics.Tag... tags)
Counters:void
incrementFallbackCallsTotal()
void
incrementRetryRetriesTotal()
The number of times the method was retriedboolean
isRetried()
void
register(String metric, String unit, LongSupplier gauge, String... tag)
Gauge registration:void
register(org.eclipse.microprofile.metrics.MetricType type, String metric, String[]... tagsPermutations)
Registration: Registers a metric for each permutation of the tags.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fish.payara.microprofile.faulttolerance.FaultToleranceMetrics
addBulkheadExecutionDuration, addBulkheadWaitingDuration, addTimeoutExecutionDuration, addToHistogram, incrementBulkheadCallsAcceptedTotal, incrementBulkheadCallsRejectedTotal, incrementCircuitbreakerCallsFailedTotal, incrementCircuitbreakerCallsPreventedTotal, incrementCircuitbreakerCallsSucceededTotal, incrementCircuitbreakerOpenedTotal, incrementCounter, incrementInvocationsExceptionThrown, incrementInvocationsValueReturned, incrementRetryCallsExceptionNotRetryable, incrementRetryCallsMaxDurationReached, incrementRetryCallsMaxRetriesReached, incrementRetryCallsValueReturned, incrementTimeoutCallsNotTimedOutTotal, incrementTimeoutCallsTimedOutTotal
-
-
-
-
Constructor Detail
-
MethodFaultToleranceMetrics
public MethodFaultToleranceMetrics(org.eclipse.microprofile.metrics.MetricRegistry registry, String canonicalMethodName)
-
-
Method Detail
-
boundTo
public FaultToleranceMetrics boundTo(FaultToleranceMethodContext context, FaultTolerancePolicy policy)
The first thread calling creates the metrics all thread calling the same method work with. Other threads have to wait until these metrics actually exist. The easiest to make that happen was to make this method synchronised. Theregistered
is still anAtomicBoolean
so that a state change affects otherMethodFaultToleranceMetrics
instances for the same method that were created in the meantime as well.- Specified by:
boundTo
in interfaceFaultToleranceMetrics
- Returns:
- a instance on the basis of this
FaultToleranceMetrics
that is properly adopted to the provided context and policy. This can be the same instance if no change is required or a new one if a change of internal state is required. As part of binding to the context and policy this method also should register all metrics that make sense for the provided policy in case this has not been done already.
-
register
public void register(org.eclipse.microprofile.metrics.MetricType type, String metric, String[]... tagsPermutations)
Description copied from interface:FaultToleranceMetrics
Registration: Registers a metric for each permutation of the tags. Infers unit from type.- Specified by:
register
in interfaceFaultToleranceMetrics
- Parameters:
type
-MetricType.COUNTER
(assumes no unit) orMetricType.HISTOGRAM
(assumesMetricUnits.NANOSECONDS
)metric
- name of the metric(s)tagsPermutations
- tag name and possible values
-
register
public void register(String metric, String unit, LongSupplier gauge, String... tag)
Description copied from interface:FaultToleranceMetrics
Gauge registration:- Specified by:
register
in interfaceFaultToleranceMetrics
- Parameters:
metric
- name of the gauge metricunit
- unit of the gauge metric (null isMetricUnits.NONE
)gauge
- a supplier function for the gaugetag
- tag name and value if the gauge uses a tag
-
incrementCounter
public void incrementCounter(String metric, org.eclipse.microprofile.metrics.Tag... tags)
Description copied from interface:FaultToleranceMetrics
Counters:- Specified by:
incrementCounter
in interfaceFaultToleranceMetrics
- Parameters:
metric
- full name of the metric with%s
used as placeholder for the method nametags
- all tags to add for the metric except themethod
tag (which is added later internally)
-
addToHistogram
public void addToHistogram(String metric, long duration, org.eclipse.microprofile.metrics.Tag... tags)
Description copied from interface:FaultToleranceMetrics
Histogram:- Specified by:
addToHistogram
in interfaceFaultToleranceMetrics
- Parameters:
metric
- full name of the metric with%s
used as placeholder for the method nameduration
- amount of nanoseconds to add to the histogram (>= 0)tags
- all tags to add for the metric except themethod
tag (which is added later internally)
-
getFallbackUsage
public FaultToleranceMetrics.FallbackUsage getFallbackUsage()
- Specified by:
getFallbackUsage
in interfaceFaultToleranceMetrics
- Returns:
- How fallback was involved in the current execution of the method
-
incrementFallbackCallsTotal
public void incrementFallbackCallsTotal()
- Specified by:
incrementFallbackCallsTotal
in interfaceFaultToleranceMetrics
-
incrementRetryRetriesTotal
public void incrementRetryRetriesTotal()
Description copied from interface:FaultToleranceMetrics
The number of times the method was retried- Specified by:
incrementRetryRetriesTotal
in interfaceFaultToleranceMetrics
-
isRetried
public boolean isRetried()
- Specified by:
isRetried
in interfaceFaultToleranceMetrics
- Returns:
- true if
FaultToleranceMetrics.incrementRetryRetriesTotal()
has been called at least once, otherwise false
-
-