From 6d2fbf8bbd7f90133a25c63a16ba27d4236edf83 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Thu, 9 Nov 2023 08:27:26 -0600 Subject: [PATCH] fix: Use top level namespaces When used in conjunction with the `OpenTelemetry::Instrumenation::ActiveSupport`, the classloader would mistakenly use the wrong namespace and raises a `NameError`. This change updates references to ensure we use top level namespaces to load the appropriate classes. --- .../lib/opentelemetry/instrumentation/active_job/handlers.rb | 2 +- .../opentelemetry/instrumentation/active_job/instrumentation.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers.rb index 9c14f65e1..c1061ed71 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers.rb @@ -57,7 +57,7 @@ def subscribe } @subscriptions = handlers_by_pattern.map do |key, handler| - ActiveSupport::Notifications.subscribe("#{key}.active_job", handler) + ::ActiveSupport::Notifications.subscribe("#{key}.active_job", handler) end end diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb index 260f5fc45..c76427f6d 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb @@ -17,7 +17,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base end present do - defined?(::ActiveJob) + defined?(::ActiveJob) && defined?(::ActiveSupport) end compatible do