@Override public AggregateTimer requestLatencyTimer() { return new AggregateTimer(requestLatency, applicationMetrics.requestLatencyTimer()); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof io.netty.handler.codec.http.HttpRequest) { requestLatencyTiming = originStats.requestLatencyTimer().time(); } super.write(ctx, msg, promise); }
private void updateHttpResponseCounters(int statusCode) { if (statusIsServerError(statusCode)) { originStats.requestError(); } else { originStats.requestSuccess(); } originStats.responseWithStatusCode(statusCode); }
private void stopAndRecordLatency() { // Should only be null in unit tests, // but this check is also here just in case there is some weird bug, we should not interfere with the proxying // just because it doesn't record metrics if (requestLatencyTiming != null) { requestLatencyTiming.stopAndRecord(); } else { LOG.warn("Attempted to stop timer and record latency when no timing had begun"); } } }
public Stopper time() { return new Stopper(requestLatency.time(), applicationLatency.time()); } }
.doOnUnsubscribe(() -> { if (!completed.get()) { originStatsFactory.originStats(host.origin()).requestCancelled();
private void updateHttpResponseCounters(int statusCode) { if (statusIsServerError(statusCode)) { originStats.requestError(); } else { originStats.requestSuccess(); } originStats.responseWithStatusCode(statusCode); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof io.netty.handler.codec.http.HttpRequest) { requestLatencyTiming = originStats.requestLatencyTimer().time(); } super.write(ctx, msg, promise); }
@Override public AggregateTimer requestLatencyTimer() { return new AggregateTimer(requestLatency, applicationMetrics.requestLatencyTimer()); }
private void stopAndRecordLatency() { // Should only be null in unit tests, // but this check is also here just in case there is some weird bug, we should not interfere with the proxying // just because it doesn't record metrics if (requestLatencyTiming != null) { requestLatencyTiming.stopAndRecord(); } else { LOG.warn("Attempted to stop timer and record latency when no timing had begun"); } } }
public Stopper time() { return new Stopper(requestLatency.time(), applicationLatency.time()); } }
private Publisher<LiveHttpResponse> sendRequest(LiveHttpRequest request, List<RemoteHost> previousOrigins, int attempt) { if (attempt >= MAX_RETRY_ATTEMPTS) { return Flux.error(new NoAvailableHostsException(this.id)); } Optional<RemoteHost> remoteHost = selectOrigin(request); if (remoteHost.isPresent()) { RemoteHost host = remoteHost.get(); List<RemoteHost> newPreviousOrigins = newArrayList(previousOrigins); newPreviousOrigins.add(remoteHost.get()); return ResponseEventListener.from(host.hostClient().handle(request, HttpInterceptorContext.create()) .map(response -> addStickySessionIdentifier(response, host.origin()))) .whenResponseError(cause -> logError(request, cause)) .whenCancelled(() -> originStatsFactory.originStats(host.origin()).requestCancelled()) .apply() .doOnNext(this::recordErrorStatusMetrics) .map(response -> removeUnexpectedResponseBody(request, response)) .map(this::removeRedundantContentLengthHeader) .onErrorResume(cause -> { RetryPolicyContext retryContext = new RetryPolicyContext(this.id, attempt + 1, cause, request, previousOrigins); return retry(request, retryContext, newPreviousOrigins, attempt + 1, cause); }) .map(response -> addOriginId(host.id(), response)); } else { RetryPolicyContext retryContext = new RetryPolicyContext(this.id, attempt + 1, null, request, previousOrigins); return retry(request, retryContext, previousOrigins, attempt + 1, new NoAvailableHostsException(this.id)); } }