Sha256: de2560bf2bd39374ca7dfd69605cc5593398000b1952abd60ae906f25350f6be

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

module Appsignal
  module Rack
    class SinatraInstrumentation
      def initialize(app, options = {})
        Appsignal.logger.debug 'Initializing Appsignal::Rack::SinatraInstrumentation'
        @app, @options = app, options
      end

      def call(env)
        ActiveSupport::Notifications.instrument(
          'process_action.sinatra',
          raw_payload(env)
        ) do |payload|
          begin
            @app.call(env)
          ensure
            # This information is available only after the
            # request has been processed by Sinatra.
            payload[:action] = env['sinatra.route']
          end
        end
      end

      def raw_payload(env)
        request = @options.fetch(:request_class, ::Sinatra::Request).new(env)
        params = request.public_send(@options.fetch(:params_method, :params))
        {
          :params  => params,
          :session => request.session,
          :method  => request.request_method,
          :path    => request.path
        }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
appsignal-0.11.10 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.10.beta.2 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.10.beta.1 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.9 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.8.beta.4 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.8.beta.3 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.8.beta.2 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.8.beta.1 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.8.beta.0 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.7 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.7.beta.1 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.6 lib/appsignal/rack/sinatra_instrumentation.rb
appsignal-0.11.6.beta.0 lib/appsignal/rack/sinatra_instrumentation.rb