You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/03/24 11:18:35 UTC
[camel] 02/02: CAMEL-17848: health-check - reported kind should be what kind the health-check is.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 10effd44e309c51c94907b561562f6e16f13c9c0
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Mar 24 12:17:48 2022 +0100
CAMEL-17848: health-check - reported kind should be what kind the health-check is.
---
.../org/apache/camel/impl/health/AbstractHealthCheck.java | 12 +++++++++---
.../camel/support/ScheduledPollConsumerHealthCheck.java | 11 +++++++++--
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java b/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
index ec2b1ac..c29ef1d 100644
--- a/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
+++ b/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
@@ -134,9 +134,15 @@ public abstract class AbstractHealthCheck implements HealthCheck, CamelContextAw
builder.state(registry.getInitialState());
// what kind of check is this
- HealthCheck.Kind kind = (Kind) options.getOrDefault(CHECK_KIND, Kind.ALL);
- builder.detail(CHECK_KIND, kind.name());
-
+ HealthCheck.Kind kind;
+ if (isLiveness() && isReadiness()) {
+ // if we can do both then use kind from what type we were invoked as
+ kind = (Kind) options.getOrDefault(CHECK_KIND, Kind.ALL);
+ } else {
+ // we can only be either live or ready so report that
+ kind = isLiveness() ? Kind.LIVENESS : Kind.READINESS;
+ }
+ builder.detail(CHECK_KIND, kind);
// Extract relevant information from meta data.
int invocationCount = (Integer) meta.getOrDefault(INVOCATION_COUNT, 0);
int failureCount = (Integer) meta.getOrDefault(FAILURE_COUNT, 0);
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumerHealthCheck.java b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumerHealthCheck.java
index e3a1f4b..089e04f 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumerHealthCheck.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumerHealthCheck.java
@@ -67,8 +67,15 @@ public class ScheduledPollConsumerHealthCheck implements HealthCheck {
builder.detail(FAILURE_ENDPOINT_URI, sanitizedUri);
// what kind of check is this
- HealthCheck.Kind kind = (Kind) options.getOrDefault(CHECK_KIND, Kind.ALL);
- builder.detail(CHECK_KIND, kind.name());
+ HealthCheck.Kind kind;
+ if (isLiveness() && isReadiness()) {
+ // if we can do both then use kind from what type we were invoked as
+ kind = (Kind) options.getOrDefault(CHECK_KIND, Kind.ALL);
+ } else {
+ // we can only be either live or ready so report that
+ kind = isLiveness() ? Kind.LIVENESS : Kind.READINESS;
+ }
+ builder.detail(CHECK_KIND, kind);
if (!isEnabled()) {
builder.message("Disabled");