Class: Datadog::Core::Telemetry::Metric::Rate
- Inherits:
-
IntervalMetric
- Object
- Base
- IntervalMetric
- Datadog::Core::Telemetry::Metric::Rate
- 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
Attributes inherited from Base
#common, #name, #tags, #values
Instance Method Summary collapse
-
#initialize(name, interval:, tags: {}, common: true) ⇒ Rate
constructor
A new instance of Rate.
- #track(value = 1.0) ⇒ Object
- #type ⇒ Object
Methods inherited from IntervalMetric
Methods inherited from Base
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 |
#type ⇒ Object
130 131 132 |
# File 'lib/datadog/core/telemetry/metric.rb', line 130 def type TYPE end |