Class: Yabeda::Latency::Collector
- Inherits:
-
Object
- Object
- Yabeda::Latency::Collector
- Defined in:
- lib/yabeda/latency/collector.rb
Overview
Collector is a Rack middleware that provides meaures the latency of an HTTP request based on the “X-Request-Start” header.
By default metrics all have the prefix “http_server”. Set ‘:metrics_prefix` to something else if you like.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
-
#call(env) ⇒ Object
:nodoc:.
-
#initialize(app, metrics_prefix: :http_server, debug: false) ⇒ Collector
constructor
A new instance of Collector.
Constructor Details
#initialize(app, metrics_prefix: :http_server, debug: false) ⇒ Collector
Returns a new instance of Collector.
17 18 19 20 21 22 23 |
# File 'lib/yabeda/latency/collector.rb', line 17 def initialize(app, metrics_prefix: :http_server, debug: false) @app = app @metrics_prefix = metrics_prefix @debug = debug init_request_metrics end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
15 16 17 |
# File 'lib/yabeda/latency/collector.rb', line 15 def app @app end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
15 16 17 |
# File 'lib/yabeda/latency/collector.rb', line 15 def registry @registry end |
Instance Method Details
#call(env) ⇒ Object
:nodoc:
25 26 27 28 29 30 31 |
# File 'lib/yabeda/latency/collector.rb', line 25 def call(env) # :nodoc: return @app.call(env) if env['rack.warming_up'] now = Time.now observe(env, now) @app.call(env) end |