Skip to content

Commit 71d55d5

Browse files
authored
Take delayed_job job_name from job (#343)
`::Delayed::Job` has `name` method which calls `payload_object.display_name` See `<delayed_job>/lib/delayed/backend/base.rb`
1 parent 2f1e7e9 commit 71d55d5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/prometheus_exporter/instrumentation/delayed_job.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def initialize(client: nil)
4040

4141
def call(job, max_attempts, enqueued_count, pending_count, include_module_name, *args, &block)
4242
success = false
43+
job_name = job.handler.to_s.match(JOB_CLASS_REGEXP).to_a[include_module_name ? 1 : 2].to_s
44+
job_name ||= job.try(:name)
4345
start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
4446
latency = Time.current - job.run_at
4547
attempts = job.attempts + 1 # Increment because we're adding the current attempt
@@ -51,7 +53,7 @@ def call(job, max_attempts, enqueued_count, pending_count, include_module_name,
5153

5254
@client.send_json(
5355
type: "delayed_job",
54-
name: job.handler.to_s.match(JOB_CLASS_REGEXP).to_a[include_module_name ? 1 : 2].to_s,
56+
name: job_name,
5557
queue_name: job.queue,
5658
success: success,
5759
duration: duration,

0 commit comments

Comments
 (0)