use of fish.payara.microprofile.metrics.impl.MetricRegistryImpl in project Payara by payara.
the class BulkheadLifecycleTckTest method createService.
@Override
protected FaultToleranceServiceStub createService() {
// this test needs to use more advanced state per method as multiple methods are involved
// therefore the below special setup where we have state per method as in the actual implementation
final Map<Object, AtomicReference<BlockingQueue<Thread>>> concurrentExecutionByMethodId = new ConcurrentHashMap<>();
final Map<Object, AtomicInteger> waitingQueuePopulationByMethodId = new ConcurrentHashMap<>();
registry = new MetricRegistryImpl(Type.BASE);
return new FaultToleranceServiceStub() {
@Override
protected FaultToleranceMethodContext stubMethodContext(StubContext ctx) {
FaultToleranceMetrics metrics = new MethodFaultToleranceMetrics(registry, FaultToleranceUtils.getCanonicalMethodName(ctx.context));
return new FaultToleranceMethodContextStub(ctx, state, concurrentExecutionByMethodId.computeIfAbsent(ctx.key, key -> new AtomicReference<>()), waitingQueuePopulationByMethodId.computeIfAbsent(ctx.key, key -> new AtomicInteger())) {
@Override
public FaultToleranceMetrics getMetrics() {
return metrics;
}
@Override
public Future<?> runDelayed(long delayMillis, Runnable task) throws Exception {
return CompletableFuture.completedFuture(null);
}
};
}
};
}
use of fish.payara.microprofile.metrics.impl.MetricRegistryImpl in project Payara by payara.
the class MetricsService method getOrAddRegistry.
/**
* Returns the Metrics registry based on respective registry name,
* if not available then add the new MetricRegistry instance
*
* @param registryName
* @return
*/
public MetricRegistry getOrAddRegistry(String registryName) {
MetricRegistry registry = REGISTRIES.get(registryName.toLowerCase());
if (registry == null) {
registry = new MetricRegistryImpl();
final MetricRegistry raced = REGISTRIES.putIfAbsent(registryName.toLowerCase(), registry);
if (raced != null) {
registry = raced;
}
}
return registry;
}
Aggregations