当前位置: 首页>>代码示例>>Java>>正文


Java Timed类代码示例

本文整理汇总了Java中io.micrometer.core.annotation.Timed的典型用法代码示例。如果您正苦于以下问题:Java Timed类的具体用法?Java Timed怎么用?Java Timed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Timed类属于io.micrometer.core.annotation包,在下文中一共展示了Timed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: record

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
private void record(TimingSampleContext timingContext, HttpServletResponse response, HttpServletRequest request,
                    Object handlerObject, Throwable e) {
    for (Timed timedAnnotation : timingContext.timedAnnotations) {
        timingContext.timerSample.stop(Timer.builder(timedAnnotation, metricName)
            .tags(tagsProvider.httpRequestTags(request, response, handlerObject, e))
            .register(registry));
    }

    if(timingContext.timedAnnotations.isEmpty() && autoTimeRequests) {
        timingContext.timerSample.stop(Timer.builder(metricName)
            .tags(tagsProvider.httpRequestTags(request, response, handlerObject, e))
            .register(registry));
    }

    for (LongTaskTimer.Sample sample : timingContext.longTaskTimerSamples) {
        sample.stop();
    }
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:19,代码来源:MetricsFilter.java

示例2: annotations

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
private Set<Timed> annotations(RequestEvent event) {
    final Set<Timed> timed = new HashSet<>();

    final ResourceMethod matchingResourceMethod = event.getUriInfo().getMatchedResourceMethod();
    if (matchingResourceMethod != null) {
        // collect on method level
        timed.addAll(timedFinder.findTimedAnnotations(matchingResourceMethod.getInvocable().getHandlingMethod()));

        // fallback on class level
        if (timed.isEmpty()) {
            timed.addAll(timedFinder.findTimedAnnotations(matchingResourceMethod.getInvocable().getHandlingMethod()
                .getDeclaringClass()));
        }
    }
    return timed;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:17,代码来源:MetricsRequestEventListener.java

示例3: shortTimers

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
private Set<Timer> shortTimers(Set<Timed> timed, RequestEvent event) {
    /*
     * Given we didn't find any matching resource method, 404s will be only
     * recorded when auto-time-requests is enabled. On par with WebMVC
     * instrumentation.
     */
    if ((timed == null || timed.isEmpty()) && autoTimeRequests) {
        return Collections.singleton(registry.timer(metricName, tagsProvider.httpRequestTags(event)));
    }

    if(timed == null) {
        return Collections.emptySet();
    }

    return timed.stream()
        .map(t -> Timer.builder(t, metricName).tags(tagsProvider.httpRequestTags(event)).register(registry))
        .collect(Collectors.toSet());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:19,代码来源:MetricsRequestEventListener.java

示例4: builder

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
/**
 * Create a timer builder from a {@link Timed} annotation.
 *
 * @param timed The annotation instance to base a new timer on.
 */
static Builder builder(Timed timed) {
    if (!timed.longTask()) {
        throw new IllegalArgumentException("Cannot build a long task timer from a @Timed annotation that is not marked as a long task");
    }

    if (timed.value().isEmpty()) {
        throw new IllegalArgumentException("Long tasks instrumented with @Timed require the value attribute to be non-empty");
    }

    return new Builder(timed.value())
        .tags(timed.extraTags())
        .description(timed.description().isEmpty() ? null : timed.description());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:19,代码来源:LongTaskTimer.java

示例5: builder

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
/**
 * Create a timer builder from a {@link Timed} annotation.
 * @param timed The annotation instance to base a new timer on.
 * @param defaultName A default name to use in the event that the value attribute is empty.
 */
static Builder builder(Timed timed, String defaultName) {
    if (timed.longTask() && timed.value().isEmpty()) {
        // the user MUST name long task timers, we don't lump them in with regular
        // timers with the same name
        throw new IllegalArgumentException("Long tasks instrumented with @Timed require the value attribute to be non-empty");
    }

    return new Builder(timed.value().isEmpty() ? defaultName : timed.value())
        .tags(timed.extraTags())
        .description(timed.description().isEmpty() ? null : timed.description())
        .publishPercentileHistogram(timed.histogram())
        .publishPercentiles(timed.percentiles().length > 0 ? timed.percentiles() : null);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:19,代码来源:Timer.java

示例6: findTimedAnnotations

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
Set<Timed> findTimedAnnotations(AnnotatedElement element) {
    Timed t = annotationFinder.findAnnotation(element, Timed.class);
    if (t != null)
        return Collections.singleton(t);

    TimedSet ts = annotationFinder.findAnnotation(element, TimedSet.class);
    if (ts != null) {
        return Arrays.stream(ts.value()).collect(Collectors.toSet());
    }

    return Collections.emptySet();
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:13,代码来源:TimedFinder.java

示例7: onEvent

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
@Override
public void onEvent(RequestEvent event) {
    ContainerRequest containerRequest = event.getContainerRequest();
    Set<Timed> timedAnnotations;

    switch (event.getType()) {
        case ON_EXCEPTION:
            if(!(event.getException() instanceof NotFoundException)) {
                break;
            }
        case REQUEST_MATCHED:
            timedAnnotations = annotations(event);

            timedAnnotationsOnRequest.put(containerRequest, timedAnnotations);
            shortTaskSample.put(containerRequest, Timer.start(registry));

            List<LongTaskTimer.Sample> longTaskSamples = longTaskTimers(timedAnnotations, event).stream().map(LongTaskTimer::start).collect(Collectors.toList());
            if (!longTaskSamples.isEmpty()) {
                this.longTaskSamples.put(containerRequest, longTaskSamples);
            }
            break;
        case FINISHED:
            timedAnnotations = timedAnnotationsOnRequest.remove(containerRequest);
            Timer.Sample shortSample = shortTaskSample.remove(containerRequest);

            if (shortSample != null) {
                for (Timer timer : shortTimers(timedAnnotations, event)) {
                    shortSample.stop(timer);
                }
            }

            Collection<LongTaskTimer.Sample> longSamples = this.longTaskSamples.remove(containerRequest);
            if (longSamples != null) {
                for (LongTaskTimer.Sample longSample : longSamples) {
                    longSample.stop();
                }
            }
            break;
    }
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:41,代码来源:MetricsRequestEventListener.java

示例8: longTaskTimers

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
private Set<LongTaskTimer> longTaskTimers(Set<Timed> timed, RequestEvent event) {
    return timed.stream()
        .filter(Timed::longTask)
        .map(LongTaskTimer::builder)
        .map(b -> b.tags(tagsProvider.httpLongRequestTags(event)).register(registry))
        .collect(Collectors.toSet());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:8,代码来源:MetricsRequestEventListener.java

示例9: multiTimed

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
@GET
@Path("multi-timed")
@Timed("multi1")
@Timed("multi2")
public String multiTimed() {
    return "multi-timed";
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:8,代码来源:TimedResource.java

示例10: longTimed

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
@GET
@Path("long-timed")
@Timed
@Timed(value = "long.task.in.request", longTask = true)
public String longTimed() {
    longTaskRequestStartedLatch.countDown();
    try {
        longTaskRequestReleaseLatch.await();
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
    return "long-timed";
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:14,代码来源:TimedResource.java

示例11: longTimedUnnamed

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
@GET
@Path("long-timed-unnamed")
@Timed
@Timed(longTask = true)
public String longTimedUnnamed() {
    return "long-timed-unnamed";
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:8,代码来源:TimedResource.java

示例12: TimingSampleContext

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
TimingSampleContext(HttpServletRequest request, Object handlerObject) {
    timedAnnotations = annotations(handlerObject);
    timerSample = Timer.start(registry);
    longTaskTimerSamples = timedAnnotations.stream()
        .filter(Timed::longTask)
        .map(t -> LongTaskTimer.builder(t)
            .tags(tagsProvider.httpLongRequestTags(request, handlerObject))
            .register(registry)
            .start())
        .collect(Collectors.toList());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:12,代码来源:MetricsFilter.java

示例13: annotations

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
private Set<Timed> annotations(Object handler) {
    if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Set<Timed> timed = TimedUtils.findTimedAnnotations(handlerMethod.getMethod());
        if (timed.isEmpty()) {
            return TimedUtils.findTimedAnnotations(handlerMethod.getBeanType());
        }
        return timed;
    }
    return Collections.emptySet();
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:12,代码来源:MetricsFilter.java

示例14: findTimedAnnotations

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
public static Set<Timed> findTimedAnnotations(AnnotatedElement element) {
    Timed t = AnnotationUtils.findAnnotation(element, Timed.class);
    if (t != null)
        return Collections.singleton(t);

    TimedSet ts = AnnotationUtils.findAnnotation(element, TimedSet.class);
    if (ts != null) {
        return Arrays.stream(ts.value()).collect(Collectors.toSet());
    }

    return Collections.emptySet();
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:13,代码来源:TimedUtils.java

示例15: longBeep

import io.micrometer.core.annotation.Timed; //导入依赖的package包/类
@Timed(value = "long.beep", longTask = true)
@Scheduled(fixedDelay = 100_000)
void longBeep() throws InterruptedException {
    longTaskStarted.countDown();
    longTaskShouldComplete.await();
    System.out.println("beep");
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:8,代码来源:ScheduledMethodMetricsTest.java


注:本文中的io.micrometer.core.annotation.Timed类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。