Class: Statue::UDPBackend
- Inherits:
-
Object
- Object
- Statue::UDPBackend
- Defined in:
- lib/statue/backends/udp.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
Instance Method Summary collapse
- #collect_metric(metric) ⇒ Object (also: #<<)
-
#initialize(host = nil, port = nil) ⇒ UDPBackend
constructor
A new instance of UDPBackend.
Constructor Details
#initialize(host = nil, port = nil) ⇒ UDPBackend
Returns a new instance of UDPBackend.
7 8 9 |
# File 'lib/statue/backends/udp.rb', line 7 def initialize(host = nil, port = nil) @address = Addrinfo.udp(host || "127.0.0.1", port || 8125) end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
5 6 7 |
# File 'lib/statue/backends/udp.rb', line 5 def address @address end |
Instance Method Details
#collect_metric(metric) ⇒ Object Also known as: <<
11 12 13 14 15 |
# File 'lib/statue/backends/udp.rb', line 11 def collect_metric(metric) if metric.sample_rate == 1 || rand < metric.sample_rate send_to_socket metric.to_s end end |