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
a33c3eec
Commit
a33c3eec
authored
Dec 14, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Add InfluxDb health indicator"
Closes gh-11159
parent
cdbdc1cb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
23 deletions
+38
-23
InfluxDbHealthIndicatorAutoConfiguration.java
...gure/influx/InfluxDbHealthIndicatorAutoConfiguration.java
+4
-3
additional-spring-configuration-metadata.json
...es/META-INF/additional-spring-configuration-metadata.json
+6
-0
InfluxDbHealthIndicatorAutoConfigurationTests.java
...influx/InfluxDbHealthIndicatorAutoConfigurationTests.java
+10
-11
InfluxDbHealthIndicator.java
...framework/boot/actuate/infux/InfluxDbHealthIndicator.java
+4
-3
InfluxDbHealthIndicatorTests.java
...ork/boot/actuate/influx/InfluxDbHealthIndicatorTests.java
+10
-6
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
production-ready-features.adoc
...oot-docs/src/main/asciidoc/production-ready-features.adoc
+3
-0
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java
View file @
a33c3eec
...
@@ -37,7 +37,7 @@ import org.springframework.context.annotation.Configuration;
...
@@ -37,7 +37,7 @@ import org.springframework.context.annotation.Configuration;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link InfluxDbHealthIndicator}.
* {@link EnableAutoConfiguration Auto-configuration} for {@link InfluxDbHealthIndicator}.
*
*
* @author Eddú Meléndez
* @author Eddú Meléndez
* @since 2.0.0
* @since 2.0.0
*/
*/
...
@@ -57,8 +57,9 @@ public class InfluxDbHealthIndicatorAutoConfiguration extends
...
@@ -57,8 +57,9 @@ public class InfluxDbHealthIndicatorAutoConfiguration extends
}
}
@Bean
@Bean
@ConditionalOnMissingBean
(
name
=
"influx
d
bHealthIndicator"
)
@ConditionalOnMissingBean
(
name
=
"influx
D
bHealthIndicator"
)
public
HealthIndicator
influx
d
bHealthIndicator
()
{
public
HealthIndicator
influx
D
bHealthIndicator
()
{
return
createHealthIndicator
(
this
.
influxDbs
);
return
createHealthIndicator
(
this
.
influxDbs
);
}
}
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json
View file @
a33c3eec
...
@@ -103,6 +103,12 @@
...
@@ -103,6 +103,12 @@
"description"
:
"Whether to enable elasticsearch health check."
,
"description"
:
"Whether to enable elasticsearch health check."
,
"defaultValue"
:
true
"defaultValue"
:
true
},
},
{
"name"
:
"management.influxdb.jms.enabled"
,
"type"
:
"java.lang.Boolean"
,
"description"
:
"Whether to enable InfluxDB health check."
,
"defaultValue"
:
true
},
{
{
"name"
:
"management.health.jms.enabled"
,
"name"
:
"management.health.jms.enabled"
,
"type"
:
"java.lang.Boolean"
,
"type"
:
"java.lang.Boolean"
,
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java
View file @
a33c3eec
...
@@ -23,7 +23,6 @@ import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAuto
...
@@ -23,7 +23,6 @@ import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAuto
import
org.springframework.boot.actuate.health.ApplicationHealthIndicator
;
import
org.springframework.boot.actuate.health.ApplicationHealthIndicator
;
import
org.springframework.boot.actuate.infux.InfluxDbHealthIndicator
;
import
org.springframework.boot.actuate.infux.InfluxDbHealthIndicator
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
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
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -33,35 +32,35 @@ import static org.mockito.Mockito.mock;
...
@@ -33,35 +32,35 @@ import static org.mockito.Mockito.mock;
/**
/**
* Tests for {@link InfluxDbHealthIndicatorAutoConfiguration}.
* Tests for {@link InfluxDbHealthIndicatorAutoConfiguration}.
*
*
* @author Eddú Meléndez
* @author Eddú Meléndez
*/
*/
public
class
InfluxDbHealthIndicatorAuto
n
ConfigurationTests
{
public
class
InfluxDbHealthIndicatorAutoConfigurationTests
{
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
InfluxDbConfiguration
.
class
,
.
withUserConfiguration
(
InfluxDbConfiguration
.
class
)
.
withConfiguration
(
AutoConfigurations
.
of
(
InfluxDbHealthIndicatorAutoConfiguration
.
class
,
InfluxDbHealthIndicatorAutoConfiguration
.
class
,
HealthIndicatorAutoConfiguration
.
class
));
HealthIndicatorAutoConfiguration
.
class
));
@Test
@Test
public
void
runShouldCreateIndicator
()
throws
Exception
{
public
void
runShouldCreateIndicator
()
{
this
.
contextRunner
.
run
((
context
)
->
assertThat
(
context
)
this
.
contextRunner
.
run
((
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
InfluxDbHealthIndicator
.
class
)
.
hasSingleBean
(
InfluxDbHealthIndicator
.
class
)
.
doesNotHaveBean
(
ApplicationHealthIndicator
.
class
));
.
doesNotHaveBean
(
ApplicationHealthIndicator
.
class
));
}
}
@Test
@Test
public
void
runWhenDisabledShouldNotCreateIndicator
()
throws
Exception
{
public
void
runWhenDisabledShouldNotCreateIndicator
()
{
this
.
contextRunner
this
.
contextRunner
.
withPropertyValues
(
"management.health.influxdb.enabled:false"
).
run
(
.
withPropertyValues
(
"management.health.influxdb.enabled:false"
).
run
(
(
context
)
->
assertThat
(
context
)
(
context
)
->
assertThat
(
context
)
.
doesNotHaveBean
(
InfluxDbHealthIndicator
.
class
)
.
doesNotHaveBean
(
InfluxDbHealthIndicator
.
class
)
.
hasSingleBean
(
ApplicationHealthIndicator
.
class
));
.
hasSingleBean
(
ApplicationHealthIndicator
.
class
));
}
}
@Configuration
@Configuration
@AutoConfigureBefore
(
InfluxDbHealthIndicatorAutoConfiguration
.
class
)
static
class
InfluxDbConfiguration
{
protected
static
class
InfluxDbConfiguration
{
@Bean
@Bean
public
InfluxDB
influxdb
()
{
public
InfluxDB
influxdb
()
{
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/infux/InfluxDbHealthIndicator.java
View file @
a33c3eec
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
actuate
.
infux
;
package
org
.
springframework
.
boot
.
actuate
.
infux
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.dto.Pong
;
import
org.springframework.boot.actuate.health.AbstractHealthIndicator
;
import
org.springframework.boot.actuate.health.AbstractHealthIndicator
;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.boot.actuate.health.Health
;
...
@@ -39,9 +40,9 @@ public class InfluxDbHealthIndicator extends AbstractHealthIndicator {
...
@@ -39,9 +40,9 @@ public class InfluxDbHealthIndicator extends AbstractHealthIndicator {
}
}
@Override
@Override
protected
void
doHealthCheck
(
Health
.
Builder
builder
)
throws
Exception
{
protected
void
doHealthCheck
(
Health
.
Builder
builder
)
{
String
version
=
this
.
influxDb
.
version
();
Pong
pong
=
this
.
influxDb
.
ping
();
builder
.
up
().
withDetail
(
"version"
,
version
);
builder
.
up
().
withDetail
(
"version"
,
pong
.
getVersion
()
);
}
}
}
}
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java
View file @
a33c3eec
...
@@ -20,6 +20,7 @@ import java.io.IOException;
...
@@ -20,6 +20,7 @@ import java.io.IOException;
import
org.influxdb.InfluxDB
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.InfluxDBException
;
import
org.influxdb.InfluxDBException
;
import
org.influxdb.dto.Pong
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.boot.actuate.health.Health
;
...
@@ -39,26 +40,29 @@ import static org.mockito.Mockito.verify;
...
@@ -39,26 +40,29 @@ import static org.mockito.Mockito.verify;
public
class
InfluxDbHealthIndicatorTests
{
public
class
InfluxDbHealthIndicatorTests
{
@Test
@Test
public
void
influxdbIsUp
()
{
public
void
influxDbIsUp
()
{
Pong
pong
=
mock
(
Pong
.
class
);
given
(
pong
.
getVersion
()).
willReturn
(
"0.9"
);
InfluxDB
influxDB
=
mock
(
InfluxDB
.
class
);
InfluxDB
influxDB
=
mock
(
InfluxDB
.
class
);
given
(
influxDB
.
version
()).
willReturn
(
"0.9"
);
given
(
influxDB
.
ping
()).
willReturn
(
pong
);
InfluxDbHealthIndicator
healthIndicator
=
new
InfluxDbHealthIndicator
(
influxDB
);
InfluxDbHealthIndicator
healthIndicator
=
new
InfluxDbHealthIndicator
(
influxDB
);
Health
health
=
healthIndicator
.
health
();
Health
health
=
healthIndicator
.
health
();
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
health
.
getDetails
().
get
(
"version"
)).
isEqualTo
(
"0.9"
);
assertThat
(
health
.
getDetails
().
get
(
"version"
)).
isEqualTo
(
"0.9"
);
verify
(
influxDB
).
version
();
verify
(
influxDB
).
ping
();
}
}
@Test
@Test
public
void
influx
d
bIsDown
()
{
public
void
influx
D
bIsDown
()
{
InfluxDB
influxDB
=
mock
(
InfluxDB
.
class
);
InfluxDB
influxDB
=
mock
(
InfluxDB
.
class
);
given
(
influxDB
.
version
()).
willThrow
(
given
(
influxDB
.
ping
()).
willThrow
(
new
InfluxDBException
(
new
IOException
(
"Connection failed"
)));
new
InfluxDBException
(
new
IOException
(
"Connection failed"
)));
InfluxDbHealthIndicator
healthIndicator
=
new
InfluxDbHealthIndicator
(
influxDB
);
InfluxDbHealthIndicator
healthIndicator
=
new
InfluxDbHealthIndicator
(
influxDB
);
Health
health
=
healthIndicator
.
health
();
Health
health
=
healthIndicator
.
health
();
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
assertThat
((
String
)
health
.
getDetails
().
get
(
"error"
))
assertThat
((
String
)
health
.
getDetails
().
get
(
"error"
))
.
contains
(
"Connection failed"
);
.
contains
(
"Connection failed"
);
verify
(
influxDB
).
version
();
verify
(
influxDB
).
ping
();
}
}
}
}
spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
a33c3eec
...
@@ -1224,6 +1224,7 @@ content into your application. Rather, pick only the properties that you need.
...
@@ -1224,6 +1224,7 @@ content into your application. Rather, pick only the properties that you need.
management.health.elasticsearch.indices= # Comma-separated index names.
management.health.elasticsearch.indices= # Comma-separated index names.
management.health.elasticsearch.response-timeout=100ms # The time to wait for a response from the cluster.
management.health.elasticsearch.response-timeout=100ms # The time to wait for a response from the cluster.
management.health.jms.enabled=true # Whether to enable JMS health check.
management.health.jms.enabled=true # Whether to enable JMS health check.
management.health.influxdb.enabled=true # Whether to enable InfluxDB health check.
management.health.ldap.enabled=true # Whether to enable LDAP health check.
management.health.ldap.enabled=true # Whether to enable LDAP health check.
management.health.mail.enabled=true # Whether to enable Mail health check.
management.health.mail.enabled=true # Whether to enable Mail health check.
management.health.mongo.enabled=true # Whether to enable MongoDB health check.
management.health.mongo.enabled=true # Whether to enable MongoDB health check.
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc
View file @
a33c3eec
...
@@ -368,6 +368,9 @@ The following `HealthIndicators` are auto-configured by Spring Boot when appropr
...
@@ -368,6 +368,9 @@ The following `HealthIndicators` are auto-configured by Spring Boot when appropr
|{sc-spring-boot-actuator}/elasticsearch/ElasticsearchHealthIndicator.{sc-ext}[`ElasticsearchHealthIndicator`]
|{sc-spring-boot-actuator}/elasticsearch/ElasticsearchHealthIndicator.{sc-ext}[`ElasticsearchHealthIndicator`]
|Checks that an Elasticsearch cluster is up.
|Checks that an Elasticsearch cluster is up.
|{sc-spring-boot-actuator}/influx/InfluxDbHealthIndicator.{sc-ext}[`InfluxDbHealthIndicator`]
|Checks that an InfluxDB server is up.
|{sc-spring-boot-actuator}/jms/JmsHealthIndicator.{sc-ext}[`JmsHealthIndicator`]
|{sc-spring-boot-actuator}/jms/JmsHealthIndicator.{sc-ext}[`JmsHealthIndicator`]
|Checks that a JMS broker is up.
|Checks that a JMS broker is up.
...
...
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