Sha256: abb18b71b99915a02b5886b2003459a29c431d3820010c021809b98bc71aec56
Contents?: true
Size: 1.9 KB
Versions: 7
Compression:
Stored size: 1.9 KB
Contents
require 'appsignal' module Appsignal::Integrations module PadrinoPlugin def self.init Appsignal.logger.info("Loading Padrino (#{Padrino::VERSION}) integration") root = Padrino.mounted_root Appsignal.config = Appsignal::Config.new(root, Padrino.env) Appsignal.start_logger(File.join(root, 'log')) Appsignal.start if Appsignal.active? Padrino.use(Appsignal::Rack::Listener) end end end end module Padrino::Routing::InstanceMethods alias route_without_appsignal route! 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 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 end Padrino.after_load do Appsignal::Integrations::PadrinoPlugin.init end
Version data entries
7 entries across 7 versions & 1 rubygems