Commit 40e6f004 authored by Stephane Nicoll's avatar Stephane Nicoll

Enable info and status endpoints by default

Closes gh-10161
parent 222ed44b
...@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.health.HealthEndpoint; ...@@ -24,6 +24,7 @@ import org.springframework.boot.actuate.health.HealthEndpoint;
import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.ReactiveHealthIndicator; import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
import org.springframework.boot.actuate.health.Status; import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.actuate.health.StatusEndpoint;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -81,6 +82,19 @@ public class HealthEndpointAutoConfigurationTests { ...@@ -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 @Configuration
static class HealthIndicatorConfiguration { static class HealthIndicatorConfiguration {
......
...@@ -41,6 +41,12 @@ public class InfoEndpointAutoConfigurationTests { ...@@ -41,6 +41,12 @@ public class InfoEndpointAutoConfigurationTests {
.run((context) -> assertThat(context).hasSingleBean(InfoEndpoint.class)); .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 @Test
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
throws Exception { throws Exception {
......
...@@ -55,7 +55,8 @@ public class JmxEndpointIntegrationTests { ...@@ -55,7 +55,8 @@ public class JmxEndpointIntegrationTests {
MBeanServer mBeanServer = context.getBean(MBeanServer.class); MBeanServer mBeanServer = context.getBean(MBeanServer.class);
checkEndpointMBeans(mBeanServer, checkEndpointMBeans(mBeanServer,
new String[] { "autoconfig", "beans", "configprops", "env", "health", new String[] { "autoconfig", "beans", "configprops", "env", "health",
"info", "mappings", "metrics", "threaddump", "trace" }, "info", "mappings", "metrics", "status", "threaddump",
"trace" },
new String[] { "shutdown" }); new String[] { "shutdown" });
}); });
} }
...@@ -67,7 +68,7 @@ public class JmxEndpointIntegrationTests { ...@@ -67,7 +68,7 @@ public class JmxEndpointIntegrationTests {
MBeanServer mBeanServer = context.getBean(MBeanServer.class); MBeanServer mBeanServer = context.getBean(MBeanServer.class);
checkEndpointMBeans(mBeanServer, new String[0], checkEndpointMBeans(mBeanServer, new String[0],
new String[] { "autoconfig", "beans", "configprops", "env", new String[] { "autoconfig", "beans", "configprops", "env",
"health", "info", "mappings", "metrics", "shutdown", "health", "mappings", "metrics", "shutdown",
"threaddump", "trace" }); "threaddump", "trace" });
}); });
...@@ -80,7 +81,7 @@ public class JmxEndpointIntegrationTests { ...@@ -80,7 +81,7 @@ public class JmxEndpointIntegrationTests {
MBeanServer mBeanServer = context.getBean(MBeanServer.class); MBeanServer mBeanServer = context.getBean(MBeanServer.class);
checkEndpointMBeans(mBeanServer, new String[] { "beans" }, checkEndpointMBeans(mBeanServer, new String[] { "beans" },
new String[] { "autoconfig", "configprops", "env", "health", new String[] { "autoconfig", "configprops", "env", "health",
"info", "mappings", "metrics", "shutdown", "mappings", "metrics", "shutdown",
"threaddump", "trace" }); "threaddump", "trace" });
}); });
} }
......
...@@ -69,10 +69,11 @@ public class WebMvcEndpointExposureIntegrationTests { ...@@ -69,10 +69,11 @@ public class WebMvcEndpointExposureIntegrationTests {
assertThat(isExposed(mvc, HttpMethod.GET, "configprops")).isFalse(); assertThat(isExposed(mvc, HttpMethod.GET, "configprops")).isFalse();
assertThat(isExposed(mvc, HttpMethod.GET, "env")).isFalse(); assertThat(isExposed(mvc, HttpMethod.GET, "env")).isFalse();
assertThat(isExposed(mvc, HttpMethod.GET, "health")).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, "mappings")).isFalse();
assertThat(isExposed(mvc, HttpMethod.GET, "metrics")).isFalse(); assertThat(isExposed(mvc, HttpMethod.GET, "metrics")).isFalse();
assertThat(isExposed(mvc, HttpMethod.POST, "shutdown")).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, "threaddump")).isFalse();
assertThat(isExposed(mvc, HttpMethod.GET, "trace")).isFalse(); assertThat(isExposed(mvc, HttpMethod.GET, "trace")).isFalse();
}); });
...@@ -93,6 +94,7 @@ public class WebMvcEndpointExposureIntegrationTests { ...@@ -93,6 +94,7 @@ public class WebMvcEndpointExposureIntegrationTests {
assertThat(isExposed(mvc, HttpMethod.GET, "mappings")).isTrue(); assertThat(isExposed(mvc, HttpMethod.GET, "mappings")).isTrue();
assertThat(isExposed(mvc, HttpMethod.GET, "metrics")).isTrue(); assertThat(isExposed(mvc, HttpMethod.GET, "metrics")).isTrue();
assertThat(isExposed(mvc, HttpMethod.POST, "shutdown")).isFalse(); 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, "threaddump")).isTrue();
assertThat(isExposed(mvc, HttpMethod.GET, "trace")).isTrue(); assertThat(isExposed(mvc, HttpMethod.GET, "trace")).isTrue();
}); });
...@@ -110,10 +112,11 @@ public class WebMvcEndpointExposureIntegrationTests { ...@@ -110,10 +112,11 @@ public class WebMvcEndpointExposureIntegrationTests {
assertThat(isExposed(mvc, HttpMethod.GET, "configprops")).isFalse(); assertThat(isExposed(mvc, HttpMethod.GET, "configprops")).isFalse();
assertThat(isExposed(mvc, HttpMethod.GET, "env")).isFalse(); assertThat(isExposed(mvc, HttpMethod.GET, "env")).isFalse();
assertThat(isExposed(mvc, HttpMethod.GET, "health")).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, "mappings")).isFalse();
assertThat(isExposed(mvc, HttpMethod.GET, "metrics")).isFalse(); assertThat(isExposed(mvc, HttpMethod.GET, "metrics")).isFalse();
assertThat(isExposed(mvc, HttpMethod.POST, "shutdown")).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, "threaddump")).isFalse();
assertThat(isExposed(mvc, HttpMethod.GET, "trace")).isFalse(); assertThat(isExposed(mvc, HttpMethod.GET, "trace")).isFalse();
}); });
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.springframework.boot.actuate.health; 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.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
...@@ -25,7 +26,7 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; ...@@ -25,7 +26,7 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 2.0.0 * @since 2.0.0
*/ */
@Endpoint(id = "status") @Endpoint(id = "status", defaultEnablement = DefaultEnablement.ENABLED)
public class StatusEndpoint { public class StatusEndpoint {
private final HealthIndicator healthIndicator; private final HealthIndicator healthIndicator;
......
...@@ -19,6 +19,7 @@ package org.springframework.boot.actuate.info; ...@@ -19,6 +19,7 @@ package org.springframework.boot.actuate.info;
import java.util.List; import java.util.List;
import java.util.Map; 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.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.util.Assert; import org.springframework.util.Assert;
...@@ -31,7 +32,7 @@ import org.springframework.util.Assert; ...@@ -31,7 +32,7 @@ import org.springframework.util.Assert;
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 2.0.0 * @since 2.0.0
*/ */
@Endpoint(id = "info") @Endpoint(id = "info", defaultEnablement = DefaultEnablement.ENABLED)
public class InfoEndpoint { public class InfoEndpoint {
private final List<InfoContributor> infoContributors; private final List<InfoContributor> infoContributors;
......
...@@ -1128,9 +1128,9 @@ content into your application; rather pick only the properties that you need. ...@@ -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]) # 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.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
endpoints.info.enabled= # Enable the info endpoint. endpoints.info.enabled=true # Enable the info endpoint.
endpoints.info.jmx.enabled= # Expose the info endpoint as a JMX MBean. endpoints.info.jmx.enabled=true # Expose the info endpoint as a JMX MBean.
endpoints.info.web.enabled= # Expose the info endpoint as a Web endpoint. endpoints.info.web.enabled=true # Expose the info endpoint as a Web endpoint.
# LIQUIBASE ENDPOINT ({sc-spring-boot-actuator}/endpoint/LiquibaseEndpoint.{sc-ext}[LiquibaseEndpoint]) # 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. 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. ...@@ -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]) # 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.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
endpoints.status.enabled= # Enable the status endpoint. endpoints.status.enabled=true # Enable the status endpoint.
endpoints.status.jmx.enabled= # Expose the status endpoint as a JMX MBean. endpoints.status.jmx.enabled=true # Expose the status endpoint as a JMX MBean.
endpoints.status.web.enabled= # Expose the status endpoint as a Web endpoint. 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]) # 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. endpoints.threaddump.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment