lib/logstash/outputs/charrington.rb in logstash-output-charrington-0.2.0 vs lib/logstash/outputs/charrington.rb in logstash-output-charrington-0.2.1

- old
+ new

@@ -21,31 +21,14 @@ # create a table via Charrington::CreateTable # or alter an existing one via Charrington::AlterTable class LogStash::Outputs::Charrington < LogStash::Outputs::Base concurrency :shared + config_name 'charrington' STRFTIME_FMT = '%Y-%m-%d %T.%L'.freeze - # RETRYABLE_SQLSTATE_CLASSES = [ - # # Classes of retryable SQLSTATE codes - # # Not all in the class will be retryable. However, this is the best that - # # we've got right now. - # # If a custom state code is required, set it in retry_sql_states. - # '08', # Connection Exception - # '24', # Invalid Cursor State (Maybe retry-able in some circumstances) - # '25', # Invalid Transaction State - # '40', # Transaction Rollback - # '53', # Insufficient Resources - # '54', # Program Limit Exceeded (MAYBE) - # '55', # Object Not In Prerequisite State - # '57', # Operator Intervention - # '58', # System Error - # ].freeze - - config_name 'charrington' - # Driver class - Reintroduced for https://github.com/theangryangel/logstash-output-jdbc/issues/26 config :driver_class, validate: :string # Does the JDBC driver support autocommit? config :driver_auto_commit, validate: :boolean, default: true, required: true @@ -118,12 +101,15 @@ opts = { connection: connection, schema: @schema, max_retries: @max_flush_exceptions, retry_initial_interval: @retry_initial_interval } - Charrington::Process.call(connection, event, opts) + rescue => e + @logger.error("Unable to process event. Event dropped. #{e.message}") + next + ensure connection.close unless connection.nil? end end def close @@ -199,11 +185,9 @@ log_text = 'JDBC - Exception. ' + (retrying ? 'Retrying' : 'Not retrying') log_method = (retrying ? 'warn' : 'error') loop do - # TODO reformat event output so that it only shows the fields necessary. - @logger.send(log_method, log_text, :exception => current_exception, :event => event) if current_exception.respond_to? 'getNextException' current_exception = current_exception.getNextException() else