Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
40e6f004
Commit
40e6f004
authored
Sep 12, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable info and status endpoints by default
Closes gh-10161
parent
222ed44b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
13 deletions
+39
-13
HealthEndpointAutoConfigurationTests.java
...onfigure/health/HealthEndpointAutoConfigurationTests.java
+14
-0
InfoEndpointAutoConfigurationTests.java
...utoconfigure/info/InfoEndpointAutoConfigurationTests.java
+6
-0
JmxEndpointIntegrationTests.java
...onfigure/integrationtest/JmxEndpointIntegrationTests.java
+4
-3
WebMvcEndpointExposureIntegrationTests.java
...tegrationtest/WebMvcEndpointExposureIntegrationTests.java
+5
-2
StatusEndpoint.java
...g/springframework/boot/actuate/health/StatusEndpoint.java
+2
-1
InfoEndpoint.java
...a/org/springframework/boot/actuate/info/InfoEndpoint.java
+2
-1
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+6
-6
No files found.
spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointAutoConfigurationTests.java
View file @
40e6f004
...
@@ -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
{
...
...
spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfigurationTests.java
View file @
40e6f004
...
@@ -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
{
...
...
spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java
View file @
40e6f004
...
@@ -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"
});
});
});
}
}
...
...
spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java
View file @
40e6f004
...
@@ -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"
)).
is
Fals
e
();
assertThat
(
isExposed
(
mvc
,
HttpMethod
.
GET
,
"info"
)).
is
Tru
e
();
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"
)).
is
Fals
e
();
assertThat
(
isExposed
(
mvc
,
HttpMethod
.
GET
,
"info"
)).
is
Tru
e
();
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
();
});
});
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/StatusEndpoint.java
View file @
40e6f004
...
@@ -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
;
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoEndpoint.java
View file @
40e6f004
...
@@ -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
;
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
40e6f004
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment