Class: Meter::Backends::Udp
Direct Known Subclasses
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(host: '127.0.0.1', port: 8125) ⇒ Udp
constructor
A new instance of Udp.
- #output_data(data) ⇒ Object
- #socket ⇒ Object
Methods inherited from Base
#convert_to_backend_format, #emit_metric, #supported_metric?, supported_metrics
Constructor Details
#initialize(host: '127.0.0.1', port: 8125) ⇒ Udp
Returns a new instance of Udp.
10 11 12 |
# File 'lib/meter/backends/udp.rb', line 10 def initialize(host: '127.0.0.1', port: 8125) @host, @port = host, port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/meter/backends/udp.rb', line 8 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
8 9 10 |
# File 'lib/meter/backends/udp.rb', line 8 def port @port end |
Instance Method Details
#output_data(data) ⇒ Object
14 15 16 |
# File 'lib/meter/backends/udp.rb', line 14 def output_data(data) socket.send data, 0, self.host, self.port end |
#socket ⇒ Object
18 19 20 |
# File 'lib/meter/backends/udp.rb', line 18 def socket Thread.current["meter_socket_#{self.class.name}"] ||= UDPSocket.new end |