Class: Statsby::UDPMetricsWriter
- Inherits:
-
Object
- Object
- Statsby::UDPMetricsWriter
- Defined in:
- lib/statsby/udp_metrics_writer.rb
Overview
Most StatsD endpoints will be UDP. This is a super simple wrapper around UPDSocket
Constant Summary collapse
- DEFAULT_HOST =
'localhost'.freeze
- DEFAULT_PORT =
8125
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
-
#initialize(host = DEFAULT_HOST, port = DEFAULT_PORT) ⇒ UDPMetricsWriter
constructor
A new instance of UDPMetricsWriter.
- #write(message) ⇒ Object
Constructor Details
#initialize(host = DEFAULT_HOST, port = DEFAULT_PORT) ⇒ UDPMetricsWriter
Returns a new instance of UDPMetricsWriter.
12 13 14 15 16 |
# File 'lib/statsby/udp_metrics_writer.rb', line 12 def initialize(host = DEFAULT_HOST, port = DEFAULT_PORT) self.socket = ::UDPSocket.new self.host = host self.port = port end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
10 11 12 |
# File 'lib/statsby/udp_metrics_writer.rb', line 10 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
10 11 12 |
# File 'lib/statsby/udp_metrics_writer.rb', line 10 def port @port end |
#socket ⇒ Object
Returns the value of attribute socket.
10 11 12 |
# File 'lib/statsby/udp_metrics_writer.rb', line 10 def socket @socket end |
Instance Method Details
#write(message) ⇒ Object
18 19 20 |
# File 'lib/statsby/udp_metrics_writer.rb', line 18 def write() socket.send(, 0, host, port) end |