Module: Kafka::Statsd

Defined in:
lib/kafka/statsd.rb

Overview

Reports operational metrics to a Statsd agent.

require "kafka/statds"

# 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, 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


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

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

.namespace=(namespace) ⇒ Object


45
46
47
# File 'lib/kafka/statsd.rb', line 45

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

.port=(port) ⇒ Object


40
41
42
43
# File 'lib/kafka/statsd.rb', line 40

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

.statsdObject


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

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