Class: Datadog::Core::Telemetry::Metric::Rate

Inherits:
IntervalMetric show all
Defined in:
lib/datadog/core/telemetry/metric.rb

Overview

The rate type takes the count and divides it by the length of the time interval. This is useful if you’re interested in the number of hits per second.

Constant Summary collapse

TYPE =
'rate'

Instance Attribute Summary

Attributes inherited from IntervalMetric

#interval

Attributes inherited from Base

#common, #name, #tags, #values

Instance Method Summary collapse

Methods inherited from IntervalMetric

#to_h

Methods inherited from Base

#id, #to_h

Constructor Details

#initialize(name, interval:, tags: {}, common: true) ⇒ Rate

Returns a new instance of Rate.



124
125
126
127
128
# File 'lib/datadog/core/telemetry/metric.rb', line 124

def initialize(name, interval:, tags: {}, common: true)
  super

  @value = 0.0
end

Instance Method Details

#track(value = 1.0) ⇒ Object



134
135
136
137
138
# File 'lib/datadog/core/telemetry/metric.rb', line 134

def track(value = 1.0)
  @value += value
  @values = [[Time.now.to_i, @value / interval]]
  nil
end

#typeObject



130
131
132
# File 'lib/datadog/core/telemetry/metric.rb', line 130

def type
  TYPE
end