Class: ScoutApm::ErrorService::Sidekiq
- Inherits:
-
Object
- Object
- ScoutApm::ErrorService::Sidekiq
show all
- Defined in:
- lib/scout_apm/error_service/sidekiq.rb
Defined Under Namespace
Classes: SidekiqExceptionMiddleware
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Sidekiq.
4
5
6
|
# File 'lib/scout_apm/error_service/sidekiq.rb', line 4
def initialize
@context = ScoutApm::Agent.instance.context
end
|
Instance Method Details
#install ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/scout_apm/error_service/sidekiq.rb', line 8
def install
return false unless defined?(::Sidekiq)
if ::Sidekiq::VERSION < "3"
install_sidekiq_with_middleware
else
install_sidekiq_with_error_handler
end
true
end
|
#install_sidekiq_with_error_handler ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/scout_apm/error_service/sidekiq.rb', line 29
def install_sidekiq_with_error_handler
::Sidekiq.configure_server do |config|
config.error_handlers << proc { |exception, job_info|
context = ScoutApm::Agent.instance.context
if context.ignored_exceptions.ignored?(exception)
raise
end
job_class =
begin
job_class = job_info[:job]["class"]
job_class = job_info[:job]["args"][0]["job_class"] if job_class == "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper"
job_class
rescue
"UnknownJob"
end
context.error_buffer.capture(exception, job_info.merge(:custom_controller => job_class))
}
end
end
|
#install_sidekiq_with_middleware ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/scout_apm/error_service/sidekiq.rb', line 20
def install_sidekiq_with_middleware
::Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add ScoutApm::ErrorService::Sidekiq::SidekiqExceptionMiddleware
end
end
end
|