lib/alephant/publisher/queue/sqs_helper/queue.rb in alephant-publisher-queue-1.4.1 vs lib/alephant/publisher/queue/sqs_helper/queue.rb in alephant-publisher-queue-2.0.0

- old
+ new

@@ -1,7 +1,7 @@ -require 'aws-sdk' -require 'alephant/logger' +require "aws-sdk" +require "alephant/logger" module Alephant module Publisher module Queue module SQSHelper @@ -17,29 +17,45 @@ @queue = queue @archiver = archiver @timeout = timeout @wait_time = wait_time - logger.debug("Queue#initialize: reading from #{queue.url}") + logger.info( + "event" => "QueueConfigured", + "queueUrl" => queue.url, + "archiver" => archiver, + "timeout" => timeout, + "method" => "#{self.class}#initialize" + ) end def message receive.tap { |m| process(m) unless m.nil? } end private def process(m) logger.metric "MessagesReceived" - logger.info("Queue#message: received #{m.id}") + logger.info( + "event" => "QueueMessageReceived", + "messageId" => m.id, + "method" => "#{self.class}#process" + ) archive m end def archive(m) archiver.see(m) unless archiver.nil? rescue StandardError => e logger.metric "ArchiveFailed" - logger.warn("Queue#archive: archive failed (#{e.message})"); + logger.error( + "event" => "MessageArchiveFailed", + "class" => e.class, + "message" => e.message, + "backtrace" => e.backtrace.join.to_s, + "method" => "#{self.class}#archive" + ) end def receive queue.receive_message({ :visibility_timeout => timeout,