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)); } }