Class: UnicornMetrics::RequestCounter
- Defined in:
- lib/unicorn_metrics/request_counter.rb
Overview
Counter defined to keep count of method types of http requests Requires the UnicornMetrics::Middleware
Constant Summary collapse
- METHOD_COUNTERS =
[]
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 Counter
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, method_name, path = nil) ⇒ RequestCounter
constructor
A new instance of RequestCounter.
- #path_method_match?(meth_val, path_val) ⇒ Boolean
Methods inherited from Counter
Constructor Details
#initialize(name, method_name, path = nil) ⇒ RequestCounter
Returns a new instance of RequestCounter.
12 13 14 15 16 17 |
# File 'lib/unicorn_metrics/request_counter.rb', line 12 def initialize(name, method_name, path=nil) @path = path @method_name = method_name.to_s.upcase METHOD_COUNTERS << 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_counter.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_counter.rb', line 5 def path @path end |
Class Method Details
.counters ⇒ Array<UnicornMetrics::RequestCounter>
20 |
# File 'lib/unicorn_metrics/request_counter.rb', line 20 def self.counters ; METHOD_COUNTERS ; end |
.notify(meth_val, path) ⇒ Object
24 25 26 |
# File 'lib/unicorn_metrics/request_counter.rb', line 24 def self.notify(meth_val, path) counters.each { |c| c.increment if c.path_method_match?(meth_val, path) } end |
Instance Method Details
#path_method_match?(meth_val, path_val) ⇒ Boolean
30 31 32 |
# File 'lib/unicorn_metrics/request_counter.rb', line 30 def path_method_match?(meth_val, path_val) path_matches?(path_val) && method_matches?(meth_val) end |