Skip to content

Commit

Permalink
Merge branch '6.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
bclozel committed Nov 21, 2024
2 parents 50061da + 1910d32 commit f5ff84a
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ private void runScheduledTaskAndAwait() throws InterruptedException {
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatTaskObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("tasks.scheduled.execution").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("tasks.scheduled.execution").that();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ void shouldUseCustomConvention() throws Exception {

restClient.get().uri("https://example.org").retrieve().toBodilessEntity();

TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("custom.requests");
assertThat(this.observationRegistry).hasObservationWithNameEqualTo("custom.requests");
}

@Test
Expand Down Expand Up @@ -301,9 +300,8 @@ private void mockResponseBody(String expectedBody, MediaType mediaType) throws E


private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
TestObservationRegistryAssert.assertThat(this.observationRegistry).hasNumberOfObservationsWithNameEqualTo("http.client.requests",1);
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests").that();
assertThat(this.observationRegistry).hasNumberOfObservationsWithNameEqualTo("http.client.requests",1);
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that();
}

static class ContextAssertionObservationHandler implements ObservationHandler<ClientRequestObservationContext> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ private void mockResponseBody(String expectedBody, MediaType mediaType) throws E


private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that();
}

static class ContextAssertionObservationHandler implements ObservationHandler<ClientRequestObservationContext> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.stream.Stream;

import io.micrometer.observation.tck.TestObservationRegistry;
import io.micrometer.observation.tck.TestObservationRegistryAssert;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
Expand Down Expand Up @@ -131,9 +130,8 @@ void greeting(
assertThat(response).isEqualTo("Hello Spring!");
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/greeting");
TestObservationRegistryAssert.assertThat(observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests")
.that().hasLowCardinalityKeyValue("uri", "/greeting");
assertThat(observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that()
.hasLowCardinalityKeyValue("uri", "/greeting");
}

@ParameterizedAdapterTest
Expand All @@ -147,9 +145,8 @@ void greetingById(
assertThat(response.getBody()).isEqualTo("Hello Spring!");
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/greeting/456");
TestObservationRegistryAssert.assertThat(observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests")
.that().hasLowCardinalityKeyValue("uri", "/greeting/{id}");
assertThat(observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that()
.hasLowCardinalityKeyValue("uri", "/greeting/{id}");
}

@ParameterizedAdapterTest
Expand All @@ -163,9 +160,8 @@ void greetingWithDynamicUri(
assertThat(response.orElse("empty")).isEqualTo("Hello Spring!");
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getRequestUrl().uri()).isEqualTo(dynamicUri);
TestObservationRegistryAssert.assertThat(observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests")
.that().hasLowCardinalityKeyValue("uri", "none");
assertThat(observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that()
.hasLowCardinalityKeyValue("uri", "none");
}

@ParameterizedAdapterTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,14 @@ void shouldNotCloseObservationDuringAsyncDispatch() throws Exception {
this.mockFilterChain = new MockFilterChain(new ScopeCheckingServlet(this.observationRegistry));
this.request.setDispatcherType(DispatcherType.ASYNC);
this.filter.doFilter(this.request, this.response, this.mockFilterChain);
TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.server.requests")
.that().isNotStopped();
assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that()
.isNotStopped();
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasNumberOfObservationsWithNameEqualTo("http.server.requests", 1);
assertThat(this.observationRegistry).hasNumberOfObservationsWithNameEqualTo("http.server.requests", 1);

return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.server.requests")
.that()
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that()
.hasBeenStopped();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ private WebFilterChain createFilterChain(ThrowingConsumer<ServerWebExchange> exc
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.server.requests").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ private HttpWebHandlerAdapter createWebHandler(WebHandler targetHandler) {
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.server.requests").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.function.Function;

import io.micrometer.observation.tck.TestObservationRegistry;
import io.micrometer.observation.tck.TestObservationRegistryAssert;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -171,8 +170,8 @@ void observationRegistry() {
handler.handle(MockServerHttpRequest.get("/").build(), response).block();

TestObservationRegistry observationRegistry = applicationContext.getBean(TestObservationRegistry.class);
TestObservationRegistryAssert.assertThat(observationRegistry).hasObservationWithNameEqualTo("http.server.requests")
.that().hasLowCardinalityKeyValue("uri", "UNKNOWN");
assertThat(observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that()
.hasLowCardinalityKeyValue("uri", "UNKNOWN");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ void recordsObservationWithResponseDetailsWhenFilterFunctionErrors() {
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that();
}

private ClientRequest verifyAndGetRequest() {
Expand Down

0 comments on commit f5ff84a

Please sign in to comment.