Sha256: bec2b4c12bd10e8e5b7586f6449655d092d54accd1e66fbd3dc79aaf2c6b7712

Contents?: true

Size: 686 Bytes

Versions: 3

Compression:

Stored size: 686 Bytes

Contents

require 'rails_autoscale_agent/logger'

module RailsAutoscaleAgent
  class Collector
    extend Logger

    def self.collect(request, store)
      if request.entered_queue_at
        if request.entered_queue_at < (Time.now - 60 * 10)
          # ignore unreasonable values
          logger.info "request queued for more than 10 minutes... skipping collection"
        else
          queue_time_millis = ((Time.now - request.entered_queue_at) * 1000).to_i
          queue_time_millis = 0 if queue_time_millis < 0
          store.push(queue_time_millis)
          logger.info "Collected queue_time=#{queue_time_millis}ms request_id=#{request.id}"
        end
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_autoscale_agent-0.3.1 lib/rails_autoscale_agent/collector.rb
rails_autoscale_agent-0.3.0 lib/rails_autoscale_agent/collector.rb
rails_autoscale_agent-0.2.0 lib/rails_autoscale_agent/collector.rb