Class: ThreeScale::Backend::Metric::Collection
- Inherits:
-
Object
- Object
- ThreeScale::Backend::Metric::Collection
- Includes:
- Storable
- Defined in:
- lib/3scale/backend/metric/collection.rb
Instance Method Summary collapse
-
#initialize(service_id) ⇒ Collection
constructor
A new instance of Collection.
-
#process_usage(raw_usage, flat_usage = false) ⇒ Object
Accepts usage as => value, … and converts it into => value, …, evaluating also metric hierarchy.
Methods included from Storable
Methods included from StorageKeyHelpers
Constructor Details
#initialize(service_id) ⇒ Collection
Returns a new instance of Collection.
7 8 9 10 11 |
# File 'lib/3scale/backend/metric/collection.rb', line 7 def initialize(service_id) @service_id = service_id @metric_ids = {} @parent_ids = {} end |
Instance Method Details
#process_usage(raw_usage, flat_usage = false) ⇒ Object
Accepts usage as => value, … and converts it into => value, …, evaluating also metric hierarchy.
Example
Let’s supose there is a metric called “hits” with id 1001 and it has one child metric called “search_queries” with id 1002. Then:
metrics.process_usage('search_queries' => 42)
will produce:
{1001 => 42, 1002 => 42}
27 28 29 30 31 |
# File 'lib/3scale/backend/metric/collection.rb', line 27 def process_usage(raw_usage, flat_usage = false) return {} unless raw_usage usage = parse_usage(raw_usage) flat_usage ? usage : process_parents(usage) end |