class StatsD::Instrument::Datagram

to become the new default in the next major release of this library.
@note This class is part of the new Client implementation that is intended
The Datagram class parses and inspects a StatsD datagrams

def eql?(other)

def eql?(other)
  case other
  when StatsD::Instrument::Datagram
    source == other.source
  when String
    source == other
  else
    false
  end
end

def hash

def hash
  source.hash
end

def initialize(source)

def initialize(source)
  @source = source
end

def inspect

def inspect
  "#<#{self.class.name}:\"#{@source}\">"
end

def name

def name
  parsed_datagram[:name]
end

def parsed_datagram

def parsed_datagram
  @parsed ||= if (match_info = PARSER.match(@source))
    match_info
  else
    raise ArgumentError, "Invalid StatsD datagram: #{@source}"
  end
end

def sample_rate

Returns:
  • (Float) - The sample rate at which this datagram was emitted, between 0 and 1.
def sample_rate
  parsed_datagram[:sample_rate] ? Float(parsed_datagram[:sample_rate]) : 1.0
end

def tags

def tags
  @tags ||= parsed_datagram[:tags] ? parsed_datagram[:tags].split(",") : nil
end

def type

def type
  @type ||= parsed_datagram[:type].to_sym
end

def value

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