Skip to content

Commit

Permalink
Merge pull request #46074 from xstefank/health-fixes
Browse files Browse the repository at this point in the history
SR Health observers docs + a few small naming fixes
  • Loading branch information
geoand authored Feb 6, 2025
2 parents 151795f + d6a35d8 commit f47e0f5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
31 changes: 31 additions & 0 deletions docs/src/main/asciidoc/smallrye-health.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,37 @@ public class LivenessAsync implements AsyncHealthCheck {
}
----

== Health status change observers

If you need to react to change of the health status of your application, the Smallrye Health
extension provides a CDI event that can notify you about the individual health status changes.

To observe the health status change, you can observe the `io.smallrye.health.api.event.HealthStatusChangeEvent`
with the standard CDI observation mechanism. Since we cannot guarantee that the observer method
runs all the time on the worker thread (meaning it can run on the event loop thread), it's
recommended that you never block in the in observer method.

[source,java]
----
import io.smallrye.health.api.event.HealthStatusChangeEvent;
@ApplicationScoped
public class HealthObserver {
public void observeHealthChange(@Observes @Default HealthStatusChangeEvent event) {
...
}
public void observeReadinessChange(@Observes @Readiness HealthStatusChangeEvent event) {
...
}
public void observeLivenessChange(@Observes @Liveness HealthStatusChangeEvent event) {
...
}
}
----

== Extension health checks

Some extension may provide default health checks, including the extension will automatically register its health checks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.restassured.RestAssured;
import io.restassured.parsing.Parser;

class DeactiveHealthWithConfigTest {
class DeactivateHealthWithConfigTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public interface SmallRyeHealthRuntimeConfig {
/**
* Specifications of checks that can be disabled.
*/
@ConfigDocMapKey("check-name")
@ConfigDocMapKey("check-classname")
Map<String, Enabled> check();

@ConfigGroup
public interface Enabled {
interface Enabled {

/**
* Whether the HealthCheck should be enabled.
Expand Down

0 comments on commit f47e0f5

Please sign in to comment.