Module: Kafka::Datadog

Defined in:
lib/kafka/datadog.rb

Overview

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.

Defined Under Namespace

Classes: AsyncProducerSubscriber, ConnectionSubscriber, ConsumerSubscriber, ProducerSubscriber, StatsdSubscriber

Constant Summary collapse

STATSD_NAMESPACE =
"ruby_kafka"

Class Method Summary collapse

Class Method Details

.hostObject


35
36
37
# File 'lib/kafka/datadog.rb', line 35

def host
  @host ||= ::Datadog::Statsd::DEFAULT_HOST
end

.host=(host) ⇒ Object


39
40
41
42
# File 'lib/kafka/datadog.rb', line 39

def host=(host)
  @host = host
  clear
end

.namespaceObject


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

def namespace
  @namespace ||= STATSD_NAMESPACE
end

.namespace=(namespace) ⇒ Object


57
58
59
60
# File 'lib/kafka/datadog.rb', line 57

def namespace=(namespace)
  @namespace = namespace
  clear
end

.portObject


44
45
46
# File 'lib/kafka/datadog.rb', line 44

def port
  @port ||= ::Datadog::Statsd::DEFAULT_PORT
end

.port=(port) ⇒ Object


48
49
50
51
# File 'lib/kafka/datadog.rb', line 48

def port=(port)
  @port = port
  clear
end

.statsdObject


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

def statsd
  @statsd ||= ::Datadog::Statsd.new(host, port, namespace: namespace, tags: tags)
end

.tagsObject


62
63
64
# File 'lib/kafka/datadog.rb', line 62

def tags
  @tags ||= []
end

.tags=(tags) ⇒ Object


66
67
68
69
# File 'lib/kafka/datadog.rb', line 66

def tags=(tags)
  @tags = tags
  clear
end