Sha256: 6cdfad2393010eb9cd2203b24dbd94477a31a793d2c88700de3f631ce8adf3b3

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

module RailsPerformance
  class Middleware
    def initialize(app)
      @app = app
    end

    def call(env)
      @status, @headers, @response = @app.call(env)

      if record = Thread.current["RP_request_info"]
        record[:status] ||= @status

        # rand(100).times do |e|
        #   finished               = Time.now - rand(2000).minutes
        #   record[:datetime]      = finished.strftime(RailsPerformance::MetricsCollector::FORMAT)
        #   record[:datetimei]     = finished.to_i
        #   record[:duration]      = 50 + rand(100) + rand(50.0)
        #   record[:db_runtime]    = rand(50.0)
        #   record[:view_runtime]  = rand(50.0)
        #   RP::Utils.log_in_redis(record)
        # end

        RP::Utils.log_in_redis(record)

        Thread.current["RP_request_info"] = nil
      end

      [@status, @headers, @response]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_performance-0.0.1.6 lib/rails_performance/middleware.rb