From 36d96f94fa6b2a174a9f2d918f3e23fef9fd3757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Tue, 18 Apr 2023 10:08:52 -1000 Subject: [PATCH] Gracefully handle all exceptions We detect Riemann communication errors and in such circumstances, drop events and continue processing operations in order to cope with transient communication failures. Some network errors raise generic SocketError exceptions, OpenSSL::SSL::SSLError or EOFError exceptions. Such errors should likewise also be ignored instead of causing the program termination. --- lib/riemann/tools/riemann_client_wrapper.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/riemann/tools/riemann_client_wrapper.rb b/lib/riemann/tools/riemann_client_wrapper.rb index 58dd243e..bb1b4bba 100644 --- a/lib/riemann/tools/riemann_client_wrapper.rb +++ b/lib/riemann/tools/riemann_client_wrapper.rb @@ -25,11 +25,8 @@ def initialize(options) events << @queue.pop while !@queue.empty? && events.size < @max_bulk_size client.bulk_send(events) - rescue Riemann::Client::Error => e - warn "Dropping #{events.size} event#{'s' if events.size > 1} due to #{e}" rescue StandardError => e - warn "#{e.class} #{e}\n#{e.backtrace.join "\n"}" - Thread.main.terminate + warn "Dropping #{events.size} event#{'s' if events.size > 1} due to #{e}" end end