class Yabeda::Datadog::Metric

Internal adapter representation of metrics

Constants

DEFAULT_FLUSH_INTERVAL
SECOND

Attributes

metric[R]
overides[R]
type[R]

Public Class Methods

new(metric, type, overides = {}) click to toggle source
# File lib/yabeda/datadog/metric.rb, line 12
def initialize(metric, type, overides = {})
  @metric = metric
  @type = type
  @overides = overides
end

Private Class Methods

histogram_metrics(historgram) click to toggle source

Build Datadog histogram metrics from Yabeda histogram metric

# 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

Public Instance Methods

description() click to toggle source

Datadog API argument

# File lib/yabeda/datadog/metric.rb, line 38
def description
  overides.fetch(:description, metric.comment)
end
metadata() click to toggle source

Datadog API argument

# File lib/yabeda/datadog/metric.rb, line 21
def metadata
  {
    type: type,
    description: description,
    short_name: name,
    unit: unit,
    per_unit: per_unit,
    statsd_interval: statsd_interval,
  }
end
name() click to toggle source

Datadog API argument

# File lib/yabeda/datadog/metric.rb, line 33
def name
  [metric.group, metric.name.to_s, overides[:name_sufix]].compact.join(".")
end
per_unit() click to toggle source

Datadog API argument

# File lib/yabeda/datadog/metric.rb, line 48
def per_unit
  overides.fetch(:per_unit, Unit.find(metric.per))
end
statsd_interval() click to toggle source

Datadog API argument

# File lib/yabeda/datadog/metric.rb, line 53
def statsd_interval
  DEFAULT_FLUSH_INTERVAL if type == "rate"
end
unit() click to toggle source

Datadog API argument

# File lib/yabeda/datadog/metric.rb, line 43
def unit
  overides.fetch(:unit, Unit.find(metric.unit))
end
update(api) click to toggle source

Update metric metadata

# File lib/yabeda/datadog/metric.rb, line 58
def update(api)
  api.update_metadata(name, metadata)
end