Class: Errsight::Sidekiq::ServerMiddleware

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::ServerMiddleware
Defined in:
lib/errsight/sidekiq.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parameter_filterObject

Cached at class level — Rails.application.config.filter_parameters is effectively immutable after boot; rebuilding the ParameterFilter per job is wasted allocation on the hot path.



237
238
239
240
241
242
243
# File 'lib/errsight/sidekiq.rb', line 237

def self.parameter_filter
  return @parameter_filter if defined?(@parameter_filter)
  @parameter_filter =
    if defined?(::ActiveSupport::ParameterFilter) && defined?(::Rails) && ::Rails.application
      ::ActiveSupport::ParameterFilter.new(::Rails.application.config.filter_parameters)
    end
end

Instance Method Details

#call(worker, job, queue) ⇒ Object



121
122
123
124
125
126
127
128
129
130
# File 'lib/errsight/sidekiq.rb', line 121

def call(worker, job, queue)
  Errsight.with_scope(scope_for_job(job)) do
    run_with_capture(worker, job, queue) { yield }
  end
ensure
  # Match the dedup-set lifecycle from CaptureMiddleware: cleared at
  # job boundary so the next job on the same Sidekiq thread starts
  # fresh and isn't tricked into skipping a legitimately new error.
  Thread.current[:errsight_captured_exceptions] = nil
end