Async::HTTPSourceAsyncHTTPStatistics

class Statistics

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

Definitions

def self.start

Start tracking statistics from the current time.

Signature

returns Statistics

A new statistics instance.

Implementation

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

def initialize(start_time)

Initialize the statistics tracker.

Signature

parameter start_time Float

The start time for measuring durations.

Implementation

def initialize(start_time)
	@start_time = start_time
end

def wrap(response, &block)

Wrap a response body with a statistics-collecting wrapper.

Signature

parameter response Protocol::HTTP::Response

The response to wrap.

returns Protocol::HTTP::Response

The wrapped response.

Implementation

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