Class: ThreeScale::Backend::Stats::Aggregators::Usage

Inherits:
Object
  • Object
show all
Extended by:
Base, Keys
Defined in:
lib/3scale/backend/stats/aggregators/usage.rb

Class Method Summary collapse

Methods included from Base

aggregate_values, storage, storage_cmd

Methods included from Keys

application_key_prefix, application_response_code_value_key, application_usage_value_key, applications_key_prefix, changed_keys_bucket_key, changed_keys_key, counter_key, metric_key_prefix, response_code_key_prefix, service_key_prefix, service_response_code_value_key, service_usage_value_key, set_of_apps_with_traffic, transaction_keys

Methods included from ThreeScale::Backend::StorageKeyHelpers

#encode_key

Class Method Details

.aggregate(transaction, bucket = nil) ⇒ Object

Aggregates the usage of a transaction. If a bucket time is specified, all new or updated stats keys will be stored in a Redis Set.

Parameters:

  • transaction (Transaction)
  • bucket (String, Nil) (defaults to: nil)


19
20
21
22
23
24
25
26
27
# File 'lib/3scale/backend/stats/aggregators/usage.rb', line 19

def aggregate(transaction, bucket = nil)
  transaction.usage.each do |metric_id, raw_value|
    metric_keys = Keys.transaction_keys(transaction, :metric, metric_id)
    cmd         = storage_cmd(raw_value)
    value       = Backend::Usage.get_from raw_value

    aggregate_values(value, transaction.timestamp, metric_keys, cmd, bucket)
  end
end