Class: ElasticAPM::Spies::DelayedJobSpy Private
- Inherits:
-
Object
- Object
- ElasticAPM::Spies::DelayedJobSpy
- Defined in:
- lib/elastic_apm/spies/delayed_job.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- CLASS_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'.'
- METHOD_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'#'
- TYPE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'Delayed::Job'
Class Method Summary collapse
- .invoke_job(job, *args, &block) ⇒ Object private
- .job_name(job) ⇒ Object private
- .name_separator(payload_object) ⇒ Object private
- .object_name(payload_object) ⇒ Object private
- .performable_method_name(payload_object) ⇒ Object private
Instance Method Summary collapse
- #install ⇒ Object private
Class Method Details
.invoke_job(job, *args, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/elastic_apm/spies/delayed_job.rb', line 40 def self.invoke_job(job, *args, &block) job_name = job_name(job) transaction = ElasticAPM.start_transaction(job_name, TYPE) job.invoke_job_without_apm(*args, &block) transaction&.done 'success' transaction&.outcome = Transaction::Outcome::SUCCESS rescue ::Exception => e ElasticAPM.report(e, handled: false) transaction&.done 'error' transaction&.outcome = Transaction::Outcome::FAILURE raise ensure ElasticAPM.end_transaction end |
.job_name(job) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/elastic_apm/spies/delayed_job.rb', line 55 def self.job_name(job) payload_object = job.payload_object if payload_object.is_a?(::Delayed::PerformableMethod) performable_method_name(payload_object) elsif payload_object.instance_of?( ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper ) payload_object.job_data['job_class'] else payload_object.class.name end rescue job.name end |
.name_separator(payload_object) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 |
# File 'lib/elastic_apm/spies/delayed_job.rb', line 84 def self.name_separator(payload_object) payload_object.object.is_a?(Class) ? CLASS_SEPARATOR : METHOD_SEPARATOR end |
.object_name(payload_object) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
78 79 80 81 82 |
# File 'lib/elastic_apm/spies/delayed_job.rb', line 78 def self.object_name(payload_object) object = payload_object.object klass = object.is_a?(Class) ? object : object.class klass.name end |
.performable_method_name(payload_object) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 74 75 76 |
# File 'lib/elastic_apm/spies/delayed_job.rb', line 71 def self.performable_method_name(payload_object) class_name = object_name(payload_object) separator = name_separator(payload_object) method_name = payload_object.method_name "#{class_name}#{separator}#{method_name}" end |
Instance Method Details
#install ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/elastic_apm/spies/delayed_job.rb', line 29 def install ::Delayed::Backend::Base.class_eval do alias invoke_job_without_apm invoke_job def invoke_job(*args, &block) ::ElasticAPM::Spies::DelayedJobSpy .invoke_job(self, *args, &block) end end end |