Class: DatadogCompoundMetrics::CompoundMetric

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog_compound_metrics/compound_metric.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ CompoundMetric

Returns a new instance of CompoundMetric.



8
9
10
11
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 8

def initialize(name)
  @name = name
  @calculations = []
end

Instance Attribute Details

#calculation_strategyObject

Returns the value of attribute calculation_strategy.



6
7
8
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 6

def calculation_strategy
  @calculation_strategy
end

#calculationsObject (readonly)

Returns the value of attribute calculations.



5
6
7
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 5

def calculations
  @calculations
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 5

def name
  @name
end

Instance Method Details

#add_calculation(calculation) ⇒ Object



13
14
15
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 13

def add_calculation(calculation)
  calculations << calculation
end

#computeObject



17
18
19
20
21
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 17

def compute
  calculations
    .map(&:call)
    .public_send(calculation_strategy)
end