Sha256: c3fe1653cabf0448f1103d3d4f92efce43c8bef9b0bbf49278cda359a6ace3b4

Contents?: true

Size: 1.91 KB

Versions: 6

Compression:

Stored size: 1.91 KB

Contents

# Copyright (c) 2014 AppNeta, Inc.
# All rights reserved.

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

      def dispatch_with_oboe
        if Oboe.tracing?
          report_kvs = {}

          # Fall back to the raw tracing API so we can pass KVs
          # back on exit (a limitation of the Oboe::API.trace
          # block method) This removes the need for an info
          # event to send additonal KVs
          ::Oboe::API.log_entry('padrino', {})

          begin
            r = dispatch_without_oboe

            # Report Controller/Action as best possible
            if request.controller and not request.controller.empty?
              report_kvs[:Controller] = request.controller
            else
              report_kvs[:Controller] = self.class
            end

            report_kvs[:Action] = request.action
            r
           ensure
            ::Oboe::API.log_exit('padrino', report_kvs)
           end
        else
          dispatch_without_oboe
        end
      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.
  ::Oboe.logger.info "[oboe/loading] Instrumenting Padrino" if Oboe::Config[:verbose]

  require 'oboe/frameworks/padrino/templates'

  Padrino.after_load do
    ::Oboe.logger = ::Padrino.logger if ::Padrino.respond_to?(:logger)
    ::Oboe::Loading.load_access_key
    ::Oboe::Inst.load_instrumentation

    ::Oboe::Util.send_include(::Padrino::Routing::InstanceMethods, ::Oboe::PadrinoInst::Routing)
    if defined?(::Padrino::Rendering)
      ::Oboe::Util.send_include(::Padrino::Rendering::InstanceMethods, ::Oboe::PadrinoInst::Rendering)
    end
  
    # Report __Init after fork when in Heroku
    Oboe::API.report_init unless Oboe.heroku?
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
oboe-2.6.6.1 lib/oboe/frameworks/padrino.rb
oboe-2.6.5.5 lib/oboe/frameworks/padrino.rb
oboe-2.6.4.1 lib/oboe/frameworks/padrino.rb
oboe-2.6.3.0 lib/oboe/frameworks/padrino.rb
oboe-2.6.2.0 lib/oboe/frameworks/padrino.rb
oboe-2.6.1.0 lib/oboe/frameworks/padrino.rb