Module: Appsignal::Integrations::ActionCableIntegration

Defined in:
lib/appsignal/integrations/action_cable.rb

Instance Method Summary collapse

Instance Method Details

#perform_action(*args, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/appsignal/integrations/action_cable.rb', line 6

def perform_action(*args, &block)
  # The request is only the original websocket request
  env = connection.env
  request = ActionDispatch::Request.new(env)
  env[Appsignal::Hooks::ActionCableHook::REQUEST_ID] ||=
    request.request_id || SecureRandom.uuid

  transaction = Appsignal::Transaction.create(
    env[Appsignal::Hooks::ActionCableHook::REQUEST_ID],
    Appsignal::Transaction::ACTION_CABLE,
    request
  )

  begin
    super
  rescue Exception => exception # rubocop:disable Lint/RescueException
    transaction.set_error(exception)
    raise exception
  ensure
    transaction.params = args.first
    transaction.set_action_if_nil("#{self.class}##{args.first["action"]}")
    transaction.("path", request.path)
    transaction.("method", "websocket")
    Appsignal::Transaction.complete_current!
  end
end