Module: Appsignal::Hooks::ActiveJobHook::ActiveJobHelpers
- Defined in:
- lib/appsignal/hooks/active_job.rb
Constant Summary collapse
- ACTION_MAILER_CLASSES =
[ "ActionMailer::DeliveryJob", "ActionMailer::Parameterized::DeliveryJob", "ActionMailer::MailDeliveryJob" ].freeze
Class Method Summary collapse
- .action_name(job) ⇒ Object
- .add_distribution_value(key, value, tags = {}) ⇒ Object
- .increment_counter(key, value, tags = {}) ⇒ Object
-
.metrics_for(job) ⇒ Array
Returns an array of metrics with tags used to report the job metrics.
- .transaction_tags_for(job) ⇒ Object
Class Method Details
.action_name(job) ⇒ Object
172 173 174 175 176 177 178 179 |
# File 'lib/appsignal/hooks/active_job.rb', line 172 def self.action_name(job) case job["job_class"] when *ACTION_MAILER_CLASSES job["arguments"][0..1].join("#") else "#{job["job_class"]}#perform" end end |
.add_distribution_value(key, value, tags = {}) ⇒ Object
231 232 233 |
# File 'lib/appsignal/hooks/active_job.rb', line 231 def self.add_distribution_value(key, value, = {}) Appsignal.add_distribution_value("active_job_#{key}", value, ) end |
.increment_counter(key, value, tags = {}) ⇒ Object
227 228 229 |
# File 'lib/appsignal/hooks/active_job.rb', line 227 def self.increment_counter(key, value, = {}) Appsignal.increment_counter "active_job_#{key}", value, end |
.metrics_for(job) ⇒ Array
Returns an array of metrics with tags used to report the job metrics
If job ONLY has a queue, it will return queue_job_count with tags.
If job has a queue AND priority, it will ALSO return
queue_priority_job_count with tags.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/appsignal/hooks/active_job.rb', line 188 def self.metrics_for(job) = { :queue => job["queue_name"] } metrics = [["queue_job_count", ]] priority = job["priority"] if priority metrics << [ "queue_priority_job_count", .merge(:priority => priority) ] end metrics end |
.transaction_tags_for(job) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/appsignal/hooks/active_job.rb', line 203 def self.(job) = {} queue = job["queue_name"] [:queue] = queue if queue priority = job["priority"] [:priority] = priority if priority executions = job["executions"] [:executions] = executions.to_i + 1 if executions job_id = job["job_id"] [:active_job_id] = job_id provider_job_id = job["provider_job_id"] [:provider_job_id] = provider_job_id if provider_job_id request_id = provider_job_id || job_id [:request_id] = request_id if request_id end |