Class: SnowmanIO::Spider::Mps
- Inherits:
-
Object
- Object
- SnowmanIO::Spider::Mps
- Defined in:
- lib/snowman-io/spider/mps.rb
Overview
Metrics per second
Instance Method Summary collapse
Instance Method Details
#grab ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/snowman-io/spider/mps.rb', line 5 def grab # work with raw datapoints for simplicity key = Utils.floor_5min(Time.now) value = Aggregation.where(precision: "5min", at: key).map(&:count).sum/300.0 prev_value = Aggregation.where(precision: "5min", at: key - 5.minutes).map(&:count).sum/300.0 name = "Metrics Per Second" app = App.where(system: true).first metric = app.metrics.where(name: name, kind: "amount").first_or_create! metric.update_attributes!(last_value: value, last_value_updated_at: Time.now) point = metric.data_points.where(at: key).first_or_create! point.update_attributes!(value: value) prev_point = metric.data_points.where(at: key - 5.minutes).first_or_create! prev_point.update_attributes!(value: prev_value) app.touch end |