Class: Yabeda::Datadog::Metric
- Inherits:
-
Object
- Object
- Yabeda::Datadog::Metric
- Defined in:
- lib/yabeda/datadog/metric.rb
Overview
Internal adapter representation of metrics
Constant Summary collapse
- SECOND =
1
- DEFAULT_FLUSH_INTERVAL =
SECOND * 10
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.histogram_metrics(historgram) ⇒ Object
Build Datadog histogram metrics from Yabeda histogram metric.
Instance Method Summary collapse
-
#description ⇒ Object
Datadog API argument.
-
#initialize(metric, type, overides = {}) ⇒ Metric
constructor
A new instance of Metric.
-
#metadata ⇒ Object
Datadog API argument.
-
#name ⇒ Object
Datadog API argument.
-
#per_unit ⇒ Object
Datadog API argument.
-
#statsd_interval ⇒ Object
Datadog API argument.
-
#unit ⇒ Object
Datadog API argument.
-
#update(api) ⇒ Object
Update metric metadata.
Constructor Details
#initialize(metric, type, overides = {}) ⇒ Metric
Returns a new instance of Metric.
12 13 14 15 16 |
# File 'lib/yabeda/datadog/metric.rb', line 12 def initialize(metric, type, overides = {}) @metric = metric @type = type @overides = overides end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
18 19 20 |
# File 'lib/yabeda/datadog/metric.rb', line 18 def type @type end |
Class Method Details
.histogram_metrics(historgram) ⇒ Object
Build Datadog histogram metrics from Yabeda histogram metric
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/yabeda/datadog/metric.rb', line 68 def histogram_metrics(historgram) [ new(historgram, "gauge", name_sufix: "avg"), new(historgram, "gauge", name_sufix: "max"), new(historgram, "gauge", name_sufix: "min"), new(historgram, "gauge", name_sufix: "median"), new(historgram, "gauge", name_sufix: "95percentile", unit: nil, per_unit: nil), new(historgram, "rate", name_sufix: "count", unit: nil, per_unit: nil), ] end |
Instance Method Details
#description ⇒ Object
Datadog API argument
38 39 40 |
# File 'lib/yabeda/datadog/metric.rb', line 38 def description overides.fetch(:description, metric.comment) end |
#metadata ⇒ Object
Datadog API argument
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/yabeda/datadog/metric.rb', line 21 def { type: type, description: description, short_name: name, unit: unit, per_unit: per_unit, statsd_interval: statsd_interval, } end |
#name ⇒ Object
Datadog API argument
33 34 35 |
# File 'lib/yabeda/datadog/metric.rb', line 33 def name [metric.group, metric.name.to_s, overides[:name_sufix]].compact.join(".") end |
#per_unit ⇒ Object
Datadog API argument
48 49 50 |
# File 'lib/yabeda/datadog/metric.rb', line 48 def per_unit overides.fetch(:per_unit, Unit.find(metric.per)) end |
#statsd_interval ⇒ Object
Datadog API argument
53 54 55 |
# File 'lib/yabeda/datadog/metric.rb', line 53 def statsd_interval DEFAULT_FLUSH_INTERVAL if type == "rate" end |
#unit ⇒ Object
Datadog API argument
43 44 45 |
# File 'lib/yabeda/datadog/metric.rb', line 43 def unit overides.fetch(:unit, Unit.find(metric.unit)) end |
#update(api) ⇒ Object
Update metric metadata
58 59 60 |
# File 'lib/yabeda/datadog/metric.rb', line 58 def update(api) api.(name, ) end |