Sha256: ea0508e8890ade7ec9b0a9dbfd0da64f1759ae901d9007c59d8e2e61b0e6fcc7
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
# frozen_string_literal: true module PlainApm module Hooks class ActiveJob < ActiveSupportSubscriber NOTIFICATION_PATTERN = /\A[^!]\w+\.active_job\Z/.freeze private def notification_pattern NOTIFICATION_PATTERN end def payload(event) name, base = common_attributes(event) payload = event.payload job = payload[:job] base.merge!({ "queue_name" => job.queue_name, "job_id" => job.job_id, "job_class" => job.class.name, "job_arguments" => job.arguments, "executions" => job.executions, "enqueued_at" => enqueued_at(job), "dequeued_at" => dequeued_at(job), "scheduled_at" => job.scheduled_at, "adapter" => payload[:adapter].class.name, "aborted" => payload[:aborted] }) case name when "enqueue", "enqueue_at", "perform" base when "enqueue_retry" base.merge({ "error" => payload[:error], "wait" => payload[:wait] }) when "retry_stopped", "discard" base.merge({ "error" => payload[:error] }) when "perform_start" nil end end private def enqueued_at(job) Time.parse(job.enqueued_at).to_f if job.enqueued_at end def dequeued_at(job) Time.parse(job.dequeued_at).to_f if job.respond_to?(:dequeued_at) && job.dequeued_at end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plain_apm-0.6.7 | lib/plain_apm/hooks/active_job.rb |