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/10/23 09:27:43 UTC

[camel] 04/05: CAMEL-18639: camel-health - Add detail for last time there was a failure

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 02ca24721d70614816d64767fac465ae8fa6978d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Oct 23 11:27:06 2022 +0200

    CAMEL-18639: camel-health - Add detail for last time there was a failure
---
 .../java/org/apache/camel/impl/health/AbstractHealthCheck.java   | 9 +++++++++
 1 file changed, 9 insertions(+)

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 a40322ec5aa..654c47e2e83 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
@@ -185,6 +185,11 @@ public abstract class AbstractHealthCheck implements HealthCheck, CamelContextAw
             // reset failure since it ok
             failureCount = 0;
             successCount++;
+            if (successTime == null) {
+                // first time we are OK, then reset failure as we only want to capture
+                // failures that is happening after we have been ok (such as during bootstrap)
+                failureTime = null;
+            }
             successTime = invocationTime;
         }
 
@@ -193,10 +198,14 @@ public abstract class AbstractHealthCheck implements HealthCheck, CamelContextAw
         meta.put(FAILURE_COUNT, failureCount);
         if (failureTime != null) {
             meta.put(FAILURE_TIME, failureTime);
+        } else {
+            meta.remove(FAILURE_TIME);
         }
         meta.put(SUCCESS_COUNT, successCount);
         if (successTime != null) {
             meta.put(SUCCESS_TIME, successTime);
+        } else {
+            meta.remove(SUCCESS_TIME);
         }
 
         // Copy some meta-data bits to the response attributes so the