class StatsD::Instrument::BatchedUDPSink

@note This class is part of the new Client implementation that is intended

to become the new default in the next major release of this library.

Constants

DEFAULT_FLUSH_INTERVAL
MAX_PACKET_SIZE

Attributes

host[R]
port[R]

Public Class Methods

finalize(dispatcher) click to toggle source
# File lib/statsd/instrument/batched_udp_sink.rb, line 19
def finalize(dispatcher)
  proc { dispatcher.shutdown }
end
for_addr(addr, flush_interval: DEFAULT_FLUSH_INTERVAL) click to toggle source
# File lib/statsd/instrument/batched_udp_sink.rb, line 11
def self.for_addr(addr, flush_interval: DEFAULT_FLUSH_INTERVAL)
  host, port_as_string = addr.split(":", 2)
  new(host, Integer(port_as_string), flush_interval: flush_interval)
end
new(host, port, flush_interval: DEFAULT_FLUSH_INTERVAL) click to toggle source
# File lib/statsd/instrument/batched_udp_sink.rb, line 24
def initialize(host, port, flush_interval: DEFAULT_FLUSH_INTERVAL)
  @host = host
  @port = port
  @dispatcher = Dispatcher.new(host, port, flush_interval)
  ObjectSpace.define_finalizer(self, self.class.finalize(@dispatcher))
end

Public Instance Methods

<<(datagram) click to toggle source
# File lib/statsd/instrument/batched_udp_sink.rb, line 35
def <<(datagram)
  @dispatcher << datagram
  self
end
sample?(sample_rate) click to toggle source
# File lib/statsd/instrument/batched_udp_sink.rb, line 31
def sample?(sample_rate)
  sample_rate == 1.0 || rand < sample_rate
end