Class: Async::HTTP::Statistics

Inherits:
Object
  • Object
show all
Defined in:
lib/async/http/statistics.rb

Overview

Tracks response timing statistics including time to first byte and total duration.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_time) ⇒ Statistics

Initialize the statistics tracker.



22
23
24
# File 'lib/async/http/statistics.rb', line 22

def initialize(start_time)
	@start_time = start_time
end

Class Method Details

.startObject

Start tracking statistics from the current time.



16
17
18
# File 'lib/async/http/statistics.rb', line 16

def self.start
	self.new(Clock.now)
end

Instance Method Details

#wrap(response, &block) ⇒ Object

Wrap a response body with a statistics-collecting wrapper.



29
30
31
32
33
34
35
# File 'lib/async/http/statistics.rb', line 29

def wrap(response, &block)
	if response and response.body
		response.body = Body::Statistics.new(@start_time, response.body, block)
	end
	
	return response
end