.tag(FluxMetrics.TAG_STATUS, FluxMetrics.TAGVALUE_ON_COMPLETE) .tag(FluxMetrics.TAG_EXCEPTION, "") .description("Times the duration elapsed between a subscription and the onComplete termination of the sequence") .register(registry); this.subscribeToCancelTimer = Timer .tag(FluxMetrics.TAG_STATUS, FluxMetrics.TAGVALUE_CANCEL) .tag(FluxMetrics.TAG_EXCEPTION, "") .description("Times the duration elapsed between a subscription and the cancellation of the sequence") .register(registry); .tags(commonTags) .tag(FluxMetrics.TAG_STATUS, FluxMetrics.TAGVALUE_ON_ERROR) .description("Times the duration elapsed between a subscription and the onError termination of the sequence, with the exception name as a tag."); this.subscribeToErrorTimerFactory = e -> { return subscribeToErrorTimerBuilder
.tag(TAG_STATUS, TAGVALUE_ON_COMPLETE) .tag(TAG_EXCEPTION, "") .description("Times the duration elapsed between a subscription and the onComplete termination of the sequence") .register(registry); this.subscribeToCancelTimer = Timer .tag(TAG_STATUS, TAGVALUE_CANCEL) .tag(TAG_EXCEPTION, "") .description("Times the duration elapsed between a subscription and the cancellation of the sequence") .register(registry); .tags(commonTags) .tag(TAG_STATUS, TAGVALUE_ON_ERROR) .description("Times the duration elapsed between a subscription and the onError termination of the sequence, with the exception name as a tag"); this.subscribeToErrorTimerFactory = e -> { return subscribeToErrorTimerBuilder .builder(METER_ON_NEXT_DELAY) .tags(commonTags) .description("Measures delays between onNext signals (or between onSubscribe and first onNext)") .register(registry);
private Timer.Builder getTimeBuilder(HttpRequest request, ClientHttpResponse response) { return Timer.builder(this.metricName) .tags(this.tagProvider.getTags(urlTemplate.get(), request, response)) .description("Timer of RestTemplate operation"); }
private void time(MethodInvocation invocation, long startTime, Exception exception) { Timer .builder(THRIFT_REQUEST_DURATION_METRIC) .publishPercentileHistogram() .description("Thrift handler request duration") .tags( "handler", invocation.getThis().getClass().getCanonicalName(), "method", invocation.getMethod().getName(), "status", exception == null ? "ok" : exception.getClass().getCanonicalName() ) .register(meterRegistry) .record(System.nanoTime() - startTime, TimeUnit.NANOSECONDS); } }
/** * Creates a new timer builder for the given method. * * @param method The method the timer will be created for. * @param name The name of the timer to use. * @param description The description of the timer to use. * @return The newly created timer builder. */ public static Timer.Builder prepareTimerFor(final MethodDescriptor<?, ?> method, final String name, final String description) { return Timer.builder(name) .description(description) .tag(TAG_SERVICE_NAME, extractServiceName(method)) .tag(TAG_METHOD_NAME, extractMethodName(method)); }
private Timer.Builder getTimeBuilder(HttpServerExchange exchange) { return Timer.builder(metricName) .tags(this.getTags(exchange)) .description("Response time histogram") .publishPercentileHistogram(); }
private Timer.Builder getTransitionTimerBuilder(Transition<S, E> transition) { String transitionName = transitionToName(transition); Timer.Builder builder = Timer.builder("ssm.transition.duration") .tags("transitionName", transitionName) .description("Timer of Transition"); builder.publishPercentileHistogram(); return builder; }
private Timer.Builder getTimeBuilder(@Nullable String urlTemplate, HttpRequest request, @Nullable ClientHttpResponse response) { return Timer.builder(this.metricName) .tags(this.tagProvider.getTags(urlTemplate, request, response)) .description("Timer of RestTemplate operation"); } }
@Override public MicroTimerBuilder description(String desc) { this.builder.description(desc); return this; }
private Timer.Builder getTimerBuilder(MethodProceedingJoinPoint methodProceedingJoinPoint, Throwable throwable) { return Timer.builder(format(METRIC_NAME, getComponentType())) .tags(createTags(methodProceedingJoinPoint, throwable)) .description(format("Timer of %s operations", getComponentType())); }
public MicrometerTimer(MeterRegistry meterRegistry, MetricId id) { super(id); timer = io.micrometer.core.instrument.Timer.builder(id.getName()) .description(id.getDescription()) .tags(id.getTags().stream().map(tag -> Tag.of(tag.getKey(), tag.getValue())) .collect(Collectors.toList())) .publishPercentiles(0.5, 0.75, 0.98, 0.99, 0.999) .register(meterRegistry); }
@Override public void nodeProcessingDone() { super.nodeProcessingDone(); Timer timer = Timer.builder(namingStrategy.getName(route, getNode())) .tags(namingStrategy.getTags(route, getNode())) .description(getNode().getDescriptionText()) .register(meterRegistry); sample.stop(timer); }
public Timer get(String... values) { // Get or create the Timer return Timer.builder(name) .description(description) .tags(Labels.toTags(keys, values)) .register(registry); }
private Timer.Builder getActionTimerBuilder(Action<S, E> action) { String actionName = actionToName(action); Timer.Builder builder = Timer.builder("ssm.action.duration") .tags("actionName", actionName) .description("Timer of Action"); builder.publishPercentileHistogram(); return builder; }
public void onExchangeDone(Exchange exchange) { Timer.Sample sample = (Timer.Sample) exchange.removeProperty(propertyName(exchange)); if (sample != null) { Timer timer = Timer.builder(namingStrategy.getName(route)) .tags(namingStrategy.getTags(route, exchange)) .description(route.getDescription()) .register(meterRegistry); sample.stop(timer); } }
@Override public Mono<ClientResponse> filter(ClientRequest clientRequest, ExchangeFunction exchangeFunction) { return exchangeFunction.exchange(clientRequest).doOnEach((signal) -> { if (!signal.isOnComplete()) { Long startTime = signal.getContext().get(METRICS_WEBCLIENT_START_TIME); ClientResponse clientResponse = signal.get(); Throwable throwable = signal.getThrowable(); Iterable<Tag> tags = this.tagProvider.tags(clientRequest, clientResponse, throwable); Timer.builder(this.metricName).tags(tags) .description("Timer of WebClient operation") .register(this.meterRegistry) .record(System.nanoTime() - startTime, TimeUnit.NANOSECONDS); } }).subscriberContext((context) -> context.put(METRICS_WEBCLIENT_START_TIME, System.nanoTime())); }
/** * Creates a new timer builder for the given method. * * @param method The method the timer will be created for. * @param name The name of the timer to use. * @param description The description of the timer to use. * @return The newly created timer builder. */ public static Timer.Builder prepareTimerFor(final MethodDescriptor<?, ?> method, final String name, final String description) { return Timer.builder(name) .description(description) .tag(TAG_SERVICE_NAME, extractServiceName(method)) .tag(TAG_METHOD_NAME, extractMethodName(method)); }
@Override public MicroTimerBuilder description(String desc) { this.builder.description(desc); return this; }
.description("Connection acquire time") .tags(METRIC_CATEGORY, poolName) .register(meterRegistry); .description("Connection creation time") .tags(METRIC_CATEGORY, poolName) .register(meterRegistry); .description("Connection usage time") .tags(METRIC_CATEGORY, poolName) .register(meterRegistry);
public Sample start(MeterRegistry registry) { if (longTask) { LongTaskTimer.Sample sample = LongTaskTimer.builder(name) .description(description) .tags(tags) .register(registry) .start(); return () -> sample.stop(); } Timer.Sample sample = Timer.start(registry); Timer timer = Timer.builder(name) .description(description) .tags(tags) .publishPercentileHistogram(histogram) .publishPercentiles(percentiles) .register(registry); return () -> sample.stop(timer); }