module Resque::Plugins::RestashLogger

Public Instance Methods

after_enqueue_logstash_logger(*args) click to toggle source

Executed on the enqueueing instance

# File lib/restash_rails/resque/plugins/restash_logger.rb, line 22
def after_enqueue_logstash_logger(*args)
  log 'Enqueued', args, :debug
end
after_perform_logstash_logger(*args) click to toggle source
# File lib/restash_rails/resque/plugins/restash_logger.rb, line 11
def after_perform_logstash_logger(*args)
  @job_end_time = Time.now
  log 'Finished', args, :debug
end
after_schedule_send_monitor_data(*args) click to toggle source
# File lib/restash_rails/resque/plugins/restash_logger.rb, line 26
def after_schedule_send_monitor_data(*args)
  log 'Scheduled', args, :debug
end
before_perform_logstash_logger(*args) click to toggle source

Executed on the Resque worker

# File lib/restash_rails/resque/plugins/restash_logger.rb, line 5
def before_perform_logstash_logger(*args)
  @resque_job_uuid = SecureRandom.uuid
  @job_start_time = Time.now
  log 'Executing', args, :debug
end
log(log_message, args, severity = :info) click to toggle source
# File lib/restash_rails/resque/plugins/restash_logger.rb, line 30
def log(log_message, args, severity = :info)
  extra_data = args.is_a?(Array) ? args.last : args
  log_arguments = { log_message: log_message, extra_data: extra_data, class: self.name, log_tag: :resque_hooks }
  if args.is_a?(Array) && args.first.is_a?(Exception)
    exception = args.first
    log_arguments[:exception] = { class: exception.class.to_s, message: exception.message.to_s, backtrace: exception.backtrace }
  end
  log_arguments[:exec_run_time] = @job_end_time - @job_start_time if @job_start_time.present? && @job_end_time.present?
  log_arguments[:resque_job_uuid] = @resque_job_uuid if @resque_job_uuid.present?
  Rails.logger.send(severity, log_arguments)
end
on_failure_logstash_logger(*args) click to toggle source
# File lib/restash_rails/resque/plugins/restash_logger.rb, line 16
def on_failure_logstash_logger(*args)
  @job_end_time = Time.now
  log 'Failed', args, :error
end