Commit 809a3965 authored by Brian Clozel's avatar Brian Clozel

Add missing outcome tag for WebClient metrics

On error cases, the "outcome" tag would be missing from recorded metrics
for the `WebClient`.

This commit fixes this issue and improves the reference documentation by
mentioning the tag values used for error cases, when the client response
is not received (I/O errors, client error, etc).

Fixes gh-17219
parent 82949b9c
......@@ -37,13 +37,9 @@ public class DefaultWebClientExchangeTagsProvider implements WebClientExchangeTa
Tag method = WebClientExchangeTags.method(request);
Tag uri = WebClientExchangeTags.uri(request);
Tag clientName = WebClientExchangeTags.clientName(request);
if (response != null) {
return Arrays.asList(method, uri, clientName, WebClientExchangeTags.status(response),
WebClientExchangeTags.outcome(response));
}
else {
return Arrays.asList(method, uri, clientName, WebClientExchangeTags.status(throwable));
}
return Arrays.asList(method, uri, clientName,
(response != null) ? WebClientExchangeTags.status(response) : WebClientExchangeTags.status(throwable),
WebClientExchangeTags.outcome(response));
}
}
......@@ -77,14 +77,14 @@ class DefaultWebClientExchangeTagsProviderTests {
void tagsWhenIoExceptionShouldReturnIoErrorStatus() {
Iterable<Tag> tags = this.tagsProvider.tags(this.request, null, new IOException());
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"),
Tag.of("clientName", "example.org"), Tag.of("status", "IO_ERROR"));
Tag.of("clientName", "example.org"), Tag.of("status", "IO_ERROR"), Tag.of("outcome", "UNKNOWN"));
}
@Test
void tagsWhenExceptionShouldReturnClientErrorStatus() {
Iterable<Tag> tags = this.tagsProvider.tags(this.request, null, new IllegalArgumentException());
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"),
Tag.of("clientName", "example.org"), Tag.of("status", "CLIENT_ERROR"));
Tag.of("clientName", "example.org"), Tag.of("status", "CLIENT_ERROR"), Tag.of("outcome", "UNKNOWN"));
}
}
......@@ -1981,10 +1981,11 @@ following information:
|`outcome`
|Request's outcome based on the status code of the response. 1xx is
`INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx `CLIENT_ERROR`, and 5xx is
`SERVER_ERROR`
`SERVER_ERROR`, `UNKNOWN` otherwise
|`status`
|Response's HTTP status code (for example, `200` or `500`)
|Response's HTTP status code if available (for example, `200` or `500`),
or `IO_ERROR` in case or I/O issues, `CLIENT_ERROR` otherwise
|`uri`
|Request's URI template prior to variable substitution, if possible (for example,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment