Class: Datadog::Statsd::Connection
- Inherits:
-
Object
- Object
- Datadog::Statsd::Connection
- Defined in:
- lib/datadog/statsd.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_HOST =
'127.0.0.1'- DEFAULT_PORT =
8125
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
StatsD host.
-
#port ⇒ Object
readonly
StatsD port.
-
#socket_path ⇒ Object
readonly
DogStatsd unix socket path.
Instance Method Summary collapse
-
#close ⇒ Object
Close the underlying socket.
- #write(message) ⇒ Object
Instance Attribute Details
#host ⇒ Object (readonly)
StatsD host. Defaults to 127.0.0.1.
28 29 30 |
# File 'lib/datadog/statsd.rb', line 28 def host @host end |
#port ⇒ Object (readonly)
StatsD port. Defaults to 8125.
31 32 33 |
# File 'lib/datadog/statsd.rb', line 31 def port @port end |
#socket_path ⇒ Object (readonly)
DogStatsd unix socket path. Not used by default.
34 35 36 |
# File 'lib/datadog/statsd.rb', line 34 def socket_path @socket_path end |
Instance Method Details
#close ⇒ Object
Close the underlying socket
37 38 39 |
# File 'lib/datadog/statsd.rb', line 37 def close @socket && @socket.close end |
#write(message) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/datadog/statsd.rb', line 41 def write() @logger.debug { "Statsd: #{message}" } if @logger () rescue StandardError => boom # Try once to reconnect if the socket has been closed retries ||= 1 if retries <= 1 && boom.is_a?(Errno::ENOTCONN) or retries <= 1 && boom.is_a?(IOError) && boom. =~ /closed stream/i retries += 1 begin @socket = connect retry rescue StandardError => e boom = e end end @logger.error { "Statsd: #{boom.class} #{boom}" } if @logger nil end |