lib/sentry/inst_jobs/plugin.rb in sentry-inst_jobs-1.0.2 vs lib/sentry/inst_jobs/plugin.rb in sentry-inst_jobs-5.10.0
- old
+ new
@@ -4,22 +4,23 @@
module Sentry
module InstJobs
class Plugin < ::Delayed::Plugin
# need to symbolize strings as keyword arguments in Ruby 2.4~2.6
INST_JOBS_CONTEXT_KEY = :"Inst-Jobs"
+ OP_NAME = "inst_jobs"
callbacks do |lifecycle|
lifecycle.around(:invoke_job) do |job, *args, &block|
next block.call(job, *args) unless Sentry.initialized?
Sentry.with_scope do |scope|
contexts = generate_contexts(job)
- scope.set_transaction_name(contexts.dig(INST_JOBS_CONTEXT_KEY, :job_class))
+ scope.set_transaction_name(contexts.dig(INST_JOBS_CONTEXT_KEY, :job_class), source: :task)
scope.set_contexts(**contexts)
scope.set_tags("inst_jobs.queue" => job.queue, "inst_jobs.id" => job.id.to_s)
- transaction = Sentry.start_transaction(name: scope.transaction_name, op: "inst_jobs")
+ transaction = Sentry.start_transaction(name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME)
scope.set_span(transaction) if transaction
begin
block.call(job, *args)
@@ -46,10 +47,13 @@
queue: job.queue,
created_at: job.created_at,
last_error: job.last_error&.byteslice(0..1000),
handler: job.handler&.byteslice(0..1000),
job_class: compute_job_class(job.payload_object),
+ tag: job.tag,
+ strand: job.strand,
+ singleton: job.singleton,
}
context
end
@@ -74,10 +78,10 @@
job.attempts >= job.max_attempts.pred
end
def self.finish_transaction(transaction, status)
return unless transaction
-
+
transaction.set_http_status(status)
transaction.finish
end
end
end