Add the ability to disable the trace filter

See gh-8650
This commit is contained in:
Colin Harrington
2017-03-16 16:54:45 -05:00
committed by Stephane Nicoll
parent fccab42711
commit d3e2e22f8c
2 changed files with 17 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.trace.TraceProperties;
import org.springframework.boot.actuate.trace.TraceRepository;
import org.springframework.boot.actuate.trace.WebRequestTraceFilter;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -58,6 +59,19 @@ public class TraceWebFilterAutoConfigurationTests {
context.close();
}
@Test
public void skipsFilterIfPropertyDisabled() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context,
"endpoints.trace.filter.enabled:false");
context.register(PropertyPlaceholderAutoConfiguration.class,
TraceRepositoryAutoConfiguration.class,
TraceWebFilterAutoConfiguration.class);
context.refresh();
assertThat(context.getBeansOfType(WebRequestTraceFilter.class).size()).isEqualTo(0);
context.close();
}
@Configuration
static class CustomTraceFilterConfig {