Reintroduce endpoints.metrics.filter.enabled

Commit 8c14009 removed the endpoints.metrics.filter.enabled property so
that endpoints.metrics.enabled is used for both disabling the endpoint
and the servlet filter that records interactions.

This was an unfortunate decision as it was no longer possible to only
disable the servlet filter. The endpoints.metrics.filter.enabled property
has therefore been restored.

Closes gh-4365
This commit is contained in:
Stephane Nicoll 2015-12-10 15:37:10 +01:00
parent ce541bebcf
commit ce2346b087
5 changed files with 11 additions and 4 deletions

View File

@ -46,7 +46,7 @@ import org.springframework.web.servlet.HandlerMapping;
@ConditionalOnClass({ Servlet.class, ServletRegistration.class,
OncePerRequestFilter.class, HandlerMapping.class })
@AutoConfigureAfter(MetricRepositoryAutoConfiguration.class)
@ConditionalOnProperty(name = "endpoints.metrics.enabled", matchIfMissing = true)
@ConditionalOnProperty(name = "endpoints.metrics.filter.enabled", matchIfMissing = true)
public class MetricFilterAutoConfiguration {
@Autowired

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2015 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.
@ -33,7 +33,7 @@ import org.springframework.util.Assert;
*
* @author Dave Syer
*/
@ConfigurationProperties(prefix = "endpoints.metrics", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "endpoints.metrics")
public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> {
private final List<PublicMetrics> publicMetrics;

View File

@ -17,6 +17,12 @@
"sourceType": "org.springframework.boot.actuate.endpoint.EnvironmentEndpoint",
"description": "Keys that should be sanitized. Keys can be simple strings that the property ends with or regex expressions."
},
{
"name": "endpoints.metrics.filter.enabled",
"type": "java.lang.Boolean",
"description": "Enable the metrics servlet filter.",
"defaultValue": true
},
{
"name": "info",
"type": "java.util.Map<java.lang.String,java.lang.Object>",

View File

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

View File

@ -547,6 +547,7 @@ content into your application; rather pick only the properties that you need.
endpoints.metrics.id=metrics
endpoints.metrics.sensitive=true
endpoints.metrics.enabled=true
endpoints.metrics.filter.enabled=true # Enable the metrics servlet filter.
endpoints.shutdown.id=shutdown
endpoints.shutdown.sensitive=true
endpoints.shutdown.enabled=false