Sha256: c9e81488dd2fe3801465fe373ac8e76ae6d5c5a2f702ed1a9b6d79ea348bc67b
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true # Sidekiq middleware that adds basic sidekiq metadata to all log lines. module Loggery module Metadata module Middleware class Sidekiq include Loggery::Util # Clients can provide their own error handler class << self attr_accessor(:error_handler) { ->(e) { Sidekiq::Logging.logger.error(e) } } end def call(_worker, msg, queue) Loggery::Metadata::Store.with_metadata(jid: msg["jid"], thread_id: Thread.current.object_id.to_s(36), worker: msg["class"], args: msg["args"].inspect, queue: queue, retry_count: msg["retry_count"], worker_type: "sidekiq") do log_job_runtime(:sidekiq_job, "#{msg['class']} (#{msg['args']})") do begin yield rescue StandardError => e # Log exceptions here, otherwise they won't have the metadata available anymore by # the time they reach the Sidekiq default error handler. self.class.error_handler&.call(e) raise e end end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
loggery-0.1.0 | lib/loggery/metadata/middleware/sidekiq.rb |