module Yabeda::Datadog

Namespace for DataDog adapter

Constants

COLLECT_INTERVAL
SECOND
VERSION

Public Class Methods

config() click to toggle source

Gem configuration object

# File lib/yabeda/datadog.rb, line 19
def config
  @config ||= Config.new
end
ensure_configured() click to toggle source

Check the gem configuration has valid state

# File lib/yabeda/datadog.rb, line 24
def ensure_configured
  raise ApiKeyError unless config.api_key
  raise AppKeyError unless config.app_key
end
start() click to toggle source

Prepare the adapter to work

# File lib/yabeda/datadog.rb, line 30
def start
  ensure_configured
  worker = Yabeda::Datadog::Worker.start(config)
  adapter = Yabeda::Datadog::Adapter.new(worker: worker)
  Yabeda.register_adapter(:datadog, adapter)
  adapter
rescue ConfigError => e
  Logging.instance.warn e.message
  nil
end
start_exporter(collect_interval: COLLECT_INTERVAL) click to toggle source

Start collection metrics from Yabeda collectors

# File lib/yabeda/datadog.rb, line 42
def start_exporter(collect_interval: COLLECT_INTERVAL)
  Thread.new do
    Logging.instance.debug("initilize collectors harvest")
    loop do
      Logging.instance.debug("start collectors harvest")
      Yabeda.collectors.each(&:call)
      Logging.instance.debug("end collectors harvest")
      sleep(collect_interval)
    end
  end
end