module Kafka::Datadog
Reports operational metrics to a Datadog
agent using the modified Statsd
protocol.
require "kafka/datadog" # Default is "ruby_kafka". Kafka::Datadog.namespace = "custom-namespace" # Default is "127.0.0.1". Kafka::Datadog.host = "statsd.something.com" # Default is 8125. Kafka::Datadog.port = 1234
Once the file has been required, no further configuration is needed – all operational metrics are automatically emitted.
Constants
- STATSD_NAMESPACE
Public Class Methods
host()
click to toggle source
# File lib/kafka/datadog.rb, line 42 def host @host ||= default_host end
host=(host)
click to toggle source
# File lib/kafka/datadog.rb, line 46 def host=(host) @host = host clear end
namespace()
click to toggle source
# File lib/kafka/datadog.rb, line 60 def namespace @namespace ||= STATSD_NAMESPACE end
namespace=(namespace)
click to toggle source
# File lib/kafka/datadog.rb, line 64 def namespace=(namespace) @namespace = namespace clear end
port()
click to toggle source
# File lib/kafka/datadog.rb, line 51 def port @port ||= default_port end
port=(port)
click to toggle source
# File lib/kafka/datadog.rb, line 55 def port=(port) @port = port clear end
statsd()
click to toggle source
# File lib/kafka/datadog.rb, line 33 def statsd @statsd ||= ::Datadog::Statsd.new(host, port, namespace: namespace, tags: tags) end
statsd=(statsd)
click to toggle source
# File lib/kafka/datadog.rb, line 37 def statsd=(statsd) clear @statsd = statsd end
Private Class Methods
clear()
click to toggle source
# File lib/kafka/datadog.rb, line 88 def clear @statsd && @statsd.close @statsd = nil end
default_host()
click to toggle source
# File lib/kafka/datadog.rb, line 80 def default_host ::Datadog::Statsd.const_defined?(:Connection) ? ::Datadog::Statsd::Connection::DEFAULT_HOST : ::Datadog::Statsd::DEFAULT_HOST end
default_port()
click to toggle source
# File lib/kafka/datadog.rb, line 84 def default_port ::Datadog::Statsd.const_defined?(:Connection) ? ::Datadog::Statsd::Connection::DEFAULT_PORT : ::Datadog::Statsd::DEFAULT_PORT end