Class: Yabeda::Datadog::Adapter

Inherits:
BaseAdapter
  • Object
show all
Defined in:
lib/yabeda/datadog/adapter.rb

Overview

DataDog adapter.

Sends yabeda metrics as custom metrics to DataDog. docs.datadoghq.com/integrations/ruby/

Instance Method Summary collapse

Constructor Details

#initialize(worker:) ⇒ Adapter

Returns a new instance of Adapter.



17
18
19
# File 'lib/yabeda/datadog/adapter.rb', line 17

def initialize(worker:)
  @worker = worker
end

Instance Method Details

#perform_counter_increment!(counter, tags, increment) ⇒ Object



25
26
27
28
29
# File 'lib/yabeda/datadog/adapter.rb', line 25

def perform_counter_increment!(counter, tags, increment)
  metric = Metric.new(counter, "count")
  tags = Tags.build(tags)
  enqueue_send(metric, increment, tags)
end

#perform_gauge_set!(gauge, tags, value) ⇒ Object



35
36
37
38
39
# File 'lib/yabeda/datadog/adapter.rb', line 35

def perform_gauge_set!(gauge, tags, value)
  metric = Metric.new(gauge, "gauge")
  tags = Tags.build(tags)
  enqueue_send(metric, value, tags)
end

#perform_histogram_measure!(historam, tags, value) ⇒ Object



47
48
49
50
51
# File 'lib/yabeda/datadog/adapter.rb', line 47

def perform_histogram_measure!(historam, tags, value)
  metric = Metric.new(historam, "histogram")
  tags = Tags.build(tags)
  enqueue_send(metric, value, tags)
end

#register_counter!(counter) ⇒ Object



21
22
23
# File 'lib/yabeda/datadog/adapter.rb', line 21

def register_counter!(counter)
  enqueue_register(Metric.new(counter, "rate"))
end

#register_gauge!(gauge) ⇒ Object



31
32
33
# File 'lib/yabeda/datadog/adapter.rb', line 31

def register_gauge!(gauge)
  enqueue_register(Metric.new(gauge, "gauge"))
end

#register_histogram!(histogram) ⇒ Object



41
42
43
44
45
# File 'lib/yabeda/datadog/adapter.rb', line 41

def register_histogram!(histogram)
  Metric.histogram_metrics(histogram).map do |historgam_sub_metric|
    enqueue_register(historgam_sub_metric)
  end
end

#stopObject



53
54
55
# File 'lib/yabeda/datadog/adapter.rb', line 53

def stop
  worker.stop
end