class StatsD::Instrument::Datagram
The Datagram
class parses and inspects a StatsD
datagrams
@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
- PARSER
Attributes
source[R]
Public Class Methods
new(source)
click to toggle source
# File lib/statsd/instrument/datagram.rb, line 10 def initialize(source) @source = source end
Public Instance Methods
eql?(other)
click to toggle source
# File lib/statsd/instrument/datagram.rb, line 52 def eql?(other) case other when StatsD::Instrument::Datagram source == other.source when String source == other else false end end
Also aliased as: ==
hash()
click to toggle source
# File lib/statsd/instrument/datagram.rb, line 48 def hash source.hash end
inspect()
click to toggle source
# File lib/statsd/instrument/datagram.rb, line 44 def inspect "#<#{self.class.name}:\"#{@source}\">" end
name()
click to toggle source
# File lib/statsd/instrument/datagram.rb, line 23 def name parsed_datagram[:name] end
sample_rate()
click to toggle source
@return [Float] The sample rate at which this datagram was emitted, between 0 and 1.
# File lib/statsd/instrument/datagram.rb, line 15 def sample_rate parsed_datagram[:sample_rate] ? Float(parsed_datagram[:sample_rate]) : 1.0 end
type()
click to toggle source
# File lib/statsd/instrument/datagram.rb, line 19 def type @type ||= parsed_datagram[:type].to_sym end
value()
click to toggle source
# File lib/statsd/instrument/datagram.rb, line 27 def value @value ||= case type when :c Integer(parsed_datagram[:value]) when :g, :h, :d, :kv, :ms Float(parsed_datagram[:value]) when :s String(parsed_datagram[:value]) else parsed_datagram[:value] end end
Private Instance Methods
parsed_datagram()
click to toggle source
# File lib/statsd/instrument/datagram.rb, line 76 def parsed_datagram @parsed ||= if (match_info = PARSER.match(@source)) match_info else raise ArgumentError, "Invalid StatsD datagram: #{@source}" end end