Class: SolidObserver::Services::CacheStats::TrendData
- Inherits:
-
Object
- Object
- SolidObserver::Services::CacheStats::TrendData
- Defined in:
- lib/solid_observer/services/cache_stats.rb
Defined Under Namespace
Classes: BucketSnapshot
Instance Method Summary collapse
-
#initialize(metric_rows:, window:, current_time:) ⇒ TrendData
constructor
A new instance of TrendData.
- #to_h ⇒ Object
Constructor Details
#initialize(metric_rows:, window:, current_time:) ⇒ TrendData
Returns a new instance of TrendData.
65 66 67 68 69 |
# File 'lib/solid_observer/services/cache_stats.rb', line 65 def initialize(metric_rows:, window:, current_time:) @metric_rows = metric_rows @window = window @current_time = current_time end |
Instance Method Details
#to_h ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/solid_observer/services/cache_stats.rb', line 71 def to_h return CacheStats::ACTIVITY_TREND_EMPTY.dup if metric_rows.empty? buckets = blank_buckets metric_rows.each do |row| buckets[align_bucket(row[0].to_i)]&.add(row) end { available: true, hit_rate: hit_rate_series(buckets), operations: count_series(buckets, :operations_count), errors: count_series(buckets, :errors_count) } end |