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 voidaddToHistogram(String metric, long duration, org.eclipse.microprofile.metrics.Tag... tags)Histogram:FaultToleranceMetricsboundTo(FaultToleranceMethodContext context, FaultTolerancePolicy policy)The first thread calling creates the metrics all thread calling the same method work with.FaultToleranceMetrics.FallbackUsagegetFallbackUsage()voidincrementCounter(String metric, org.eclipse.microprofile.metrics.Tag... tags)Counters:voidincrementFallbackCallsTotal()voidincrementRetryRetriesTotal()The number of times the method was retriedbooleanisRetried()voidregister(String metric, String unit, LongSupplier gauge, String... tag)Gauge registration:voidregister(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. Theregisteredis still anAtomicBooleanso that a state change affects otherMethodFaultToleranceMetricsinstances for the same method that were created in the meantime as well.- Specified by:
boundToin interfaceFaultToleranceMetrics- Returns:
- a instance on the basis of this
FaultToleranceMetricsthat 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:FaultToleranceMetricsRegistration: Registers a metric for each permutation of the tags. Infers unit from type.- Specified by:
registerin 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:FaultToleranceMetricsGauge registration:- Specified by:
registerin 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:FaultToleranceMetricsCounters:- Specified by:
incrementCounterin interfaceFaultToleranceMetrics- Parameters:
metric- full name of the metric with%sused as placeholder for the method nametags- all tags to add for the metric except themethodtag (which is added later internally)
-
addToHistogram
public void addToHistogram(String metric, long duration, org.eclipse.microprofile.metrics.Tag... tags)
Description copied from interface:FaultToleranceMetricsHistogram:- Specified by:
addToHistogramin interfaceFaultToleranceMetrics- Parameters:
metric- full name of the metric with%sused as placeholder for the method nameduration- amount of nanoseconds to add to the histogram (>= 0)tags- all tags to add for the metric except themethodtag (which is added later internally)
-
getFallbackUsage
public FaultToleranceMetrics.FallbackUsage getFallbackUsage()
- Specified by:
getFallbackUsagein interfaceFaultToleranceMetrics- Returns:
- How fallback was involved in the current execution of the method
-
incrementFallbackCallsTotal
public void incrementFallbackCallsTotal()
- Specified by:
incrementFallbackCallsTotalin interfaceFaultToleranceMetrics
-
incrementRetryRetriesTotal
public void incrementRetryRetriesTotal()
Description copied from interface:FaultToleranceMetricsThe number of times the method was retried- Specified by:
incrementRetryRetriesTotalin interfaceFaultToleranceMetrics
-
isRetried
public boolean isRetried()
- Specified by:
isRetriedin interfaceFaultToleranceMetrics- Returns:
- true if
FaultToleranceMetrics.incrementRetryRetriesTotal()has been called at least once, otherwise false
-
-