in geronimo-metrics/src/main/java/org/apache/geronimo/microprofile/metrics/cdi/CountedInterceptor.java [79:110]
private Meta findCounter(final Executable executable) {
if (counters == null) {
synchronized (this) {
if (counters == null) {
counters = new ConcurrentHashMap<>();
}
}
}
Meta meta = counters.get(executable);
if (meta == null) {
final AnnotatedType<?> type = beanManager.createAnnotatedType(bean.getBeanClass());
final Counted counted = Stream.concat(type.getMethods().stream(), type.getConstructors().stream())
.filter(it -> it.getJavaMember().equals(executable))
.findFirst()
.map(m -> m.getAnnotation(Counted.class))
.orElse(null);
final String name = Names.findName(
Modifier.isAbstract(executable.getDeclaringClass().getModifiers()) ? type.getJavaClass() : executable.getDeclaringClass(),
executable, counted == null ? null : counted.name(),
counted != null && counted.absolute(),
ofNullable(extension.getAnnotation(type, Counted.class)).map(Counted::name).orElse(""));
final Counter counter = registry.getCounter(
new MetricID(name, extension.createTags(counted == null ? new String[0] : counted.tags())));
if (counter == null) {
throw new IllegalStateException("No counter with name [" + name + "] found in registry [" + registry + "]");
}
meta = new Meta(counter);
counters.putIfAbsent(executable, meta);
}
return meta;
}