-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
http_server_requests metrics uri label shows up as "UNKNOWN" on gateway routes when using spring cloud gateway with spring boot release 2.1.3. This seems to have been introduced between spring boot 2.1.1 and 2.1.2 releases. Sample project here.
http_server_requests_seconds_count{exception="SSLHandshakeException",method="GET",outcome="SERVER_ERROR",status="500",uri="UNKNOWN",} 2.0
http_server_requests_seconds_sum{exception="SSLHandshakeException",method="GET",outcome="SERVER_ERROR",status="500",uri="UNKNOWN",} 1.022870125
Steps to reproduce:
- Clone repo
- Start Application
- curL http://localhost:8080/test-service/200 a couple of times
- Go to http://localhost:8080/actuator/prometheus
N.B. The curl command will result in 500 server errors due to separate https routing issue on gateway.
Digging a little deeper and it looks to be a problem with the WebFluxTags#uri() method. In 2.1.1 the method is:
public static Tag uri(ServerWebExchange exchange) {
PathPattern pathPattern = exchange
.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
if (pathPattern != null) {
return Tag.of("uri", pathPattern.getPatternString());
}
HttpStatus status = exchange.getResponse().getStatusCode();
if (status != null) {
if (status.is3xxRedirection()) {
return URI_REDIRECTION;
}
if (status == HttpStatus.NOT_FOUND) {
return URI_NOT_FOUND;
}
}
String path = exchange.getRequest().getPath().value();
if (path.isEmpty()) {
return URI_ROOT;
}
return Tag.of("uri", path);
}
where as in 2.1.3 the method is:
public static Tag uri(ServerWebExchange exchange) {
PathPattern pathPattern = exchange
.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
if (pathPattern != null) {
return Tag.of("uri", pathPattern.getPatternString());
}
HttpStatus status = exchange.getResponse().getStatusCode();
if (status != null) {
if (status.is3xxRedirection()) {
return URI_REDIRECTION;
}
if (status == HttpStatus.NOT_FOUND) {
return URI_NOT_FOUND;
}
}
String path = getPathInfo(exchange);
if (path.isEmpty()) {
return URI_ROOT;
}
return URI_UNKNOWN;
}
The default always returns URI_UNKNOWN despite path being not empty.