Module: ThreeScale::Backend::Stats::PeriodCommons

Defined in:
lib/3scale/backend/stats/period_commons.rb

Constant Summary collapse

SERVICE_GRANULARITIES =
%i[eternity month week day hour].map do |g|
  Period[g]
end.freeze
EXPANDED_GRANULARITIES =

For applications and users

(SERVICE_GRANULARITIES + [Period[:year], Period[:minute]]).freeze
EXCLUDED_FOR_BUCKETS =

We are not going to send metrics with granularity ‘eternity’ or ‘week’ to Kinesis, so there is no point in storing them in Redis buckets.

[Period[:eternity], Period[:week]].freeze

Class Method Summary collapse

Class Method Details

.expire_time_for_granularity(granularity) ⇒ Object



25
26
27
# File 'lib/3scale/backend/stats/period_commons.rb', line 25

def self.expire_time_for_granularity(granularity)
  GRANULARITY_EXPIRATION_TIME[granularity]
end

.granularities(metric_type) ⇒ Object

Return an array of granularities given a metric_type



21
22
23
# File 'lib/3scale/backend/stats/period_commons.rb', line 21

def self.granularities(metric_type)
  metric_type == :service ? SERVICE_GRANULARITIES : EXPANDED_GRANULARITIES
end