Class: Deimos::Metrics::Datadog

Inherits:
Provider
  • Object
show all
Defined in:
lib/deimos/metrics/datadog.rb

Overview

A Metrics wrapper class for Datadog.

Instance Method Summary collapse

Constructor Details

#initialize(config, logger) ⇒ Datadog

Returns a new instance of Datadog.

Parameters:

  • config (Hash)
  • logger (Logger)


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/deimos/metrics/datadog.rb', line 11

def initialize(config, logger)
  raise 'Metrics config must specify host_ip' if config[:host_ip].nil?
  raise 'Metrics config must specify host_port' if config[:host_port].nil?
  raise 'Metrics config must specify namespace' if config[:namespace].nil?

  logger.info("DatadogMetricsProvider configured with: #{config}")
  @client = ::Datadog::Statsd.new(
    config[:host_ip],
    config[:host_port],
    tags: config[:tags],
    namespace: config[:namespace]
  )
end

Instance Method Details

#gauge(metric_name, count, options = {}) ⇒ Object

:nodoc:



31
32
33
# File 'lib/deimos/metrics/datadog.rb', line 31

def gauge(metric_name, count, options={})
  @client.gauge(metric_name, count, options)
end

#histogram(metric_name, count, options = {}) ⇒ Object

:nodoc:



36
37
38
# File 'lib/deimos/metrics/datadog.rb', line 36

def histogram(metric_name, count, options={})
  @client.histogram(metric_name, count, options)
end

#increment(metric_name, options = {}) ⇒ Object

:nodoc:



26
27
28
# File 'lib/deimos/metrics/datadog.rb', line 26

def increment(metric_name, options={})
  @client.increment(metric_name, options)
end

#time(metric_name, options = {}) ⇒ Object

:nodoc:



41
42
43
44
45
# File 'lib/deimos/metrics/datadog.rb', line 41

def time(metric_name, options={})
  @client.time(metric_name, options) do
    yield
  end
end