Skip to content

Commit

Permalink
refactor: clean up and renames
Browse files Browse the repository at this point in the history
  • Loading branch information
arielvalentin committed Oct 9, 2023
1 parent 4f46f12 commit 5aa3549
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module Handlers
# 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 install
def subscribe
return unless Array(@subscriptions).empty?

tracer = Instrumentation.instance.tracer
Expand All @@ -61,7 +61,7 @@ def install

# Removes Event Handler Subscriptions for ActiveJob notifications
# @note this method is not thread safe and sholud not be used in a multi-threaded context
def uninstall
def unsubscribe
@subscriptions&.each { |subscriber| ActiveSupport::Notifications.unsubscribe(subscriber) }
@subscriptions = nil
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(tracer, mapper)
# @param payload [Hash] containing job run information
# @return [Hash] the payload passed as a method argument
def start(name, id, payload)
payload.merge!(__otel: on_start(name, id, payload))
payload.merge!(__otel: start_span(name, id, payload))
rescue StandardError => e
OpenTelemetry.handle_error(exception: e)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def require_dependencies
def patch_activejob
::ActiveJob::Base.prepend(Patches::Base) unless ::ActiveJob::Base.ancestors.include?(Patches::Base)

Handlers.install
Handlers.subscribe
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
let(:retry_span) { spans.find { |s| s.name == 'retry_stopped.active_job' } }

before do
OpenTelemetry::Instrumentation::ActiveJob::Handlers.uninstall
OpenTelemetry::Instrumentation::ActiveJob::Handlers.unsubscribe
instrumentation.instance_variable_set(:@config, config)
instrumentation.instance_variable_set(:@installed, false)

Expand Down

0 comments on commit 5aa3549

Please sign in to comment.