Module: DeliveryBoy::Datadog

Defined in:
lib/delivery_boy/datadog.rb

Overview

Reports operational metrics to a Datadog agent using the Statsd protocol.

require "delivery_boy/datadog"

# Default is "ruby_kafka" (kept for backward compatibility).
DeliveryBoy::Datadog.namespace = "custom-namespace"

# Default is "127.0.0.1".
DeliveryBoy::Datadog.host = "statsd.something.com"

# Default is 8125.
DeliveryBoy::Datadog.port = 1234

Defined Under Namespace

Classes: ProducerSubscriber, StatsdSubscriber

Constant Summary collapse

STATSD_NAMESPACE =
"ruby_kafka"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.hostObject

Returns the value of attribute host.



30
31
32
# File 'lib/delivery_boy/datadog.rb', line 30

def host
  @host
end

.portObject

Returns the value of attribute port.



30
31
32
# File 'lib/delivery_boy/datadog.rb', line 30

def port
  @port
end

.socket_pathObject

Returns the value of attribute socket_path.



30
31
32
# File 'lib/delivery_boy/datadog.rb', line 30

def socket_path
  @socket_path
end

Class Method Details

.closeObject



82
83
84
# File 'lib/delivery_boy/datadog.rb', line 82

def close
  @statsd&.close
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



32
33
34
# File 'lib/delivery_boy/datadog.rb', line 32

def configure
  yield self
end

.namespaceObject



64
65
66
# File 'lib/delivery_boy/datadog.rb', line 64

def namespace
  @namespace ||= STATSD_NAMESPACE
end

.namespace=(namespace) ⇒ Object



68
69
70
71
# File 'lib/delivery_boy/datadog.rb', line 68

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

.statsdObject



36
37
38
39
40
41
42
# File 'lib/delivery_boy/datadog.rb', line 36

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

.statsd=(statsd) ⇒ Object



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

def statsd=(statsd)
  clear
  @statsd = statsd
end

.tagsObject



73
74
75
# File 'lib/delivery_boy/datadog.rb', line 73

def tags
  @tags ||= []
end

.tags=(tags) ⇒ Object



77
78
79
80
# File 'lib/delivery_boy/datadog.rb', line 77

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