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)


61
62
63
64
65
66
67
# File 'lib/datadog/core/telemetry/metric.rb', line 61

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.



55
56
57
# File 'lib/datadog/core/telemetry/metric.rb', line 55

def interval
  @interval
end

Instance Method Details

#to_hObject



69
70
71
72
73
# File 'lib/datadog/core/telemetry/metric.rb', line 69

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