@Override @Nullable public T poll() { if (qs == null) { return null; } try { T v = qs.poll(); if (v == null && this.mode == SYNC) { //this is also a complete event this.subscribeToTerminateSample.stop(subscribeToCompleteTimer); } return v; } catch (Throwable e) { //register a timer for that particular exception Timer timer = subscribeToErrorTimerFactory.apply(e); //record error termination this.subscribeToTerminateSample.stop(timer); throw e; } }
@Override public void onError(Throwable e) { if (done) { this.malformedSourceCounter.increment(); Operators.onErrorDropped(e, actual.currentContext()); return; } done = true; //register a timer for that particular exception Timer timer = subscribeToErrorTimerFactory.apply(e); //record error termination this.subscribeToTerminateSample.stop(timer); actual.onError(e); }
private void endTimerInner(ServerWebExchange exchange, Sample sample) { String outcome = "CUSTOM"; String status = "CUSTOM"; HttpStatus statusCode = exchange.getResponse().getStatusCode(); if (statusCode != null) { outcome = statusCode.series().name(); status = statusCode.name(); } else { // a non standard HTTPS status could be used. Let's be defensive here if (exchange.getResponse() instanceof AbstractServerHttpResponse) { Integer statusInt = ((AbstractServerHttpResponse) exchange.getResponse()) .getStatusCodeValue(); if (statusInt != null) { status = String.valueOf(statusInt); } else { status = "NA"; } } } Route route = exchange.getAttribute(GATEWAY_ROUTE_ATTR); Tags tags = Tags.of("outcome", outcome, "status", status, "routeId", route.getId(), "routeUri", route.getUri().toString()); if (log.isTraceEnabled()) { log.trace("Stopping timer 'gateway.requests' with tags " + tags); } sample.stop(meterRegistry.timer("gateway.requests", tags)); } }
private void on(final State to) { final State from = state.getAndSet(to); final Sample last = sample.getAndSet(start(registry)); if (from != CLOSED) { last.stop(registry.timer(metricName, tags(from))); } }
@SuppressWarnings("unchecked") @Override public void stop(TimerFacade timer) { this.sample.stop(((AbstractMeter<Timer>) timer).getMeter()); }
@Override public void cancel() { this.subscribeToTerminateSample.stop(subscribeToCancelTimer); s.cancel(); } }
@Override public void onComplete() { if (done) { this.malformedSourceCounter.increment(); return; } done = true; //we don't record the time between last onNext and onComplete, // because it would skew the onNext count by one this.subscribeToTerminateSample.stop(subscribeToCompleteTimer); actual.onComplete(); }
private void stop(Timer.Sample timerSample, Supplier<Iterable<Tag>> tags, Builder builder) { timerSample.stop(builder.tags(tags.get()).register(this.registry)); }
@Override public void close(final Status status, final Metadata responseHeaders) { this.timerSample.stop(this.timerFunction.apply(status.getCode())); super.close(status, responseHeaders); }
@Override public void onClose(final Status status, final Metadata metadata) { this.timerSample.stop(this.timerFunction.apply(status.getCode())); super.onClose(status, metadata); }
@SuppressWarnings("unchecked") @Override public void stop(TimerFacade timer) { this.sample.stop(((AbstractMeter<Timer>) timer).getMeter()); }
@Override @Nullable public T poll() { if (qs == null) { return null; } try { T v = qs.poll(); if (v == null && fusionMode == SYNC) { //this is also a complete event this.subscribeToTerminateSample.stop(subscribeToCompleteTimer); } if (v != null) { //this is an onNext event //record the delay since previous onNext/onSubscribe. This also records the count. long last = this.lastNextEventNanos; this.lastNextEventNanos = clock.monotonicTime(); this.onNextIntervalTimer.record(lastNextEventNanos - last, TimeUnit.NANOSECONDS); } return v; } catch (Throwable e) { //register a timer for that particular exception Timer timer = subscribeToErrorTimerFactory.apply(e); //record error termination this.subscribeToTerminateSample.stop(timer); throw e; } }
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); }
@Override public void onError(Throwable e) { if (done) { this.malformedSourceCounter.increment(); Operators.onErrorDropped(e, actual.currentContext()); return; } done = true; //we don't record the time between last onNext and onError, // because it would skew the onNext count by one //register a timer for that particular exception Timer timer = subscribeToErrorTimerFactory.apply(e); //record error termination this.subscribeToTerminateSample.stop(timer); actual.onError(e); }
@Benchmark public int sumTimedWithSample() { Timer.Sample sample = Timer.start(registry); int sum = sum(); sample.stop(timer); return sum; }
@Override public void cancel() { //we don't record the time between last onNext and cancel, // because it would skew the onNext count by one this.subscribeToTerminateSample.stop(subscribeToCancelTimer); s.cancel(); } }
@Override public void onComplete() { if (done) { this.malformedSourceCounter.increment(); return; } done = true; //we don't record the time between last onNext and onComplete, // because it would skew the onNext count by one this.subscribeToTerminateSample.stop(subscribeToCompleteTimer); actual.onComplete(); }
@Override public void onComplete() { if (done) { this.malformedSourceCounter.increment(); return; } done = true; this.subscribeToTerminateSample.stop(subscribeToCompleteTimer); actual.onComplete(); }
@Override public void cancel() { this.subscribeToTerminateSample.stop(subscribeToCancelTimer); s.cancel(); } }