mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
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:
parent
ce541bebcf
commit
ce2346b087
@ -46,7 +46,7 @@ import org.springframework.web.servlet.HandlerMapping;
|
|||||||
@ConditionalOnClass({ Servlet.class, ServletRegistration.class,
|
@ConditionalOnClass({ Servlet.class, ServletRegistration.class,
|
||||||
OncePerRequestFilter.class, HandlerMapping.class })
|
OncePerRequestFilter.class, HandlerMapping.class })
|
||||||
@AutoConfigureAfter(MetricRepositoryAutoConfiguration.class)
|
@AutoConfigureAfter(MetricRepositoryAutoConfiguration.class)
|
||||||
@ConditionalOnProperty(name = "endpoints.metrics.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(name = "endpoints.metrics.filter.enabled", matchIfMissing = true)
|
||||||
public class MetricFilterAutoConfiguration {
|
public class MetricFilterAutoConfiguration {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* @author Dave Syer
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "endpoints.metrics", ignoreUnknownFields = false)
|
@ConfigurationProperties(prefix = "endpoints.metrics")
|
||||||
public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
||||||
|
|
||||||
private final List<PublicMetrics> publicMetrics;
|
private final List<PublicMetrics> publicMetrics;
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
"sourceType": "org.springframework.boot.actuate.endpoint.EnvironmentEndpoint",
|
"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."
|
"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",
|
"name": "info",
|
||||||
"type": "java.util.Map<java.lang.String,java.lang.Object>",
|
"type": "java.util.Map<java.lang.String,java.lang.Object>",
|
||||||
|
@ -180,7 +180,7 @@ public class MetricFilterAutoConfigurationTests {
|
|||||||
@Test
|
@Test
|
||||||
public void skipsFilterIfPropertyDisabled() throws Exception {
|
public void skipsFilterIfPropertyDisabled() throws Exception {
|
||||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
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.register(Config.class, MetricFilterAutoConfiguration.class);
|
||||||
context.refresh();
|
context.refresh();
|
||||||
assertThat(context.getBeansOfType(Filter.class).size(), equalTo(0));
|
assertThat(context.getBeansOfType(Filter.class).size(), equalTo(0));
|
||||||
|
@ -547,6 +547,7 @@ content into your application; rather pick only the properties that you need.
|
|||||||
endpoints.metrics.id=metrics
|
endpoints.metrics.id=metrics
|
||||||
endpoints.metrics.sensitive=true
|
endpoints.metrics.sensitive=true
|
||||||
endpoints.metrics.enabled=true
|
endpoints.metrics.enabled=true
|
||||||
|
endpoints.metrics.filter.enabled=true # Enable the metrics servlet filter.
|
||||||
endpoints.shutdown.id=shutdown
|
endpoints.shutdown.id=shutdown
|
||||||
endpoints.shutdown.sensitive=true
|
endpoints.shutdown.sensitive=true
|
||||||
endpoints.shutdown.enabled=false
|
endpoints.shutdown.enabled=false
|
||||||
|
Loading…
Reference in New Issue
Block a user