use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.
the class BulkheadMetricTckTest method bulkheadMetricAsyncTest.
/**
* Scenario is equivalent to the TCK test of same name but not 100% identical
*/
@Test(timeout = 3000)
public void bulkheadMetricAsyncTest() {
callMethodWithNewThreadAndWaitFor(commonWaiter);
callMethodWithNewThreadAndWaitFor(commonWaiter);
waitUntilPermitsAquired(2, 0);
callMethodWithNewThreadAndWaitFor(commonWaiter);
callMethodWithNewThreadAndWaitFor(commonWaiter);
waitUntilPermitsAquired(2, 2);
assertFurtherThreadThrowsBulkheadException(1);
commonWaiter.complete(null);
waitUntilPermitsAquired(0, 0);
String methodName = "fish.payara.microprofile.faulttolerance.policy.BulkheadMetricTckTest.bulkheadMetricAsyncTest_Method";
Counter successfulInvocations = registry.getCounter(new MetricID("ft.invocations.total", new Tag("method", methodName), new Tag("fallback", "notDefined"), new Tag("result", "valueReturned")));
Counter failedInvocations = registry.getCounter(new MetricID("ft.invocations.total", new Tag("method", methodName), new Tag("fallback", "notDefined"), new Tag("result", "exceptionThrown")));
assertEquals(4, successfulInvocations.getCount());
assertEquals(1, failedInvocations.getCount());
}
use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.
the class BulkheadMetricTckTest method bulkheadMetricRejectionTest.
/**
* Scenario is equivalent to the TCK test of same name but not 100% identical
*/
@Test(timeout = 3000)
public void bulkheadMetricRejectionTest() {
callMethodWithNewThreadAndWaitFor(commonWaiter);
callMethodWithNewThreadAndWaitFor(commonWaiter);
waitUntilPermitsAquired(2, 0);
assertFurtherThreadThrowsBulkheadException(1);
commonWaiter.complete(null);
waitUntilPermitsAquired(0, 0);
String methodName = "fish.payara.microprofile.faulttolerance.policy.BulkheadMetricTckTest.bulkheadMetricRejectionTest_Method";
@SuppressWarnings("unchecked") Gauge<Long> excutionsRunning = (Gauge<Long>) registry.getGauge(new MetricID("ft.bulkhead.executionsRunning", new Tag("method", methodName)));
assertNotNull(excutionsRunning);
assertEquals(0, excutionsRunning.getValue().intValue());
Counter acceptedCalls = registry.getCounter(new MetricID("ft.bulkhead.calls.total", new Tag("method", methodName), new Tag("bulkheadResult", "accepted")));
assertNotNull(acceptedCalls);
assertEquals(2, acceptedCalls.getCount());
Counter rejectedCalls = registry.getCounter(new MetricID("ft.bulkhead.calls.total", new Tag("method", methodName), new Tag("bulkheadResult", "rejected")));
assertNotNull(rejectedCalls);
assertEquals(1, rejectedCalls.getCount());
}
use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.
the class MetricUtils method getGauge.
@SuppressWarnings("unchecked")
private static Gauge<?> getGauge(MetricRegistry registry, String name, Tag[] tags) {
MetricID metricID = new MetricID(name, tags);
Gauge<?> gauge = registry.getGauges().get(metricID);
return gauge != null ? gauge : new LazyGauge<>(() -> registry.getGauges().get(metricID));
}
Aggregations