Skip to content

Commit

Permalink
Gracefully handle all exceptions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
smortex committed Apr 20, 2023
1 parent bc936ce commit 36d96f9
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/riemann/tools/riemann_client_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 36d96f9

Please sign in to comment.