class Qless::Middleware::Sentry::SentryLogger
Logs a single exception to Sentry
, adding pertinent job info.
Public Class Methods
new(exception, job)
click to toggle source
# File lib/qless/middleware/sentry.rb, line 19 def initialize(exception, job) @exception, @job = exception, job end
Public Instance Methods
log()
click to toggle source
# File lib/qless/middleware/sentry.rb, line 23 def log event = ::Raven::Event.capture_exception(@exception) do |evt| evt.extra = { job: job_metadata } end safely_send event end
Private Instance Methods
job_history()
click to toggle source
We want to log formatted timestamps rather than integer timestamps
# File lib/qless/middleware/sentry.rb, line 56 def job_history @job.queue_history.map do |history_event| history_event.each_with_object({}) do |(key, value), hash| hash[key] = value.is_a?(Time) ? value.iso8601 : value end end end
job_metadata()
click to toggle source
# File lib/qless/middleware/sentry.rb, line 42 def job_metadata { jid: @job.jid, klass: @job.klass_name, history: job_history, data: @job.data, queue: @job.queue_name, worker: @job.worker_name, tags: @job.tags, priority: @job.priority } end
safely_send(event)
click to toggle source
# File lib/qless/middleware/sentry.rb, line 33 def safely_send(event) return unless event ::Raven.send_event(event) rescue # We don't want to silence our errors when the Sentry server # responds with an error. We'll still see the errors on the # Qless Web UI. end