Module: Kafka::Statsd

Defined in:
lib/kafka/statsd.rb

Overview

Reports operational metrics to a Statsd agent.

require "kafka/statsd"

# Default is "ruby_kafka".
Kafka::Statsd.namespace = "custom-namespace"

# Default is "127.0.0.1".
Kafka::Statsd.host = "statsd.something.com"

# Default is 8125.
Kafka::Statsd.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, FetcherSubscriber, ProducerSubscriber, StatsdSubscriber

Constant Summary collapse

DEFAULT_NAMESPACE =
"ruby_kafka"
DEFAULT_HOST =
'127.0.0.1'
DEFAULT_PORT =
8125

Class Method Summary collapse

Class Method Details

.host=(host) ⇒ Object



37
38
39
40
# File 'lib/kafka/statsd.rb', line 37

def self.host=(host)
  statsd.host = host
  statsd.connect if statsd.respond_to?(:connect)
end

.namespace=(namespace) ⇒ Object



47
48
49
# File 'lib/kafka/statsd.rb', line 47

def self.namespace=(namespace)
  statsd.namespace = namespace
end

.port=(port) ⇒ Object



42
43
44
45
# File 'lib/kafka/statsd.rb', line 42

def self.port=(port)
  statsd.port = port
  statsd.connect if statsd.respond_to?(:connect)
end

.statsdObject



33
34
35
# File 'lib/kafka/statsd.rb', line 33

def self.statsd
  @statsd ||= ::Statsd.new(DEFAULT_HOST, DEFAULT_PORT).tap { |sd| sd.namespace = DEFAULT_NAMESPACE }
end