Class: Datadog::Core::Telemetry::Metric::Count

Inherits:
Base
  • Object
show all
Defined in:
lib/datadog/core/telemetry/metric.rb

Overview

Count metric adds up all the submitted values in a time interval. This would be suitable for a metric tracking the number of website hits, for instance.

Constant Summary collapse

TYPE =
'count'

Instance Attribute Summary

Attributes inherited from Base

#common, #name, #tags, #values

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Method Details

#track(value) ⇒ Object



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

def track(value)
  value = value.to_i

  if values.empty?
    values << [Core::Utils::Time.now.to_i, value]
  else
    values[0][0] = Core::Utils::Time.now.to_i
    values[0][1] += value
  end
  nil
end

#typeObject



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

def type
  TYPE
end