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

#==, #hash, #to_h

Methods inherited from Base

#==, #hash, #id, #to_h

Constructor Details

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

Returns a new instance of Rate.



146
147
148
149
150
# File 'lib/datadog/core/telemetry/metric.rb', line 146

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

  @value = 0.0
end

Instance Method Details

#track(value = 1.0) ⇒ Object



156
157
158
159
160
# File 'lib/datadog/core/telemetry/metric.rb', line 156

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

#typeObject



152
153
154
# File 'lib/datadog/core/telemetry/metric.rb', line 152

def type
  TYPE
end