Enable info and status endpoints by default
Closes gh-10161
This commit is contained in:
parent
222ed44bd4
commit
40e6f004da
|
@ -24,6 +24,7 @@ import org.springframework.boot.actuate.health.HealthEndpoint;
|
|||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
import org.springframework.boot.actuate.health.StatusEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -81,6 +82,19 @@ public class HealthEndpointAutoConfigurationTests {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runShouldHaveStatusEndpointBeanEvenIfDefaultIsDisabled() {
|
||||
this.contextRunner.withPropertyValues("endpoints.default.enabled:false")
|
||||
.run((context) -> assertThat(context).hasSingleBean(StatusEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
this.contextRunner.withPropertyValues("endpoints.status.enabled:false").run(
|
||||
(context) -> assertThat(context).doesNotHaveBean(StatusEndpoint.class));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class HealthIndicatorConfiguration {
|
||||
|
||||
|
|
|
@ -41,6 +41,12 @@ public class InfoEndpointAutoConfigurationTests {
|
|||
.run((context) -> assertThat(context).hasSingleBean(InfoEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBeanEvenIfDefaultIsDisabled() {
|
||||
this.contextRunner.withPropertyValues("endpoints.default.enabled:false")
|
||||
.run((context) -> assertThat(context).hasSingleBean(InfoEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
|
|
|
@ -55,7 +55,8 @@ public class JmxEndpointIntegrationTests {
|
|||
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
|
||||
checkEndpointMBeans(mBeanServer,
|
||||
new String[] { "autoconfig", "beans", "configprops", "env", "health",
|
||||
"info", "mappings", "metrics", "threaddump", "trace" },
|
||||
"info", "mappings", "metrics", "status", "threaddump",
|
||||
"trace" },
|
||||
new String[] { "shutdown" });
|
||||
});
|
||||
}
|
||||
|
@ -67,7 +68,7 @@ public class JmxEndpointIntegrationTests {
|
|||
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
|
||||
checkEndpointMBeans(mBeanServer, new String[0],
|
||||
new String[] { "autoconfig", "beans", "configprops", "env",
|
||||
"health", "info", "mappings", "metrics", "shutdown",
|
||||
"health", "mappings", "metrics", "shutdown",
|
||||
"threaddump", "trace" });
|
||||
|
||||
});
|
||||
|
@ -80,7 +81,7 @@ public class JmxEndpointIntegrationTests {
|
|||
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
|
||||
checkEndpointMBeans(mBeanServer, new String[] { "beans" },
|
||||
new String[] { "autoconfig", "configprops", "env", "health",
|
||||
"info", "mappings", "metrics", "shutdown",
|
||||
"mappings", "metrics", "shutdown",
|
||||
"threaddump", "trace" });
|
||||
});
|
||||
}
|
||||
|
|
|
@ -69,10 +69,11 @@ public class WebMvcEndpointExposureIntegrationTests {
|
|||
assertThat(isExposed(mvc, HttpMethod.GET, "configprops")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "env")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "health")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "info")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "info")).isTrue();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "mappings")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "metrics")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.POST, "shutdown")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "status")).isTrue();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "threaddump")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "trace")).isFalse();
|
||||
});
|
||||
|
@ -93,6 +94,7 @@ public class WebMvcEndpointExposureIntegrationTests {
|
|||
assertThat(isExposed(mvc, HttpMethod.GET, "mappings")).isTrue();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "metrics")).isTrue();
|
||||
assertThat(isExposed(mvc, HttpMethod.POST, "shutdown")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "status")).isTrue();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "threaddump")).isTrue();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "trace")).isTrue();
|
||||
});
|
||||
|
@ -110,10 +112,11 @@ public class WebMvcEndpointExposureIntegrationTests {
|
|||
assertThat(isExposed(mvc, HttpMethod.GET, "configprops")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "env")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "health")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "info")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "info")).isTrue();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "mappings")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "metrics")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.POST, "shutdown")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "status")).isTrue();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "threaddump")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "trace")).isFalse();
|
||||
});
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.DefaultEnablement;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
|
||||
|
@ -25,7 +26,7 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
|||
* @author Stephane Nicoll
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Endpoint(id = "status")
|
||||
@Endpoint(id = "status", defaultEnablement = DefaultEnablement.ENABLED)
|
||||
public class StatusEndpoint {
|
||||
|
||||
private final HealthIndicator healthIndicator;
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.info;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.DefaultEnablement;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
import org.springframework.util.Assert;
|
||||
|
@ -31,7 +32,7 @@ import org.springframework.util.Assert;
|
|||
* @author Stephane Nicoll
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Endpoint(id = "info")
|
||||
@Endpoint(id = "info", defaultEnablement = DefaultEnablement.ENABLED)
|
||||
public class InfoEndpoint {
|
||||
|
||||
private final List<InfoContributor> infoContributors;
|
||||
|
|
|
@ -1128,9 +1128,9 @@ content into your application; rather pick only the properties that you need.
|
|||
|
||||
# INFO ENDPOINT ({sc-spring-boot-actuator}/endpoint/InfoEndpoint.{sc-ext}[InfoEndpoint])
|
||||
endpoints.info.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
|
||||
endpoints.info.enabled= # Enable the info endpoint.
|
||||
endpoints.info.jmx.enabled= # Expose the info endpoint as a JMX MBean.
|
||||
endpoints.info.web.enabled= # Expose the info endpoint as a Web endpoint.
|
||||
endpoints.info.enabled=true # Enable the info endpoint.
|
||||
endpoints.info.jmx.enabled=true # Expose the info endpoint as a JMX MBean.
|
||||
endpoints.info.web.enabled=true # Expose the info endpoint as a Web endpoint.
|
||||
|
||||
# LIQUIBASE ENDPOINT ({sc-spring-boot-actuator}/endpoint/LiquibaseEndpoint.{sc-ext}[LiquibaseEndpoint])
|
||||
endpoints.liquibase.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
|
||||
|
@ -1170,9 +1170,9 @@ content into your application; rather pick only the properties that you need.
|
|||
|
||||
# STATUS ENDPOINT ({sc-spring-boot-actuator}/endpoint/StatusEndpoint.{sc-ext}[StatusEndpoint])
|
||||
endpoints.status.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
|
||||
endpoints.status.enabled= # Enable the status endpoint.
|
||||
endpoints.status.jmx.enabled= # Expose the status endpoint as a JMX MBean.
|
||||
endpoints.status.web.enabled= # Expose the status endpoint as a Web endpoint.
|
||||
endpoints.status.enabled=true # Enable the status endpoint.
|
||||
endpoints.status.jmx.enabled=true # Expose the status endpoint as a JMX MBean.
|
||||
endpoints.status.web.enabled=true # Expose the status endpoint as a Web endpoint.
|
||||
|
||||
# THREAD DUMP ENDPOINT ({sc-spring-boot-actuator}/endpoint/ThreadDumpEndpoint.{sc-ext}[ThreadDumpEndpoint])
|
||||
endpoints.threaddump.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
|
||||
|
|
Loading…
Reference in New Issue