Class: Datadog::Core::Telemetry::Metric::Base
- Inherits:
-
Object
- Object
- Datadog::Core::Telemetry::Metric::Base
show all
- Defined in:
- lib/datadog/core/telemetry/metric.rb
Overview
Base class for all metric types
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, tags: {}, common: true) ⇒ Base
15
16
17
18
19
20
|
# File 'lib/datadog/core/telemetry/metric.rb', line 15
def initialize(name, tags: {}, common: true)
@name = name
@values = []
@tags = tags_to_array(tags)
@common = common
end
|
Instance Attribute Details
#common ⇒ Object
Returns the value of attribute common.
10
11
12
|
# File 'lib/datadog/core/telemetry/metric.rb', line 10
def common
@common
end
|
#name ⇒ Object
Returns the value of attribute name.
10
11
12
|
# File 'lib/datadog/core/telemetry/metric.rb', line 10
def name
@name
end
|
Returns the value of attribute tags.
10
11
12
|
# File 'lib/datadog/core/telemetry/metric.rb', line 10
def tags
@tags
end
|
#values ⇒ Object
Returns the value of attribute values.
10
11
12
|
# File 'lib/datadog/core/telemetry/metric.rb', line 10
def values
@values
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
44
45
46
47
48
|
# File 'lib/datadog/core/telemetry/metric.rb', line 44
def ==(other)
other.is_a?(self.class) &&
name == other.name &&
values == other.values && tags == other.tags && common == other.common && type == other.type
end
|
#hash ⇒ Object
52
53
54
|
# File 'lib/datadog/core/telemetry/metric.rb', line 52
def hash
[self.class, name, values, tags, common, type].hash
end
|
#id ⇒ Object
22
23
24
|
# File 'lib/datadog/core/telemetry/metric.rb', line 22
def id
@id ||= "#{type}::#{name}::#{tags.join(",")}"
end
|
#to_h ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/datadog/core/telemetry/metric.rb', line 34
def to_h
{
metric: name,
points: values,
type: type,
tags: tags,
common: common
}
end
|
#track(value) ⇒ Object
26
27
28
|
# File 'lib/datadog/core/telemetry/metric.rb', line 26
def track(value)
raise NotImplementedError, 'method must be implemented in subclasses'
end
|
#type ⇒ Object
30
31
32
|
# File 'lib/datadog/core/telemetry/metric.rb', line 30
def type
raise NotImplementedError, 'method must be implemented in subclasses'
end
|