mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Revert "Add property to specify the order of ServerHttpObservationFilter"
This reverts commit 7b90fbb0b2
.
This commit is contained in:
parent
849f65a0de
commit
b4bc7cebbc
@ -20,7 +20,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ConfigurationProperties @ConfigurationProperties} for configuring Micrometer
|
* {@link ConfigurationProperties @ConfigurationProperties} for configuring Micrometer
|
||||||
@ -111,16 +110,10 @@ public class ObservationProperties {
|
|||||||
|
|
||||||
private final ServerRequests requests = new ServerRequests();
|
private final ServerRequests requests = new ServerRequests();
|
||||||
|
|
||||||
private final Filter filter = new Filter();
|
|
||||||
|
|
||||||
public ServerRequests getRequests() {
|
public ServerRequests getRequests() {
|
||||||
return this.requests;
|
return this.requests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Filter getFilter() {
|
|
||||||
return this.filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ServerRequests {
|
public static class ServerRequests {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,23 +131,6 @@ public class ObservationProperties {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Filter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Order of the filter that creates the observations.
|
|
||||||
*/
|
|
||||||
private int order = Ordered.HIGHEST_PRECEDENCE + 1;
|
|
||||||
|
|
||||||
public int getOrder() {
|
|
||||||
return this.order;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrder(int order) {
|
|
||||||
this.order = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2023 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.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.observation.web.reactive;
|
|
||||||
|
|
||||||
import io.micrometer.observation.ObservationRegistry;
|
|
||||||
|
|
||||||
import org.springframework.boot.web.reactive.filter.OrderedWebFilter;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.http.server.reactive.observation.ServerRequestObservationConvention;
|
|
||||||
import org.springframework.web.filter.reactive.ServerHttpObservationFilter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link ServerHttpObservationFilter} that also implements {@link Ordered}.
|
|
||||||
*
|
|
||||||
* @author Moritz Halbritter
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "deprecation", "removal" })
|
|
||||||
class OrderedServerHttpObservationFilter extends ServerHttpObservationFilter implements OrderedWebFilter {
|
|
||||||
|
|
||||||
private final int order;
|
|
||||||
|
|
||||||
OrderedServerHttpObservationFilter(ObservationRegistry observationRegistry,
|
|
||||||
ServerRequestObservationConvention observationConvention, int order) {
|
|
||||||
super(observationRegistry, observationConvention);
|
|
||||||
this.order = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOrder() {
|
|
||||||
return this.order;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -38,6 +38,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
|
|||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.http.server.reactive.observation.DefaultServerRequestObservationConvention;
|
import org.springframework.http.server.reactive.observation.DefaultServerRequestObservationConvention;
|
||||||
import org.springframework.http.server.reactive.observation.ServerRequestObservationConvention;
|
import org.springframework.http.server.reactive.observation.ServerRequestObservationConvention;
|
||||||
@ -50,7 +51,6 @@ import org.springframework.web.filter.reactive.ServerHttpObservationFilter;
|
|||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @author Jon Schneider
|
* @author Jon Schneider
|
||||||
* @author Dmytro Nosan
|
* @author Dmytro Nosan
|
||||||
* @author Moritz Halbritter
|
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration(after = { MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class,
|
@AutoConfiguration(after = { MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class,
|
||||||
@ -70,13 +70,13 @@ public class WebFluxObservationAutoConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean(ServerHttpObservationFilter.class)
|
@ConditionalOnMissingBean(ServerHttpObservationFilter.class)
|
||||||
public OrderedServerHttpObservationFilter webfluxObservationFilter(ObservationRegistry registry,
|
@Order(Ordered.HIGHEST_PRECEDENCE + 1)
|
||||||
|
public ServerHttpObservationFilter webfluxObservationFilter(ObservationRegistry registry,
|
||||||
ObjectProvider<ServerRequestObservationConvention> customConvention) {
|
ObjectProvider<ServerRequestObservationConvention> customConvention) {
|
||||||
String name = this.observationProperties.getHttp().getServer().getRequests().getName();
|
String name = this.observationProperties.getHttp().getServer().getRequests().getName();
|
||||||
ServerRequestObservationConvention convention = customConvention
|
ServerRequestObservationConvention convention = customConvention
|
||||||
.getIfAvailable(() -> new DefaultServerRequestObservationConvention(name));
|
.getIfAvailable(() -> new DefaultServerRequestObservationConvention(name));
|
||||||
int order = this.observationProperties.getHttp().getServer().getFilter().getOrder();
|
return new ServerHttpObservationFilter(registry, convention);
|
||||||
return new OrderedServerHttpObservationFilter(registry, convention, order);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
@ -52,7 +52,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @author Dmytro Nosan
|
* @author Dmytro Nosan
|
||||||
* @author Madhura Bhave
|
* @author Madhura Bhave
|
||||||
* @author Moritz Halbritter
|
|
||||||
*/
|
*/
|
||||||
@ExtendWith(OutputCaptureExtension.class)
|
@ExtendWith(OutputCaptureExtension.class)
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
@ -128,15 +127,6 @@ class WebFluxObservationAutoConfigurationTests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void shouldUsePropertyForServerHttpObservationFilterOrder() {
|
|
||||||
this.contextRunner.withPropertyValues("management.observations.http.server.filter.order=1000")
|
|
||||||
.run((context) -> {
|
|
||||||
OrderedServerHttpObservationFilter bean = context.getBean(OrderedServerHttpObservationFilter.class);
|
|
||||||
assertThat(bean.getOrder()).isEqualTo(1000);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private MeterRegistry getInitializedMeterRegistry(AssertableReactiveWebApplicationContext context)
|
private MeterRegistry getInitializedMeterRegistry(AssertableReactiveWebApplicationContext context)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
return getInitializedMeterRegistry(context, "/test0", "/test1", "/test2");
|
return getInitializedMeterRegistry(context, "/test0", "/test1", "/test2");
|
||||||
|
Loading…
Reference in New Issue
Block a user