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

#id, #initialize, #to_h

Constructor Details

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

Instance Method Details

#track(value) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/datadog/core/telemetry/metric.rb', line 85

def track(value)
  value = value.to_i

  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



81
82
83
# File 'lib/datadog/core/telemetry/metric.rb', line 81

def type
  TYPE
end