mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Start building against Spring Framework 6.0.0 SNAPSHOTs
See gh-33136
This commit is contained in:
parent
4bd2fe151e
commit
932f7d705f
@ -24,8 +24,14 @@ import io.micrometer.core.instrument.Tag;
|
||||
import org.springframework.boot.actuate.metrics.web.reactive.server.DefaultWebFluxTagsProvider;
|
||||
import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsContributor;
|
||||
import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsProvider;
|
||||
import org.springframework.http.observation.reactive.ServerRequestObservationContext;
|
||||
import org.springframework.http.observation.reactive.ServerRequestObservationConvention;
|
||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
import org.springframework.http.server.reactive.observation.ServerRequestObservationContext;
|
||||
import org.springframework.http.server.reactive.observation.ServerRequestObservationConvention;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver;
|
||||
import org.springframework.web.server.i18n.LocaleContextResolver;
|
||||
import org.springframework.web.server.session.DefaultWebSessionManager;
|
||||
import org.springframework.web.server.session.WebSessionManager;
|
||||
|
||||
/**
|
||||
* Adapter class that applies {@link WebFluxTagsProvider} tags as a
|
||||
@ -37,6 +43,12 @@ import org.springframework.http.observation.reactive.ServerRequestObservationCon
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention {
|
||||
|
||||
private final WebSessionManager webSessionManager = new DefaultWebSessionManager();
|
||||
|
||||
private final ServerCodecConfigurer serverCodecConfigurer = ServerCodecConfigurer.create();
|
||||
|
||||
private final LocaleContextResolver localeContextResolver = new AcceptHeaderLocaleContextResolver();
|
||||
|
||||
private final String name;
|
||||
|
||||
private final WebFluxTagsProvider tagsProvider;
|
||||
@ -58,7 +70,10 @@ class ServerRequestObservationConventionAdapter implements ServerRequestObservat
|
||||
|
||||
@Override
|
||||
public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) {
|
||||
Iterable<Tag> tags = this.tagsProvider.httpRequestTags(context.getServerWebExchange(), context.getError());
|
||||
DefaultServerWebExchange serverWebExchange = new DefaultServerWebExchange(context.getCarrier(),
|
||||
context.getResponse(), this.webSessionManager, this.serverCodecConfigurer, this.localeContextResolver);
|
||||
serverWebExchange.getAttributes().putAll(context.getAttributes());
|
||||
Iterable<Tag> tags = this.tagsProvider.httpRequestTags(serverWebExchange, context.getError());
|
||||
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.observation.reactive.DefaultServerRequestObservationConvention;
|
||||
import org.springframework.http.observation.reactive.ServerRequestObservationConvention;
|
||||
import org.springframework.http.server.reactive.observation.DefaultServerRequestObservationConvention;
|
||||
import org.springframework.http.server.reactive.observation.ServerRequestObservationConvention;
|
||||
import org.springframework.web.filter.reactive.ServerHttpObservationFilter;
|
||||
|
||||
/**
|
||||
@ -85,11 +85,11 @@ public class WebFluxObservationAutoConfiguration {
|
||||
String name = (observationName != null) ? observationName : metricName;
|
||||
WebFluxTagsProvider tagsProvider = tagConfigurer.getIfAvailable();
|
||||
List<WebFluxTagsContributor> tagsContributors = contributorsProvider.orderedStream().toList();
|
||||
ServerRequestObservationConvention convention = extracted(name, tagsProvider, tagsContributors);
|
||||
ServerRequestObservationConvention convention = createConvention(name, tagsProvider, tagsContributors);
|
||||
return new ServerHttpObservationFilter(registry, convention);
|
||||
}
|
||||
|
||||
private ServerRequestObservationConvention extracted(String name, WebFluxTagsProvider tagsProvider,
|
||||
private ServerRequestObservationConvention createConvention(String name, WebFluxTagsProvider tagsProvider,
|
||||
List<WebFluxTagsContributor> tagsContributors) {
|
||||
if (tagsProvider != null) {
|
||||
return new ServerRequestObservationConventionAdapter(name, tagsProvider);
|
||||
|
@ -25,8 +25,8 @@ import io.micrometer.observation.Observation;
|
||||
import org.springframework.boot.actuate.metrics.web.servlet.DefaultWebMvcTagsProvider;
|
||||
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor;
|
||||
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsProvider;
|
||||
import org.springframework.http.observation.ServerRequestObservationContext;
|
||||
import org.springframework.http.observation.ServerRequestObservationConvention;
|
||||
import org.springframework.http.server.observation.ServerRequestObservationContext;
|
||||
import org.springframework.http.server.observation.ServerRequestObservationConvention;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
|
@ -46,8 +46,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.observation.DefaultServerRequestObservationConvention;
|
||||
import org.springframework.http.observation.ServerRequestObservationConvention;
|
||||
import org.springframework.http.server.observation.DefaultServerRequestObservationConvention;
|
||||
import org.springframework.http.server.observation.ServerRequestObservationConvention;
|
||||
import org.springframework.web.filter.ServerHttpObservationFilter;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
||||
|
@ -16,13 +16,15 @@
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.observation.web.reactive;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.micrometer.common.KeyValue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.web.reactive.server.DefaultWebFluxTagsProvider;
|
||||
import org.springframework.http.observation.reactive.ServerRequestObservationContext;
|
||||
import org.springframework.http.server.reactive.observation.ServerRequestObservationContext;
|
||||
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.mock.web.server.MockServerWebExchange;
|
||||
import org.springframework.mock.http.server.reactive.MockServerHttpResponse;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
import org.springframework.web.util.pattern.PathPatternParser;
|
||||
|
||||
@ -39,12 +41,6 @@ class ServerRequestObservationConventionAdapterTests {
|
||||
|
||||
private static final String TEST_METRIC_NAME = "test.metric.name";
|
||||
|
||||
private final MockServerHttpRequest request = MockServerHttpRequest.get("/resource/test").build();
|
||||
|
||||
private final MockServerWebExchange serverWebExchange = MockServerWebExchange.builder(this.request).build();
|
||||
|
||||
private final ServerRequestObservationContext context = new ServerRequestObservationContext(this.serverWebExchange);
|
||||
|
||||
private final ServerRequestObservationConventionAdapter convention = new ServerRequestObservationConventionAdapter(
|
||||
TEST_METRIC_NAME, new DefaultWebFluxTagsProvider());
|
||||
|
||||
@ -55,9 +51,12 @@ class ServerRequestObservationConventionAdapterTests {
|
||||
|
||||
@Test
|
||||
void shouldPushTagsAsLowCardinalityKeyValues() {
|
||||
this.serverWebExchange.getAttributes().put(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE,
|
||||
PathPatternParser.defaultInstance.parse("/resource/{name}"));
|
||||
assertThat(this.convention.getLowCardinalityKeyValues(this.context)).contains(KeyValue.of("status", "200"),
|
||||
MockServerHttpRequest request = MockServerHttpRequest.get("/resource/test").build();
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
ServerRequestObservationContext context = new ServerRequestObservationContext(request, response,
|
||||
Map.of(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE,
|
||||
PathPatternParser.defaultInstance.parse("/resource/{name}")));
|
||||
assertThat(this.convention.getLowCardinalityKeyValues(context)).contains(KeyValue.of("status", "200"),
|
||||
KeyValue.of("outcome", "SUCCESS"), KeyValue.of("uri", "/resource/{name}"),
|
||||
KeyValue.of("method", "GET"));
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.web.servlet.DefaultWebMvcTagsProvider;
|
||||
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor;
|
||||
import org.springframework.http.observation.ServerRequestObservationContext;
|
||||
import org.springframework.http.server.observation.ServerRequestObservationContext;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
@ -31,7 +31,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
|
||||
* {@link org.springframework.http.observation.reactive.ServerRequestObservationConvention}
|
||||
* {@link org.springframework.http.server.reactive.observation.ServerRequestObservationConvention}
|
||||
*/
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
|
@ -41,7 +41,7 @@ import org.springframework.web.util.pattern.PathPattern;
|
||||
* @author Brian Clozel
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
|
||||
* {@link org.springframework.http.observation.reactive.ServerRequestObservationConvention}
|
||||
* {@link org.springframework.http.server.reactive.observation.ServerRequestObservationConvention}
|
||||
*/
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
public final class WebFluxTags {
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.3.0
|
||||
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
|
||||
* {@link org.springframework.http.observation.reactive.ServerRequestObservationConvention}
|
||||
* {@link org.springframework.http.server.reactive.observation.ServerRequestObservationConvention}
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
|
||||
* {@link org.springframework.http.observation.reactive.ServerRequestObservationConvention}
|
||||
* {@link org.springframework.http.server.reactive.observation.ServerRequestObservationConvention}
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
|
@ -30,7 +30,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
|
||||
* {@link org.springframework.http.observation.ServerRequestObservationConvention}
|
||||
* {@link org.springframework.http.server.observation.ServerRequestObservationConvention}
|
||||
*/
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
|
@ -38,7 +38,7 @@ import org.springframework.web.util.pattern.PathPattern;
|
||||
* @author Michael McFadyen
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
|
||||
* {@link org.springframework.http.observation.ServerRequestObservationConvention}
|
||||
* {@link org.springframework.http.server.observation.ServerRequestObservationConvention}
|
||||
*/
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
public final class WebMvcTags {
|
||||
|
@ -28,7 +28,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.3.0
|
||||
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
|
||||
* {@link org.springframework.http.observation.ServerRequestObservationConvention}
|
||||
* {@link org.springframework.http.server.observation.ServerRequestObservationConvention}
|
||||
*/
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
public interface WebMvcTagsContributor {
|
||||
|
@ -28,7 +28,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.0.0
|
||||
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
|
||||
* {@link org.springframework.http.observation.ServerRequestObservationConvention}
|
||||
* {@link org.springframework.http.server.observation.ServerRequestObservationConvention}
|
||||
*/
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
public interface WebMvcTagsProvider {
|
||||
|
@ -1357,7 +1357,7 @@ bom {
|
||||
]
|
||||
}
|
||||
}
|
||||
library("Spring Framework", "6.0.0-RC4") {
|
||||
library("Spring Framework", "6.0.0-SNAPSHOT") {
|
||||
group("org.springframework") {
|
||||
imports = [
|
||||
"spring-framework-bom"
|
||||
|
Loading…
Reference in New Issue
Block a user