Sha256: 55d2c670f31b9621aec77cf5c4bf8484b910a5c1ee4e4cc5e754398c5e49bfd7

Contents?: true

Size: 750 Bytes

Versions: 8

Compression:

Stored size: 750 Bytes

Contents

module Rhoconnect
  module Stats
    class Middleware
      def initialize(app)
        @app = app
      end

      def call(env)
        if Rhoconnect.stats || Rhoconnect::Server.stats
          start = Time.now.to_f
          status, headers, body = @app.call(env)
          finish = Time.now.to_f
          metric = "http:#{env['REQUEST_METHOD']}:#{env['PATH_INFO']}"
          source_name = env['rack.request.query_hash']["source_name"] if env['rack.request.query_hash']
          metric << ":#{source_name}" if source_name
          Record.save_average(metric,finish - start)
          [status, headers, body]
        else
          status, headers, body = @app.call(env)
          [status, headers, body]
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rhoconnect-3.2.1 lib/rhoconnect/stats/middleware.rb
rhoconnect-3.2.0 lib/rhoconnect/stats/middleware.rb
rhoconnect-3.2.0.beta5 lib/rhoconnect/stats/middleware.rb
rhoconnect-3.2.0.beta4 lib/rhoconnect/stats/middleware.rb
rhoconnect-3.2.0.beta3 lib/rhoconnect/stats/middleware.rb
rhoconnect-3.2.0.beta2 lib/rhoconnect/stats/middleware.rb
rhoconnect-3.2.0.beta1 lib/rhoconnect/stats/middleware.rb
rhoconnect-3.1.2 lib/rhoconnect/stats/middleware.rb