Class: Rack::QueueMetrics::QueueDepth

Inherits:
Object
  • Object
show all
Includes:
Notify
Defined in:
lib/queue-metrics/queue_depth.rb

Instance Method Summary collapse

Methods included from Notify

#notify, #should_notify?

Constructor Details

#initialize(app, logger = nil) ⇒ QueueDepth

Returns a new instance of QueueDepth.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/queue-metrics/queue_depth.rb', line 10

def initialize(app, logger = nil)
  @app             = app
  @addr            = getaddr
  @instrument_name = "rack.queue-metrics.queue-depth"
  @logger          = logger
  if @logger.nil?
    @logger = ::Logger.new($stdout)
    @logger.formatter = L2MetFormatter.new
  end

  Thread.new {report(1)}
end

Instance Method Details

#call(env) ⇒ Object



23
24
25
26
27
# File 'lib/queue-metrics/queue_depth.rb', line 23

def call(env)
  return @app.call(env) unless ENV['PORT']
  status, headers, body = @app.call(env)
  [status, headers, body]
end