Class: UnicornMetrics::ResponseCounter
- Defined in:
- lib/unicorn_metrics/response_counter.rb
Overview
Counter defined to keep count of status codes of http responses Requires the UnicornMetrics::Middleware
Constant Summary collapse
- STATUS_COUNTERS =
[]
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Attributes inherited from Counter
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, status_code, path = nil) ⇒ ResponseCounter
constructor
A new instance of ResponseCounter.
- #path_status_match?(status, path) ⇒ Boolean
Methods inherited from Counter
Constructor Details
#initialize(name, status_code, path = nil) ⇒ ResponseCounter
Returns a new instance of ResponseCounter.
12 13 14 15 16 17 |
# File 'lib/unicorn_metrics/response_counter.rb', line 12 def initialize(name, status_code, path=nil) @path = path @status_code = status_code STATUS_COUNTERS << self super(name) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/unicorn_metrics/response_counter.rb', line 5 def path @path end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
5 6 7 |
# File 'lib/unicorn_metrics/response_counter.rb', line 5 def status_code @status_code end |
Class Method Details
.counters ⇒ Array<UnicornMetrics::ResponseCounter>
20 |
# File 'lib/unicorn_metrics/response_counter.rb', line 20 def self.counters ; STATUS_COUNTERS ; end |
.notify(status, path) ⇒ Object
25 26 27 |
# File 'lib/unicorn_metrics/response_counter.rb', line 25 def self.notify(status, path) counters.each { |c| c.increment if c.path_status_match?(status, path) } end |
Instance Method Details
#path_status_match?(status, path) ⇒ Boolean
31 32 33 |
# File 'lib/unicorn_metrics/response_counter.rb', line 31 def path_status_match?(status,path) status_matches?(status) && path_matches?(path) end |