Sha256: eed7ace6614c3dc426fa31ea4c26ef4c627314aa7f59dbf9e7845cd1e83e6a2a

Contents?: true

Size: 810 Bytes

Versions: 36

Compression:

Stored size: 810 Bytes

Contents

require 'rhoconnect/middleware/helpers'

module Rhoconnect
  module Middleware
    class Stats
      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
          Rhoconnect::Stats::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

36 entries across 36 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 lib/rhoconnect/middleware/stats.rb
rhoconnect-7.5.1 lib/rhoconnect/middleware/stats.rb
rhoconnect-7.4.1 lib/rhoconnect/middleware/stats.rb
rhoconnect-7.1.17 lib/rhoconnect/middleware/stats.rb
rhoconnect-6.2.0 lib/rhoconnect/middleware/stats.rb
rhoconnect-6.0.11 lib/rhoconnect/middleware/stats.rb
rhoconnect-5.5.18 lib/rhoconnect/middleware/stats.rb
rhoconnect-5.5.17 lib/rhoconnect/middleware/stats.rb
rhoconnect-5.5.15 lib/rhoconnect/middleware/stats.rb
rhoconnect-5.5.0.22 lib/rhoconnect/middleware/stats.rb
rhoconnect-5.5.2 lib/rhoconnect/middleware/stats.rb
rhoconnect-5.5.0.7 lib/rhoconnect/middleware/stats.rb
rhoconnect-5.5.0.3 lib/rhoconnect/middleware/stats.rb
rhoconnect-5.5.0 lib/rhoconnect/middleware/stats.rb
rhoconnect-5.1.1 lib/rhoconnect/middleware/stats.rb
rhoconnect-4.0.4 lib/rhoconnect/middleware/stats.rb
rhoconnect-4.0.3 lib/rhoconnect/middleware/stats.rb
rhoconnect-4.0.2 lib/rhoconnect/middleware/stats.rb
rhoconnect-4.0.1 lib/rhoconnect/middleware/stats.rb
rhoconnect-4.0.0 lib/rhoconnect/middleware/stats.rb