Skip to content

Commit

Permalink
Fix key to disable the metrics filter
Browse files Browse the repository at this point in the history
Commit d0cf6b5 introduced a `endpoints.metrics.filter.enabled` property
key meant to disable the filter. Unfortunately, the `endpoints.metrics`
namespace is already managed so setting this property will fail.

We now use the same key than the one used to disable the metrics
endpoint.

Closes spring-projectsgh-4365
  • Loading branch information
snicoll committed Nov 3, 2015
1 parent 791e304 commit 8c14009
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
@ConditionalOnClass({ Servlet.class, ServletRegistration.class,
OncePerRequestFilter.class, HandlerMapping.class })
@AutoConfigureAfter(MetricRepositoryAutoConfiguration.class)
@ConditionalOnProperty(name = "endpoints.metrics.filter.enabled", matchIfMissing = true)
@ConditionalOnProperty(name = "endpoints.metrics.enabled", matchIfMissing = true)
public class MetricFilterAutoConfiguration {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -77,6 +78,7 @@
*
* @author Phillip Webb
* @author Andy Wilkinson
* @@author Stephane Nicoll
*/
public class MetricFilterAutoConfigurationTests {

Expand Down Expand Up @@ -175,6 +177,16 @@ public void skipsFilterIfMissingServices() throws Exception {
context.close();
}

@Test
public void skipsFilterIfPropertyDisabled() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, "endpoints.metrics.enabled:false");
context.register(Config.class, MetricFilterAutoConfiguration.class);
context.refresh();
assertThat(context.getBeansOfType(Filter.class).size(), equalTo(0));
context.close();
}

@Test
public void controllerMethodThatThrowsUnhandledException() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
Expand Down

0 comments on commit 8c14009

Please sign in to comment.