Module: Rollbar::Delayed
- Defined in:
- lib/rollbar/plugins/delayed_job/plugin.rb,
lib/rollbar/plugins/delayed_job/job_data.rb
Defined Under Namespace
Classes: JobData, RollbarPlugin
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.wrapped ⇒ Object
Returns the value of attribute wrapped.
7
8
9
|
# File 'lib/rollbar/plugins/delayed_job/plugin.rb', line 7
def wrapped
@wrapped
end
|
Class Method Details
.build_job_data(job) ⇒ Object
82
83
84
85
86
|
# File 'lib/rollbar/plugins/delayed_job/plugin.rb', line 82
def self.build_job_data(job)
return nil unless ::Rollbar.configuration.report_dj_data
JobData.new(job).to_hash
end
|
.invoke_job_callback ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/rollbar/plugins/delayed_job/plugin.rb', line 48
def self.invoke_job_callback
proc do |job, *args, &block|
begin
if Rollbar.configuration.dj_use_scoped_block
data = Rollbar::Delayed.build_job_data(job)
Rollbar.scoped(:request => data) { block.call(job, *args) }
else
block.call(job, *args)
end
rescue StandardError => e
report(e, job)
raise e
end
end
end
|
.report(e, job) ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/rollbar/plugins/delayed_job/plugin.rb', line 65
def self.report(e, job)
return if skip_report?(job)
data = build_job_data(job)
::Rollbar.scope(:request => data)
.error(e, :use_exception_level_filters => true)
end
|
.skip_report?(job) ⇒ Boolean
74
75
76
77
78
79
80
|
# File 'lib/rollbar/plugins/delayed_job/plugin.rb', line 74
def self.skip_report?(job)
handler = ::Rollbar.configuration.async_skip_report_handler
return handler.call(job) if handler.respond_to?(:call)
job.attempts < ::Rollbar.configuration.dj_threshold
end
|
.wrap_worker ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/rollbar/plugins/delayed_job/plugin.rb', line 34
def self.wrap_worker
return if wrapped
::Delayed::Worker.plugins << RollbarPlugin
self.wrapped = true
end
|
.wrap_worker! ⇒ Object
42
43
44
45
46
|
# File 'lib/rollbar/plugins/delayed_job/plugin.rb', line 42
def self.wrap_worker!
self.wrapped = false
wrap_worker
end
|