-
Notifications
You must be signed in to change notification settings - Fork 41.2k
MetricsWebFilter assigns UNKNOWN outcome to 200 OK responses #19367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can confirm this behaviour is present in spring boot 2.2.2 |
The behaviour looks to be caused by the following method: Line 145 in b15e427
There is a discrepancy between how the status code is resolved for the status code tag how it is resolved for the outcome tag. |
In spring-projects/spring-framework#21901, we can see that the I'm wondering if Lines 137 to 141 in bb3b6db
@rstoyanchev do you think we should rely at all on |
I think you could update private static Integer extractStatusCode(ServerWebExchange exchange) {
ServerHttpResponse response = exchange.getResponse();
Integer statusCode = null;
if (response instanceof AbstractServerHttpResponse) {
statusCode = ((AbstractServerHttpResponse) response).getStatusCodeValue();
}
if (statusCode == null) {
HttpStatus httpStatus = response.getStatusCode();
statusCode = (httpStatus != null ? httpStatus.value() : null);
}
return statusCode;
} |
Thanks Rossen, we'll switch from |
@rstoyanchev @bclozel I'm trying to understand why the above snippet is better than what we currently have. Is there any situation where an |
@mbhave maybe what you're missing is the fact that getStatusCode() is overridden in sub-classes which fall back on the underlying server default. In short the situation is whenever the status code is not explicitly set. |
ah, I see what you mean now. Thanks @rstoyanchev. |
This commit also changed the default outcome to SUCCESS Fixes spring-projectsgh-19367
Note that with spring-projects/spring-framework#24400 |
This commit also changes Spring Framework version to 5.2.4.BUILD-SNAPSHOT for the necessary upstream change. See spring-projects#19367 (comment)
I created #19987 to apply the upstream change. |
This commit also changes Spring Framework version to 5.2.4.BUILD-SNAPSHOT for the necessary upstream change. See spring-projects#19367 (comment)
If REST controller doesn't explicitly set status code (so it defaults to 200 OK),
MetricsWebFilter
will setoutcome
tag toUNKNOWN
instead ofSUCCESS
.Example application to reproduce:
The text was updated successfully, but these errors were encountered: