Skip to content

Commit ce2346b

Browse files
committed
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 spring-projectsgh-4365
1 parent ce541be commit ce2346b

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricFilterAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
@ConditionalOnClass({ Servlet.class, ServletRegistration.class,
4747
OncePerRequestFilter.class, HandlerMapping.class })
4848
@AutoConfigureAfter(MetricRepositoryAutoConfiguration.class)
49-
@ConditionalOnProperty(name = "endpoints.metrics.enabled", matchIfMissing = true)
49+
@ConditionalOnProperty(name = "endpoints.metrics.filter.enabled", matchIfMissing = true)
5050
public class MetricFilterAutoConfiguration {
5151

5252
@Autowired

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/MetricsEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@
3333
*
3434
* @author Dave Syer
3535
*/
36-
@ConfigurationProperties(prefix = "endpoints.metrics", ignoreUnknownFields = false)
36+
@ConfigurationProperties(prefix = "endpoints.metrics")
3737
public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> {
3838

3939
private final List<PublicMetrics> publicMetrics;

spring-boot-actuator/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
"sourceType": "org.springframework.boot.actuate.endpoint.EnvironmentEndpoint",
1818
"description": "Keys that should be sanitized. Keys can be simple strings that the property ends with or regex expressions."
1919
},
20+
{
21+
"name": "endpoints.metrics.filter.enabled",
22+
"type": "java.lang.Boolean",
23+
"description": "Enable the metrics servlet filter.",
24+
"defaultValue": true
25+
},
2026
{
2127
"name": "info",
2228
"type": "java.util.Map<java.lang.String,java.lang.Object>",

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/MetricFilterAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public void skipsFilterIfMissingServices() throws Exception {
180180
@Test
181181
public void skipsFilterIfPropertyDisabled() throws Exception {
182182
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
183-
EnvironmentTestUtils.addEnvironment(context, "endpoints.metrics.enabled:false");
183+
EnvironmentTestUtils.addEnvironment(context, "endpoints.metrics.filter.enabled:false");
184184
context.register(Config.class, MetricFilterAutoConfiguration.class);
185185
context.refresh();
186186
assertThat(context.getBeansOfType(Filter.class).size(), equalTo(0));

spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ content into your application; rather pick only the properties that you need.
547547
endpoints.metrics.id=metrics
548548
endpoints.metrics.sensitive=true
549549
endpoints.metrics.enabled=true
550+
endpoints.metrics.filter.enabled=true # Enable the metrics servlet filter.
550551
endpoints.shutdown.id=shutdown
551552
endpoints.shutdown.sensitive=true
552553
endpoints.shutdown.enabled=false

0 commit comments

Comments
 (0)