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.
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 |
#type ⇒ Object
152 153 154 |
# File 'lib/datadog/core/telemetry/metric.rb', line 152 def type TYPE end |