Skip to content

Commit ce371d3

Browse files
committed
Move appsignal calls to instrumentation
1 parent 1f302d5 commit ce371d3

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/gouda.rb

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def self.logger
7070
Gouda.config.logger
7171
end
7272

73+
def self.instrument(channel, **options, &block)
74+
ActiveSupport::Notifications.instrument("#{channel}.gouda", **options, &block)
75+
end
76+
77+
7378
def self.create_tables(active_record_schema)
7479
active_record_schema.create_enum :gouda_workload_state, %w[enqueued executing finished]
7580
active_record_schema.create_table :gouda_workloads, id: :uuid do |t|

lib/gouda/worker.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ def self.worker_loop(n_threads:, check_shutdown: TrapShutdownCheck.new, queue_co
163163
# Find jobs which just hung and clean them up (mark them as "finished" and enqueue replacement workloads if possible)
164164
Gouda::Workload.reap_zombie_workloads
165165
rescue => e
166-
Appsignal.add_exception(e)
166+
Gouda.instrument(:exception, exception: e)
167+
167168
warn "Uncaught exception during housekeeping (#{e.class} - #{e}"
168169
end
169170

lib/gouda/workload.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def self.reap_zombie_workloads
6363
workload.with_lock("FOR UPDATE SKIP LOCKED") do
6464
Gouda.logger.info { "Reviving (re-enqueueing) Gouda workload #{workload.id} after interruption" }
6565

66-
Appsignal.increment_counter("gouda_workloads_revived", 1, job_class: workload.active_job_class_name)
66+
Gouda.instrument(:workloads_revived_counter, size: 1, job_class: workload.active_job_class_name)
6767

6868
interrupted_at = workload.last_execution_heartbeat_at
6969
workload.update!(state: "finished", interrupted_at: interrupted_at, last_execution_heartbeat_at: Time.now.utc, execution_finished_at: Time.now.utc)

0 commit comments

Comments
 (0)