private SimpleTimer findTimer()

in geronimo-metrics/src/main/java/org/apache/geronimo/microprofile/metrics/cdi/SimplyTimedInterceptor.java [73:100]


    private SimpleTimer findTimer(final Executable executable) {
        if (timers == null) {
            synchronized (this) {
                if (timers == null) {
                    timers = new ConcurrentHashMap<>();
                }
            }
        }
        SimpleTimer timer = timers.get(executable);
        if (timer == null) {
            final AnnotatedType<?> type = beanManager.createAnnotatedType(bean.getBeanClass());
            final SimplyTimed timed = Stream.concat(type.getMethods().stream(), type.getConstructors().stream())
                    .filter(it -> it.getJavaMember().equals(executable))
                    .findFirst()
                    .map(m -> m.getAnnotation(SimplyTimed.class))
                    .orElse(null);
            final String name = Names.findName(
                    Modifier.isAbstract(executable.getDeclaringClass().getModifiers()) ? type.getJavaClass() : executable.getDeclaringClass(),
                    executable, timed == null ? null : timed.name(), timed != null && timed.absolute(),
                    ofNullable(extension.getAnnotation(type, SimplyTimed.class)).map(SimplyTimed::name).orElse(""));
            timer = registry.getSimpleTimer(new MetricID(name, extension.createTags(timed == null ? new String[0] : timed.tags())));
            if (timer == null) {
                throw new IllegalStateException("No timer with name [" + name + "] found in registry [" + registry + "]");
            }
            timers.putIfAbsent(executable, timer);
        }
        return timer;
    }