Class: EventMachine::Middleware::Metrics
- Inherits:
-
Object
- Object
- EventMachine::Middleware::Metrics
- Defined in:
- lib/em-http-metrics.rb
Instance Method Summary collapse
-
#initialize(metrics) ⇒ Metrics
constructor
A new instance of Metrics.
- #request(client, head, body) ⇒ Object
- #response(resp) ⇒ Object
Constructor Details
#initialize(metrics) ⇒ Metrics
Returns a new instance of Metrics.
14 15 16 17 |
# File 'lib/em-http-metrics.rb', line 14 def initialize(metrics) @metrics = metrics @conn = {} end |
Instance Method Details
#request(client, head, body) ⇒ Object
19 20 21 22 |
# File 'lib/em-http-metrics.rb', line 19 def request(client, head, body) @conn[client.hash] = Time.new [head, body] end |
#response(resp) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/em-http-metrics.rb', line 24 def response(resp) = Time.new t = - @conn[resp.hash] @conn.delete resp.hash @metrics << { :time => t, :timestamp => , :status => resp.response_header.status, :uri => resp.req.uri.to_s } resp end |