diff --git a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/ObservationExecChainHandlerIntegrationTest.java b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/ObservationExecChainHandlerIntegrationTest.java index 3744949a18..c174455a93 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/ObservationExecChainHandlerIntegrationTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/ObservationExecChainHandlerIntegrationTest.java @@ -82,9 +82,9 @@ void recordSuccessfulExchanges(@WiremockResolver.Wiremock WireMockServer server) } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "SUCCESS") - .hasLowCardinalityKeyValue(STATUS.asString(), "200") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("SUCCESS")) + .hasLowCardinalityKeyValue(STATUS.withValue("200")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); // end::example_classic[] } @@ -96,9 +96,9 @@ void recordClientErrorExchanges(@WiremockResolver.Wiremock WireMockServer server } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "CLIENT_ERROR") - .hasLowCardinalityKeyValue(STATUS.asString(), "404") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("CLIENT_ERROR")) + .hasLowCardinalityKeyValue(STATUS.withValue("404")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); } @Test @@ -109,7 +109,7 @@ void recordUnknownUriPatternByDefault(@WiremockResolver.Wiremock WireMockServer } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(URI.asString(), "UNKNOWN"); + .hasLowCardinalityKeyValue(URI.withValue("UNKNOWN")); } @Test @@ -123,7 +123,7 @@ void recordUriPatternWhenHeader(@WiremockResolver.Wiremock WireMockServer server } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(URI.asString(), "/some/{name}"); + .hasLowCardinalityKeyValue(URI.withValue("/some/{name}")); } @Test @@ -137,7 +137,7 @@ void recordUriPatternWhenContext(@WiremockResolver.Wiremock WireMockServer serve } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(URI.asString(), "/some/{name}"); + .hasLowCardinalityKeyValue(URI.withValue("/some/{name}")); } @ParameterizedTest @@ -152,7 +152,7 @@ void contextualNameContainsMethod(String methodName, @WiremockResolver.Wiremock assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() .hasContextualNameEqualTo("HTTP " + methodName) - .hasLowCardinalityKeyValue(METHOD.asString(), methodName); + .hasLowCardinalityKeyValue(METHOD.withValue(methodName)); } @Test @@ -164,10 +164,10 @@ void recordProtocolErrorsAsIoErrors(@WiremockResolver.Wiremock WireMockServer se } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "UNKNOWN") - .hasLowCardinalityKeyValue(STATUS.asString(), "IO_ERROR") - .hasLowCardinalityKeyValue(EXCEPTION.asString(), "ProtocolException") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("UNKNOWN")) + .hasLowCardinalityKeyValue(STATUS.withValue("IO_ERROR")) + .hasLowCardinalityKeyValue(EXCEPTION.withValue("ProtocolException")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); } @Test @@ -179,10 +179,10 @@ void recordSocketTimeoutAsIoErrors(@WiremockResolver.Wiremock WireMockServer ser } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "UNKNOWN") - .hasLowCardinalityKeyValue(STATUS.asString(), "IO_ERROR") - .hasLowCardinalityKeyValue(EXCEPTION.asString(), "SocketTimeoutException") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("UNKNOWN")) + .hasLowCardinalityKeyValue(STATUS.withValue("IO_ERROR")) + .hasLowCardinalityKeyValue(EXCEPTION.withValue("SocketTimeoutException")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); } @Test @@ -193,9 +193,9 @@ void recordRequestRetries(@WiremockResolver.Wiremock WireMockServer server) thro } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "SERVER_ERROR") - .hasLowCardinalityKeyValue(STATUS.asString(), "503") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("SERVER_ERROR")) + .hasLowCardinalityKeyValue(STATUS.withValue("503")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); assertThat(observationRegistry).hasNumberOfObservationsWithNameEqualTo(DEFAULT_METER_NAME, 2); } @@ -232,9 +232,9 @@ void recordSuccessfulExchanges(@WiremockResolver.Wiremock WireMockServer server) } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "SUCCESS") - .hasLowCardinalityKeyValue(STATUS.asString(), "200") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("SUCCESS")) + .hasLowCardinalityKeyValue(STATUS.withValue("200")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); // end::example_async[] } @@ -247,9 +247,9 @@ void recordClientErrorExchanges(@WiremockResolver.Wiremock WireMockServer server } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "CLIENT_ERROR") - .hasLowCardinalityKeyValue(STATUS.asString(), "404") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("CLIENT_ERROR")) + .hasLowCardinalityKeyValue(STATUS.withValue("404")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); } @Test @@ -261,7 +261,7 @@ void recordUnknownUriPatternByDefault(@WiremockResolver.Wiremock WireMockServer } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(URI.asString(), "UNKNOWN"); + .hasLowCardinalityKeyValue(URI.withValue("UNKNOWN")); } @Test @@ -276,7 +276,7 @@ void recordUriPatternWhenHeader(@WiremockResolver.Wiremock WireMockServer server } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(URI.asString(), "/some/{name}"); + .hasLowCardinalityKeyValue(URI.withValue("/some/{name}")); } @Test @@ -290,7 +290,7 @@ void recordUriPatternWhenContext(@WiremockResolver.Wiremock WireMockServer serve } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(URI.asString(), "/some/{name}"); + .hasLowCardinalityKeyValue(URI.withValue("/some/{name}")); } @ParameterizedTest @@ -306,7 +306,7 @@ void contextualNameContainsMethod(String methodName, @WiremockResolver.Wiremock assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() .hasContextualNameEqualTo("HTTP " + methodName) - .hasLowCardinalityKeyValue(METHOD.asString(), methodName); + .hasLowCardinalityKeyValue(METHOD.withValue(methodName)); } @Test @@ -318,10 +318,10 @@ void recordProtocolErrorsAsIoErrors(@WiremockResolver.Wiremock WireMockServer se } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "UNKNOWN") - .hasLowCardinalityKeyValue(STATUS.asString(), "IO_ERROR") - .hasLowCardinalityKeyValue(EXCEPTION.asString(), "ProtocolException") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("UNKNOWN")) + .hasLowCardinalityKeyValue(STATUS.withValue("IO_ERROR")) + .hasLowCardinalityKeyValue(EXCEPTION.withValue("ProtocolException")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); } @Test @@ -334,10 +334,10 @@ void recordSocketTimeoutAsIoErrors(@WiremockResolver.Wiremock WireMockServer ser } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "UNKNOWN") - .hasLowCardinalityKeyValue(STATUS.asString(), "IO_ERROR") - .hasLowCardinalityKeyValue(EXCEPTION.asString(), "SocketTimeoutException") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("UNKNOWN")) + .hasLowCardinalityKeyValue(STATUS.withValue("IO_ERROR")) + .hasLowCardinalityKeyValue(EXCEPTION.withValue("SocketTimeoutException")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); } @Test @@ -349,9 +349,9 @@ void recordRequestRetries(@WiremockResolver.Wiremock WireMockServer server) thro } assertThat(observationRegistry).hasObservationWithNameEqualTo(DEFAULT_METER_NAME) .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "SERVER_ERROR") - .hasLowCardinalityKeyValue(STATUS.asString(), "503") - .hasLowCardinalityKeyValue(METHOD.asString(), "GET"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("SERVER_ERROR")) + .hasLowCardinalityKeyValue(STATUS.withValue("503")) + .hasLowCardinalityKeyValue(METHOD.withValue("GET")); assertThat(observationRegistry).hasNumberOfObservationsWithNameEqualTo(DEFAULT_METER_NAME, 2); } diff --git a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/ObservationExecChainHandlerTest.java b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/ObservationExecChainHandlerTest.java index b235b387d4..0e633559ae 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/ObservationExecChainHandlerTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/ObservationExecChainHandlerTest.java @@ -83,7 +83,7 @@ void shouldInstrumentReceivedResponses() throws Exception { handler.execute(request, this.scope, chain); assertThat(observationRegistry).hasObservationWithNameEqualTo("httpcomponents.httpclient.request") .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "SUCCESS"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("SUCCESS")); } @Test @@ -95,8 +95,8 @@ void shouldInstrumentExceptions() throws Exception { .isInstanceOf(IllegalArgumentException.class); assertThat(observationRegistry).hasObservationWithNameEqualTo("httpcomponents.httpclient.request") .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "UNKNOWN") - .hasLowCardinalityKeyValue(EXCEPTION.asString(), "IllegalArgumentException"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("UNKNOWN")) + .hasLowCardinalityKeyValue(EXCEPTION.withValue("IllegalArgumentException")); } @Test @@ -108,8 +108,8 @@ void shouldInstrumentCancelledRequests() throws Exception { .isInstanceOf(RequestFailedException.class); assertThat(observationRegistry).hasObservationWithNameEqualTo("httpcomponents.httpclient.request") .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "UNKNOWN") - .hasLowCardinalityKeyValue(EXCEPTION.asString(), "RequestFailedException"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("UNKNOWN")) + .hasLowCardinalityKeyValue(EXCEPTION.withValue("RequestFailedException")); } } @@ -138,7 +138,7 @@ void shouldInstrumentReceivedResponses() throws Exception { assertThat(observationRegistry).hasObservationWithNameEqualTo("httpcomponents.httpclient.request") .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "SUCCESS"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("SUCCESS")); } @Test @@ -151,8 +151,8 @@ void shouldInstrumentExceptions() throws Exception { assertThat(observationRegistry).hasObservationWithNameEqualTo("httpcomponents.httpclient.request") .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "UNKNOWN") - .hasLowCardinalityKeyValue(EXCEPTION.asString(), "IllegalArgumentException"); + .hasLowCardinalityKeyValue(OUTCOME.withValue("UNKNOWN")) + .hasLowCardinalityKeyValue(EXCEPTION.withValue("IllegalArgumentException")); } @Test @@ -164,8 +164,8 @@ void shouldInstrumentCancelledRequests() throws Exception { assertThat(observationRegistry).hasObservationWithNameEqualTo("httpcomponents.httpclient.request") .that() - .hasLowCardinalityKeyValue(OUTCOME.asString(), "UNKNOWN") - .hasLowCardinalityKeyValue(EXCEPTION.asString(), KeyValue.NONE_VALUE); + .hasLowCardinalityKeyValue(OUTCOME.withValue("UNKNOWN")) + .hasLowCardinalityKeyValue(EXCEPTION.withValue(KeyValue.NONE_VALUE)); } }