-
Notifications
You must be signed in to change notification settings - Fork 3k
Add health checks for Mongodb, Kafka and Neo4j #5222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add health checks for Mongodb, Kafka and Neo4j #5222
Conversation
This looks great. Here is an idea: would it be possible to enable them automatically if the |
Ah ignore my idea, I think you already do that :) Awesome! |
@ConfigRoot(name = "neo4j", phase = ConfigPhase.BUILD_TIME) | ||
public class Neo4jBuildTimeConfig { | ||
/** | ||
* Whether or not an healt check is published in case the smallrye-health extension is present (default to true). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can remove the (default to true)
from the description. It will be automatically picked from ConfigItem during doc generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but the JavaDoc is also usefull for Quarkus developpers :)
Maybe I could but best is to make it after to keep all health check enabled comments the same (agroal, these 3 new ones, kafka-streams)
@gunnarmorling can you review the Kafka health check implementation and some question I raised inside the PR description ? |
driver.verifyConnectivity(); | ||
return builder.build(); | ||
} catch (Exception e) { | ||
return builder.down().withData("reason", e.getMessage()).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that it matters much, so just nitpicking that it is a little weird if you first call up()
and then change it to down()
. To me reading this, the first impression was "So this always returns 'up', why?". You could call up()
only after verifyConnectivity()
passes. Otherwise a big +1 from me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constuct is inspired by the Agroal health check because of multiple datasource support. When we will support multiple MongoDB connection/ Kafka connection / ... this construct will be needed (because you will fails the health check if one of the multiple connection fails).
So better keep it this way.
Can someone review the Kafka part and gives feedback of the fact that I choose to disabled the health check by default (rational is in the issue description)? Maybe @gunnarmorling or @cescoffier ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @loicmathieu; a few comments on the Kafka part.
...client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaBuildTimeConfig.java
Outdated
Show resolved
Hide resolved
...kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java
Outdated
Show resolved
Hide resolved
extensions/neo4j/deployment/src/main/java/io/quarkus/neo4j/deployment/Neo4jBuildTimeConfig.java
Outdated
Show resolved
Hide resolved
...ions/kafka-client/runtime/src/main/java/io/quarkus/kafka/client/health/KafkaHealthCheck.java
Show resolved
Hide resolved
4d8f254
to
d3c1314
Compare
Just a heads up that I started a review of this one. I'm working on the Qute PR today but will get back to this one soon. |
@gunnarmorling WDYT regarding my latests comments on this PR? |
...client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaBuildTimeConfig.java
Outdated
Show resolved
Hide resolved
d3c1314
to
3043525
Compare
3043525
to
c033695
Compare
I rebase on master to fix a conflict. @gsmet did you have time to review it as you intended ? |
c033695
to
94b59e3
Compare
I adjusted a few things. |
docs/src/main/asciidoc/mongodb.adoc
Outdated
|
||
So when you access the `/health/ready` endpoint of your application you will have information about the connection validation status. | ||
|
||
This behavior can be disabled via the property `quarkus.mongodb.health.enabled`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior can be disabled via the property `quarkus.mongodb.health.enabled`. | |
This behavior can be disabled by setting the property `quarkus.mongodb.health.enabled` to `false` in your `application.properties`. |
Same for the others.
@ConfigRoot(name = "kafka", phase = ConfigPhase.BUILD_TIME) | ||
public class KafkaBuildTimeConfig { | ||
/** | ||
* Whether or not an health check is published in case the smallrye-health extension is present (default to false). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Whether or not an health check is published in case the smallrye-health extension is present (default to false). | |
* Whether or not an health check is published in case the smallrye-health extension is present (defaults to false). |
Merged, thanks. |
@gsmet you move the bootstrap server property from the standard one to a quarkus specific one. |
Having two separate properties for reactive streams and health is very confusing. The need for additional property in "Guides" can be easily overlooked. Please emphasize that in the documentation, or add all messaging bootstrap servers automatically. IMHO health check should not be general Kafka health check, but rather reactive messaging specific one; otherwise, whoever writes a Kafka client should somehow register it with health check functionality. |
This fixes #5073
This is a draft PR as the Kafka health check is subject to discussion:
quarkus-kafka-client
that didn't provides any Kafka client inside CDI.kafka.bootstrap.servers
as a temporary solution : a better solution should be to scan all properties and find the one that defines a Kafka cluster (from mp-messaging or kafka-stream config) and creates an AdminClient for each.When #3343 lands in, we must impact the MongoDB health check to check all the mongo clients.