Class: Stackify::Metrics::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/stackify/metrics/metric.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(category, name, metric_type, metric_settings = nil) ⇒ Metric

Returns a new instance of Metric.



7
8
9
10
11
12
13
14
15
# File 'lib/stackify/metrics/metric.rb', line 7

def initialize category, name, metric_type, metric_settings = nil
  @category = category
  @name = name
  @metric_type = metric_type
  @occurred = Time.now.utc
  @occurred = get_rounded_time
  @is_increment = false
  @settings = metric_settings || MetricSettings.new
end

Instance Attribute Details

#aggregate_keyObject

Returns the value of attribute aggregate_key.



4
5
6
# File 'lib/stackify/metrics/metric.rb', line 4

def aggregate_key
  @aggregate_key
end

#categoryObject

Returns the value of attribute category.



4
5
6
# File 'lib/stackify/metrics/metric.rb', line 4

def category
  @category
end

#is_incrementObject

Returns the value of attribute is_increment.



4
5
6
# File 'lib/stackify/metrics/metric.rb', line 4

def is_increment
  @is_increment
end

#metric_typeObject

Returns the value of attribute metric_type.



4
5
6
# File 'lib/stackify/metrics/metric.rb', line 4

def metric_type
  @metric_type
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/stackify/metrics/metric.rb', line 4

def name
  @name
end

#occurredObject

Returns the value of attribute occurred.



4
5
6
# File 'lib/stackify/metrics/metric.rb', line 4

def occurred
  @occurred
end

#settingsObject

Returns the value of attribute settings.



4
5
6
# File 'lib/stackify/metrics/metric.rb', line 4

def settings
  @settings
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/stackify/metrics/metric.rb', line 4

def value
  @value
end

Instance Method Details

#calc_and_set_aggregate_keyObject



17
18
19
20
# File 'lib/stackify/metrics/metric.rb', line 17

def calc_and_set_aggregate_key
  @aggregate_key = @category.downcase + '-' + (@name || 'Missing Name').downcase +
                   '-' + @metric_type.to_s + '-' + get_rounded_time.to_s
end

#calc_name_keyObject



22
23
24
# File 'lib/stackify/metrics/metric.rb', line 22

def calc_name_key
  @category.downcase + '-' + (@name || 'Missing Name').downcase + '-' + @metric_type.to_s
end

#get_rounded_timeObject



26
27
28
# File 'lib/stackify/metrics/metric.rb', line 26

def get_rounded_time
  @occurred - @occurred.sec
end