Class: Datadog::Core::Telemetry::Metric::Gauge

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

Overview

A gauge type takes the last value reported during the interval. This type would make sense for tracking RAM or CPU usage, where taking the last value provides a representative picture of the host’s behavior during the time interval.

Constant Summary collapse

TYPE =
'gauge'

Instance Attribute Summary

Attributes inherited from IntervalMetric

#interval

Attributes inherited from Base

#common, #name, #tags, #values

Instance Method Summary collapse

Methods inherited from IntervalMetric

#initialize, #to_h

Methods inherited from Base

#id, #initialize, #to_h

Constructor Details

This class inherits a constructor from Datadog::Core::Telemetry::Metric::IntervalMetric

Instance Method Details

#track(value) ⇒ Object



108
109
110
111
112
113
114
115
116
# File 'lib/datadog/core/telemetry/metric.rb', line 108

def track(value)
  if values.empty?
    values << [Time.now.to_i, value]
  else
    values[0][0] = Time.now.to_i
    values[0][1] = value
  end
  nil
end

#typeObject



104
105
106
# File 'lib/datadog/core/telemetry/metric.rb', line 104

def type
  TYPE
end