Class: Datadog::Core::Telemetry::Metric::Base
- Inherits:
-
Object
- Object
- Datadog::Core::Telemetry::Metric::Base
- Defined in:
- lib/datadog/core/telemetry/metric.rb
Overview
Base class for all metric types
Direct Known Subclasses
Instance Attribute Summary collapse
-
#common ⇒ Object
readonly
Returns the value of attribute common.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(name, tags: {}, common: true) ⇒ Base
constructor
A new instance of Base.
- #to_h ⇒ Object
- #track(value) ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(name, tags: {}, common: true) ⇒ Base
Returns a new instance of 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 = () @common = common end |
Instance Attribute Details
#common ⇒ Object (readonly)
Returns the value of attribute common.
10 11 12 |
# File 'lib/datadog/core/telemetry/metric.rb', line 10 def common @common end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/datadog/core/telemetry/metric.rb', line 10 def name @name end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
10 11 12 |
# File 'lib/datadog/core/telemetry/metric.rb', line 10 def @tags end |
#values ⇒ Object (readonly)
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
#id ⇒ Object
22 23 24 |
# File 'lib/datadog/core/telemetry/metric.rb', line 22 def id @id ||= "#{type}::#{name}::#{.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: , 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 |