Class: Librato::Metrics::Collect
- Inherits:
-
Object
- Object
- Librato::Metrics::Collect
- Defined in:
- lib/librato/metrics/collect.rb
Constant Summary collapse
- MAX_RESULTS =
100
Class Method Summary collapse
-
.paginated_metrics(connection, path, query) ⇒ Object
Aggregates all results of paginated elements, requesting more collections as needed.
Class Method Details
.paginated_metrics(connection, path, query) ⇒ Object
Aggregates all results of paginated elements, requesting more collections as needed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/librato/metrics/collect.rb', line 12 def self.paginated_metrics connection, path, query results = [] response = connection.get(:path => path, :query => query, :expects => 200) parsed = MultiJson.decode(response.body) results = parsed["metrics"] return results if parsed["query"]["found"] <= MAX_RESULTS query[:offset] = MAX_RESULTS begin response = connection.get(:path => path, :query => query, :expects => 200) parsed = MultiJson.decode(response.body) results.push(*parsed["metrics"]) query[:offset] += MAX_RESULTS end while query[:offset] < parsed["query"]["found"] results end |