Module: OpenTelemetry::Instrumentation::ActionPack::Handlers

Defined in:
lib/opentelemetry/instrumentation/action_pack/handlers.rb,
lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb

Overview

Module that contains custom event handlers, which are used to generate spans per event

Defined Under Namespace

Classes: ActionController

Class Method Summary collapse

Class Method Details

.subscribeObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/opentelemetry/instrumentation/action_pack/handlers.rb', line 16

def subscribe
  return unless Array(@subscriptions).empty?

  config = ActionPack::Instrumentation.instance.config
  handlers_by_pattern = {
    'process_action.action_controller' => Handlers::ActionController.new(config)
  }

  @subscriptions = handlers_by_pattern.map do |key, handler|
    ::ActiveSupport::Notifications.subscribe(key, handler)
  end
end

.unsubscribeObject

Note:

this method is not thread-safe and should not be used in a multi-threaded context

Removes Event Handler Subscriptions for Action Controller notifications



31
32
33
34
# File 'lib/opentelemetry/instrumentation/action_pack/handlers.rb', line 31

def unsubscribe
  @subscriptions&.each { |subscriber| ::ActiveSupport::Notifications.unsubscribe(subscriber) }
  @subscriptions = nil
end