Sha256: 3ac9460d87aca3d6cd8eb957c3fdf309afbae3700193c607687383ca60329c51

Contents?: true

Size: 708 Bytes

Versions: 10

Compression:

Stored size: 708 Bytes

Contents

# frozen_string_literal: true

module Trifle
  module Logger
    module Middleware
      class Sidekiq
        def call(_worker, job, _queue)
          Trifle::Logger.tracer = tracer_for(job: job)
          yield
        rescue => e # rubocop:disable Style/RescueStandardError
          Trifle::Logger.tracer&.trace("Exception: #{e}", state: :error)
          Trifle::Logger.tracer&.fail!
          raise e
        ensure
          Trifle::Logger.tracer&.wrapup
        end

        def tracer_for(job:)
          return nil unless job['logger_key']

          Trifle::Logger.default.tracer_klass.new(
            key: job['logger_key'], meta: job['args']
          )
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
trifle-logger-0.2.2 lib/trifle/logger/middleware/sidekiq.rb
trifle-logger-0.2.1 lib/trifle/logger/middleware/sidekiq.rb
trifle-logger-0.2.0 lib/trifle/logger/middleware/sidekiq.rb
trifle-logger-0.1.4 lib/trifle/logger/middleware/sidekiq.rb
trifle-logger-0.1.3 lib/trifle/logger/middleware/sidekiq.rb
trifle-logger-0.1.2 lib/trifle/logger/middleware/sidekiq.rb
trifle-logger-0.1.1 lib/trifle/logger/middleware/sidekiq.rb
trifle-logger-0.1.0 lib/trifle/logger/middleware/sidekiq.rb
trifle-logger-0.0.2 lib/trifle/logger/middleware/sidekiq.rb
trifle-logger-0.0.1 lib/trifle/logger/middleware/sidekiq.rb