Skip to content

Commit 8b9aba3

Browse files
authored
fix: ActiveJob::Handlers.unsubscribe (#1078)
Fix ActiveJob::Handlers.unsubscribe
1 parent 246fc10 commit 8b9aba3

File tree

2 files changed

+11
-1
lines changed
  • instrumentation/active_job

2 files changed

+11
-1
lines changed

instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def subscribe
6464
# Removes Event Handler Subscriptions for ActiveJob notifications
6565
# @note this method is not thread-safe and should not be used in a multi-threaded context
6666
def unsubscribe
67-
@subscriptions&.each { |subscriber| ActiveSupport::Notifications.unsubscribe(subscriber) }
67+
@subscriptions&.each { |subscriber| ::ActiveSupport::Notifications.unsubscribe(subscriber) }
6868
@subscriptions = nil
6969
end
7070
end

instrumentation/active_job/test/opentelemetry/instrumentation/active_job/handlers_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,14 @@
5050
_(MixedArgsJob.perform_now('arg1', 'arg2', keyword2: :keyword2)).must_be_nil # Make sure this runs without raising an error
5151
end
5252
end
53+
54+
describe 'usage' do
55+
it 'can unsubscribe' do
56+
_(OpenTelemetry::Instrumentation::ActiveJob::Handlers.instance_variable_get(:@subscriptions)).wont_be_empty
57+
58+
OpenTelemetry::Instrumentation::ActiveJob::Handlers.unsubscribe
59+
60+
_(OpenTelemetry::Instrumentation::ActiveJob::Handlers.instance_variable_get(:@subscriptions)).must_be_nil
61+
end
62+
end
5363
end

0 commit comments

Comments
 (0)