Sha256: a770aa754cb3e135948ff702df9df55b630299b95f0d093331388f43b802a891

Contents?: true

Size: 1.12 KB

Versions: 23

Compression:

Stored size: 1.12 KB

Contents

require 'rack'

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

      def call(env)
        if Appsignal.active?
          call_with_appsignal_monitoring(env)
        else
          @app.call(env)
        end
      end

      def call_with_appsignal_monitoring(env)
        request = ActionDispatch::Request.new(env)
        transaction = Appsignal::Transaction.create(
          env['action_dispatch.request_id'],
          Appsignal::Transaction::HTTP_REQUEST,
          request
        )
        begin
          @app.call(env)
        rescue => error
          transaction.set_error(error)
          raise error
        ensure
          transaction.set_http_or_background_action
          transaction.set_http_or_background_queue_start
          transaction.set_metadata('path', request.path)
          transaction.set_metadata('method', request.request_method)
          Appsignal::Transaction.complete_current!
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
appsignal-0.12.beta.54 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.53 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.52 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.51 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.50 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.49 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.48 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.47 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.46 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.45 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.44 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.43 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.42 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.41 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.40 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.39 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.38 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.37 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.36 lib/appsignal/rack/rails_instrumentation.rb
appsignal-0.12.beta.35 lib/appsignal/rack/rails_instrumentation.rb