Class: Ask::Monitoring::Metrics::ErrorCount
- Defined in:
- lib/ask/monitoring/metrics/error_count.rb
Overview
Computes error count over time chart data.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #as_chart_data ⇒ Object
-
#rate ⇒ Float
Error rate as a decimal (0.0 – 1.0).
Methods inherited from Base
Constructor Details
This class inherits a constructor from Ask::Monitoring::Metrics::Base
Instance Method Details
#as_chart_data ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/ask/monitoring/metrics/error_count.rb', line 6 def as_chart_data scope .where.not(error: nil) .group_by_period(:hour, :created_at) .count .map { |date, value| { date: date, value: value } } end |
#rate ⇒ Float
Returns Error rate as a decimal (0.0 – 1.0).
15 16 17 18 19 |
# File 'lib/ask/monitoring/metrics/error_count.rb', line 15 def rate total = scope.count return 0.0 if total.zero? scope.where.not(error: nil).count.to_f / total end |