Skip to content

Commit 99bfd18

Browse files
committed
Title the Active Job enqueue event with the job
The `enqueue.active_job` event carries an "enqueue <Class> job" title so the timeline shows which job was enqueued.
1 parent cb90121 commit 99bfd18

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

.changesets/instrument-active-job-enqueues.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Record the `enqueue.active_job` event from AppSignal's own Active Job
77
instrumentation rather than from Rails' native `enqueue.active_job`
88
notification, which is now suppressed so the enqueue is recorded once. The
99
event still shows up on the active transaction when enqueuing from within a web
10-
request or another job; there is no change to what you see.
10+
request or another job, and is now titled after the job being enqueued.

lib/appsignal/hooks/active_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def install
5656
# @!visibility private
5757
module ActiveJobEnqueueInstrumentation
5858
def enqueue(*, **)
59-
Appsignal.instrument("enqueue.active_job") do
59+
Appsignal.instrument("enqueue.active_job", "enqueue #{self.class.name} job") do
6060
# Active Job enqueues through an adapter (Sidekiq, Resque, ...) that
6161
# has its own enqueue instrumentation. Suppress it so the enqueue is
6262
# recorded once, as this event, rather than as nested Active Job +

spec/lib/appsignal/hooks/activejob_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,11 @@ def perform(*_args)
346346

347347
# Exactly one enqueue event: ours. Rails' native `enqueue.active_job`
348348
# notification is suppressed so it isn't recorded a second time.
349-
event_names = transaction.to_h["events"].map { |event| event["name"] }
350-
expect(event_names.count("enqueue.active_job")).to eq(1)
349+
enqueue_events =
350+
transaction.to_h["events"].select { |event| event["name"] == "enqueue.active_job" }
351+
expect(enqueue_events.size).to eq(1)
352+
# The event is titled after the job being enqueued.
353+
expect(enqueue_events.first["title"]).to eq("enqueue ActiveJobTestJob job")
351354
end
352355
end
353356

0 commit comments

Comments
 (0)