Skip to content

Commit

Permalink
Merge branch '6.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
bclozel committed Oct 18, 2024
2 parents e02f8ca + 67d78eb commit 5f14703
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,14 @@ protected KeyValue exception(ServerRequestObservationContext context) {
}

protected KeyValue outcome(ServerRequestObservationContext context) {
if (context.getResponse() != null) {
HttpStatusCode statusCode = HttpStatusCode.valueOf(context.getResponse().getStatus());
return HttpOutcome.forStatus(statusCode);
try {
if (context.getResponse() != null) {
HttpStatusCode statusCode = HttpStatusCode.valueOf(context.getResponse().getStatus());
return HttpOutcome.forStatus(statusCode);
}
}
catch (IllegalArgumentException ex) {
return HTTP_OUTCOME_UNKNOWN;
}
return HTTP_OUTCOME_UNKNOWN;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -137,4 +137,16 @@ void addsKeyValuesForUnknownHttpMethodExchange() {
.contains(KeyValue.of("http.url", "/test"));
}

@Test
void addsKeyValuesForInvalidStatusExchange() {
this.request.setRequestURI("/test/invalidStatus");
this.response.setStatus(0);

assertThat(this.convention.getLowCardinalityKeyValues(this.context)).hasSize(5)
.contains(KeyValue.of("method", "GET"), KeyValue.of("uri", "UNKNOWN"), KeyValue.of("status", "0"),
KeyValue.of("exception", "none"), KeyValue.of("outcome", "UNKNOWN"));
assertThat(this.convention.getHighCardinalityKeyValues(this.context)).hasSize(1)
.contains(KeyValue.of("http.url", "/test/invalidStatus"));
}

}

0 comments on commit 5f14703

Please sign in to comment.