From 891fb32251148d08860ad5680c0121e4c4ef085e Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Fri, 29 Sep 2023 19:41:06 -0500 Subject: [PATCH] squash: Abandon all hope ye who perform_start --- .../instrumentation/active_job/subscriber.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/subscriber.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/subscriber.rb index 42be26e64..b672f2b21 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/subscriber.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/subscriber.rb @@ -106,14 +106,11 @@ def initialize(...) mapper = AttributeMapper.new default_handler = DefaultHandler.new(tracer, mapper) enqueue_handler = EnqueueHandler.new(tracer, mapper) - # Rails 7 uses `perform` as the ingress point to the job - # Rails 6 uses `perform_start` as the ingress point of the job - consumer_event = Gem::Requirement.create('< 7').satisfied_by?(::ActiveJob.version) ? 'perform_start.active_job' : 'perform.active_job' @handlers_by_pattern = { 'enqueue.active_job' => enqueue_handler, 'enqueue_at.active_job' => enqueue_handler, - consumer_event => PerformHandler.new(tracer, mapper) + 'perform.active_job' => PerformHandler.new(tracer, mapper) } @handlers_by_pattern.default = default_handler end @@ -122,7 +119,11 @@ def initialize(...) def enqueue_at(...); end def enqueue(...); end def enqueue_retry(...); end - def perform_start(...); end + # This event causes much heartache as it is the first in a series of events that is triggered. + # It should not be the ingress span because it does not measure anything. + # https://github.com/rails/rails/blob/v6.1.7.6/activejob/lib/active_job/instrumentation.rb#L14 + # https://github.com/rails/rails/blob/v7.0.8/activejob/lib/active_job/instrumentation.rb#L19 + # def perform_start(...); end def perform(...); end def retry_stopped(...); end def discard(...); end