Class: EventMachine::Statsd

Inherits:
Statsd
  • Object
show all
Defined in:
lib/em_statsd/statsd.rb

Instance Method Summary collapse

Instance Method Details

#connectObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/em_statsd/statsd.rb', line 4

def connect
  @s_mu.synchronize do
    begin
      @socket.close if @socket
    rescue
      self.class.logger.error { 'Statsd: can not close connection' } if self.class.logger
    end

    case @protocol
      when :tcp
        @socket = EMStatsd::TCPWrapper.new host, port
      else
        @socket = EMStatsd::UDPWrapper.new host, port
    end
  end
end

#send_to_socket(message) ⇒ Object



21
22
23
24
25
26
# File 'lib/em_statsd/statsd.rb', line 21

def send_to_socket(message)
  socket.write(message)
rescue => boom
  self.class.logger.error { "Statsd: #{boom.class} #{boom}" } if self.class.logger
  nil
end