Sha256: b85029d737afcf83676c56db83395d8f0f0613311e38bda7999275fdf1b5849f

Contents?: true

Size: 1.79 KB

Versions: 16

Compression:

Stored size: 1.79 KB

Contents

# Copyright (c) 2016 SolarWinds, LLC.
# All rights reserved.

module AppOpticsAPM
  module PadrinoInst
    module Routing
      def self.included(klass)
        ::AppOpticsAPM::Util.method_alias(klass, :dispatch!, ::Padrino::Routing)
      end

      def dispatch_with_appoptics

        ::AppOpticsAPM::API.log_entry('padrino', {})

        result = dispatch_without_appoptics

        # Report Controller/Action and Transaction as best possible
        report_kvs = {}
        controller = (request.controller && !request.controller.empty?) ? request.controller : nil
        report_kvs[:Controller] = controller || self.class
        report_kvs[:Action] = request.route_obj ? request.route_obj.path : request.action
        env['appoptics_apm.controller'] = report_kvs[:Controller]
        env['appoptics_apm.action']     = report_kvs[:Action]

        result
      ensure
        ::AppOpticsAPM::API.log_exit('padrino', report_kvs)
      end
    end
  end
end

if defined?(::Padrino)
  # This instrumentation is a superset of the Sinatra instrumentation similar
  # to how Padrino is a superset of Sinatra itself.
  ::AppOpticsAPM.logger.info '[appoptics_apm/loading] Instrumenting Padrino' if AppOpticsAPM::Config[:verbose]

  require 'appoptics_apm/frameworks/padrino/templates'

  Padrino.after_load do
    ::AppOpticsAPM.logger = ::Padrino.logger if ::Padrino.respond_to?(:logger)
    ::AppOpticsAPM::Inst.load_instrumentation

    ::AppOpticsAPM::Util.send_include(::Padrino::Routing::InstanceMethods, ::AppOpticsAPM::PadrinoInst::Routing)
    if defined?(::Padrino::Rendering)
      ::AppOpticsAPM::Util.send_include(::Padrino::Rendering::InstanceMethods, ::AppOpticsAPM::PadrinoInst::Rendering)
    end

    # Report __Init after fork when in Heroku
    AppOpticsAPM::API.report_init unless AppOpticsAPM.heroku?
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
appoptics_apm-4.2.3 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.2.2 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.2.1 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.2.0 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.1.2 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.0.9 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.1.1 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.0.8 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.1.0 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.0.7 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.0.6 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.0.5 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.0.4 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.0.3 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.0.2 lib/appoptics_apm/frameworks/padrino.rb
appoptics_apm-4.0.1-x86_64-linux lib/appoptics_apm/frameworks/padrino.rb