Class: UnicornMetrics::RequestTimer
- Defined in:
- lib/unicorn_metrics/request_timer.rb
Overview
Timer defined to keep track of total elapsed request time Requires the UnicornMetrics::Middleware
Constant Summary collapse
- REQUEST_TIMERS =
[]
Constants inherited from Timer
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from Timer
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, method_name, path = nil) ⇒ RequestTimer
constructor
A new instance of RequestTimer.
- #path_method_match?(meth_val, path_val) ⇒ Boolean
Methods inherited from Timer
#as_json, #reset, #sum, #tick, #type
Constructor Details
#initialize(name, method_name, path = nil) ⇒ RequestTimer
Returns a new instance of RequestTimer.
12 13 14 15 16 17 |
# File 'lib/unicorn_metrics/request_timer.rb', line 12 def initialize(name, method_name, path=nil) @path = path @method_name = method_name.to_s REQUEST_TIMERS << self super(name) end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
5 6 7 |
# File 'lib/unicorn_metrics/request_timer.rb', line 5 def method_name @method_name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/unicorn_metrics/request_timer.rb', line 5 def path @path end |
Class Method Details
.notify(meth_val, path, elapsed_time) ⇒ Object
24 25 26 |
# File 'lib/unicorn_metrics/request_timer.rb', line 24 def self.notify(meth_val, path, elapsed_time) timers.each { |c| c.tick(elapsed_time) if c.path_method_match?(meth_val, path) } end |
.timers ⇒ Array<UnicornMetrics::RequestTimer>
20 |
# File 'lib/unicorn_metrics/request_timer.rb', line 20 def self.timers ; REQUEST_TIMERS ; end |
Instance Method Details
#path_method_match?(meth_val, path_val) ⇒ Boolean
31 32 33 |
# File 'lib/unicorn_metrics/request_timer.rb', line 31 def path_method_match?(meth_val, path_val) path_matches?(path_val) && method_matches?(meth_val) end |