Sha256: 45c5f31f21d782a2f8d10c39089f788e4b5c3e2397c8b722f8baff8d2bf1ad2b

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 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
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oboe-2.6.0.2 lib/oboe/frameworks/padrino.rb