Class: Datadog::Core::Telemetry::Metric::IntervalMetric

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

Overview

Base class for metrics that require aggregation interval

Direct Known Subclasses

Gauge, Rate

Instance Attribute Summary collapse

Attributes inherited from Base

#common, #name, #tags, #values

Instance Method Summary collapse

Methods inherited from Base

#id, #track, #type

Constructor Details

#initialize(name, interval:, tags: {}, common: true) ⇒ IntervalMetric

Returns a new instance of IntervalMetric.

Parameters:

  • name (String)

    metric name

  • tags (Array<String>|Hash{String=>String}) (defaults to: {})

    metric tags as hash of array of “tag:val” strings

  • common (Boolean) (defaults to: true)

    true if the metric is common for all languages, false for Ruby-specific metric

  • interval (Integer)

    metrics aggregation interval in seconds

Raises:

  • (ArgumentError)


73
74
75
76
77
78
79
# File 'lib/datadog/core/telemetry/metric.rb', line 73

def initialize(name, interval:, tags: {}, common: true)
  raise ArgumentError, 'interval must be a positive number' if interval.nil? || interval <= 0

  super(name, tags: tags, common: common)

  @interval = interval
end

Instance Attribute Details

#intervalObject (readonly)

Returns the value of attribute interval.



67
68
69
# File 'lib/datadog/core/telemetry/metric.rb', line 67

def interval
  @interval
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



87
88
89
# File 'lib/datadog/core/telemetry/metric.rb', line 87

def ==(other)
  super && interval == other.interval
end

#hashObject



93
94
95
# File 'lib/datadog/core/telemetry/metric.rb', line 93

def hash
  [super, interval].hash
end

#to_hObject



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

def to_h
  res = super
  res[:interval] = interval
  res
end