Merge branch '6.0.x'
This commit is contained in:
commit
d1cf71cc70
|
@ -108,7 +108,7 @@ public class DefaultServerRequestObservationConvention implements ServerRequestO
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KeyValue status(ServerRequestObservationContext context) {
|
protected KeyValue status(ServerRequestObservationContext context) {
|
||||||
if (context.isConnectionAborted()) {
|
if (context.isConnectionAborted() && (context.getResponse() == null || !context.getResponse().isCommitted())) {
|
||||||
return STATUS_UNKNOWN;
|
return STATUS_UNKNOWN;
|
||||||
}
|
}
|
||||||
return (context.getResponse() != null && context.getResponse().getStatusCode() != null) ?
|
return (context.getResponse() != null && context.getResponse().getStatusCode() != null) ?
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -147,6 +147,21 @@ class DefaultServerRequestObservationConventionTests {
|
||||||
.contains(KeyValue.of("http.url", "/test/resource"));
|
.contains(KeyValue.of("http.url", "/test/resource"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void addsKeyValuesForCancelledExchangeWhenResponseCommitted() {
|
||||||
|
ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/test/resource"));
|
||||||
|
ServerRequestObservationContext context = new ServerRequestObservationContext(exchange.getRequest(), exchange.getResponse(), exchange.getAttributes());
|
||||||
|
context.setConnectionAborted(true);
|
||||||
|
exchange.getResponse().setRawStatusCode(404);
|
||||||
|
exchange.getResponse().setComplete().block();
|
||||||
|
|
||||||
|
assertThat(this.convention.getLowCardinalityKeyValues(context)).hasSize(5)
|
||||||
|
.contains(KeyValue.of("method", "GET"), KeyValue.of("uri", "NOT_FOUND"), KeyValue.of("status", "404"),
|
||||||
|
KeyValue.of("exception", "none"), KeyValue.of("outcome", "UNKNOWN"));
|
||||||
|
assertThat(this.convention.getHighCardinalityKeyValues(context)).hasSize(1)
|
||||||
|
.contains(KeyValue.of("http.url", "/test/resource"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void supportsNullStatusCode() {
|
void supportsNullStatusCode() {
|
||||||
ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/test/resource"));
|
ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/test/resource"));
|
||||||
|
|
Loading…
Reference in New Issue