Module: Padrino::Routing::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#get_payload_action(request) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/appsignal/integrations/padrino.rb', line 46

def get_payload_action(request)
  # Short-circut is there's no request object to obtain information from
  return "#{settings.name}" if request.nil?

  # Older versions of Padrino work with a route object
  route_obj = defined?(request.route_obj) && request.route_obj
  if route_obj && route_obj.respond_to?(:original_path)
    return "#{settings.name}:#{request.route_obj.original_path}"
  end

  # Newer versions expose the action / controller on the request class
  request_data = request.respond_to?(:action) ? request.action : request.fullpath
  "#{settings.name}:#{request.controller}##{request_data}"
end

#route!(base = settings, pass_block = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/appsignal/integrations/padrino.rb', line 24

def route!(base = settings, pass_block = nil)
  if env['sinatra.static_file']
    route_without_appsignal(base, pass_block)
  else
    request_payload = {
      :params  => request.params,
      :session => request.session,
      :method  => request.request_method,
      :path    => request.path
    }
    ActiveSupport::Notifications.instrument('process_action.padrino', request_payload) do |request_payload|
      begin
        route_without_appsignal(base, pass_block)
      rescue => e
        Appsignal.add_exception(e); raise e
      ensure
        request_payload[:action] = get_payload_action(request)
      end
    end
  end
end

#route_without_appsignalObject



22
# File 'lib/appsignal/integrations/padrino.rb', line 22

alias route_without_appsignal route!