@Override public void collectAndPublish(SessionContext context) { // Request timings. long totalRequestTime = context.getTimings().getRequest().getDuration(); long requestProxyTime = context.getTimings().getRequestProxy().getDuration(); int originReportedDuration = context.getOriginReportedDuration(); // Approximation of time spent just within Zuul's own processing of the request. long totalInternalTime = totalRequestTime - requestProxyTime; // Approximation of time added to request by addition of Zuul+NIWS // (ie. the time added compared to if ELB sent request direct to Origin). // if -1, means we don't have that metric. long totalTimeAddedToOrigin = -1; if (originReportedDuration > -1) { totalTimeAddedToOrigin = totalRequestTime - originReportedDuration; } // Publish final String METRIC_TIMINGS_REQ_PREFIX = "zuul.timings.request."; recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "total", totalRequestTime); recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "proxy", requestProxyTime); recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "internal", totalInternalTime); recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "added", totalTimeAddedToOrigin); }
@Override public void collectAndPublish(SessionContext context) { // Request timings. long totalRequestTime = context.getTimings().getRequest().getDuration(); long requestProxyTime = context.getTimings().getRequestProxy().getDuration(); int originReportedDuration = context.getOriginReportedDuration(); // Approximation of time spent just within Zuul's own processing of the request. long totalInternalTime = totalRequestTime - requestProxyTime; // Approximation of time added to request by addition of Zuul+NIWS // (ie. the time added compared to if ELB sent request direct to Origin). // if -1, means we don't have that metric. long totalTimeAddedToOrigin = -1; if (originReportedDuration > -1) { totalTimeAddedToOrigin = totalRequestTime - originReportedDuration; } // Publish final String METRIC_TIMINGS_REQ_PREFIX = "zuul.timings.request."; recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "total", totalRequestTime); recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "proxy", requestProxyTime); recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "internal", totalInternalTime); recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "added", totalTimeAddedToOrigin); }
@Override public void collectAndPublish(SessionContext context) { // Request timings. long totalRequestTime = context.getTimings().getRequest().getDuration(); long requestProxyTime = context.getTimings().getRequestProxy().getDuration(); int originReportedDuration = context.getOriginReportedDuration(); // Approximation of time spent just within Zuul's own processing of the request. long totalInternalTime = totalRequestTime - requestProxyTime; // Approximation of time added to request by addition of Zuul+NIWS // (ie. the time added compared to if ELB sent request direct to Origin). // if -1, means we don't have that metric. long totalTimeAddedToOrigin = -1; if (originReportedDuration > -1) { totalTimeAddedToOrigin = totalRequestTime - originReportedDuration; } // Publish final String METRIC_TIMINGS_REQ_PREFIX = "zuul.timings.request."; recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "total", totalRequestTime); recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "proxy", requestProxyTime); recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "internal", totalInternalTime); recordRequestTiming(METRIC_TIMINGS_REQ_PREFIX + "added", totalTimeAddedToOrigin); }
request.getContext().getTimings().getRequest().start(); context.getTimings().getRequest().end();
request.getContext().getTimings().getRequest().start(); msg.getContext().getTimings().getRequest().end();
final Timing timing = ctx.getTimings().getRequestProxy(); timing.start(); if (stats != null)
Timing readTiming = context.getTimings().getRequestBodyRead(); readTiming.start(); requestBuiltObs.finallyDo(() -> readTiming.end() ); final Timing timing = context.getTimings().getRequestProxy(); timing.start(); Observable<HttpResponseMessage> responseObs = requestBuiltObs.map(httpClientRequest -> {
@Override public void handle(HttpResponseMessage response) { HttpRequestMessage request = response.getRequest(); SessionContext context = response.getContext(); long duration = context.getTimings().getRequest().getDuration(); int responseBodySize = response.getBody() == null ? 0 : response.getBody().length; // Write to access log. accessLogPublisher.publish(new SimpleAccessRecord(LocalDateTime.now(), response.getStatus(), request.getMethod(), request.getPathAndQuery(), duration, responseBodySize, request.getHeaders(), response.getHeaders() )); // Publish request-level metrics. if (requestMetricsPublisher != null) { requestMetricsPublisher.collectAndPublish(context); } } }