davsclaus commented on code in PR #26754:
URL: https://github.com/apache/camel/pull/26754#discussion_r4080278939


##########
core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultErrorRegistry.java:
##########
@@ -206,10 +212,77 @@ private void capture(Exchange exchange, boolean handled) {
                 }
             }
         }
+        // count this kind of error and keep only a few of its exchanges, so a 
storm of one failure neither hides
+        // the count nor evicts everything else (CAMEL-24911)
+        String kind = kindOf(entry);
+        Repeat repeat = repeats.computeIfAbsent(kind, k -> new 
Repeat(timestamp));
+        long count = repeat.record(timestamp);
+        entry.setRepeat(count, repeat.first(), timestamp);
         entries.addFirst(entry);
+        evictKind(kind);
         evict();
     }
 
+    /** What makes two errors the same kind: the route, the node that failed, 
and the exception with its message. */
+    private static String kindOf(BacklogErrorEventMessage entry) {
+        return entry.getRouteId() + "|" + entry.getToNode() + "|" + 
entry.getExceptionType() + "|"
+               + entry.getExceptionMessage();

Review Comment:
   This is the same finding as the batch from 19:25, which is already answered 
above - the kind is now route, node and exception type with the message left 
out, the counters are bounded by maximumEntries, and the mbean keeps the 
getter/setter description pair the file already uses.



##########
core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultErrorRegistry.java:
##########
@@ -47,9 +48,14 @@
 public class DefaultErrorRegistry extends EventNotifierSupport implements 
ErrorRegistry {
 
     private final ConcurrentLinkedDeque<BacklogErrorEventMessage> entries = 
new ConcurrentLinkedDeque<>();
+    /** How often each kind of error happened, so a storm is counted while 
only a few of its exchanges are kept. */
+    private final Map<String, Repeat> repeats = new ConcurrentHashMap<>();
     private final AtomicLong uidCounter = new AtomicLong();
     private volatile boolean enabled;
     private volatile int maximumEntries = 100;
+    /** How many exchanges of the same kind of error are kept, so one storm 
does not push out the other errors. */
+    private volatile int maximumEntriesPerKind = 3;
+    private volatile int maximumKinds = 100;

Review Comment:
   This is the same finding as the batch from 19:25, which is already answered 
above - the kind is now route, node and exception type with the message left 
out, the counters are bounded by maximumEntries, and the mbean keeps the 
getter/setter description pair the file already uses.



##########
core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedErrorRegistryMBean.java:
##########
@@ -38,6 +38,12 @@ public interface ManagedErrorRegistryMBean extends 
ManagedServiceMBean {
     @ManagedAttribute(description = "Maximum number of error entries to keep")
     void setMaximumEntries(int maximumEntries);
 
+    @ManagedAttribute(description = "Maximum number of error entries of the 
same kind to keep")
+    int getMaximumEntriesPerKind();
+
+    @ManagedAttribute(description = "Maximum number of error entries of the 
same kind to keep")

Review Comment:
   This is the same finding as the batch from 19:25, which is already answered 
above - the kind is now route, node and exception type with the message left 
out, the counters are bounded by maximumEntries, and the mbean keeps the 
getter/setter description pair the file already uses.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to