class StatsD::Instrument::DogStatsDDatagram

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

EVENT_PARSER

|k:my-key|p:low|s:source|t:success|

PARSER
SERVICE_CHECK_PARSER

Public Instance Methods

aggregation_key() click to toggle source
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 33
def aggregation_key
  parsed_datagram[:aggregation_key]
end
alert_type() click to toggle source
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 45
def alert_type
  parsed_datagram[:alert_type]
end
hostname() click to toggle source
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 25
def hostname
  parsed_datagram[:hostname]
end
message() click to toggle source
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 49
def message
  parsed_datagram[:message]
end
name() click to toggle source
Calls superclass method StatsD::Instrument::Datagram#name
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 10
def name
  @name ||= case type
  when :_e then parsed_datagram[:name].gsub('\n', "\n")
  else super
  end
end
priority() click to toggle source
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 41
def priority
  parsed_datagram[:priority]
end
source_type_name() click to toggle source
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 37
def source_type_name
  parsed_datagram[:source_type_name]
end
timestamp() click to toggle source
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 29
def timestamp
  Time.at(Integer(parsed_datagram[:timestamp])).utc
end
value() click to toggle source
Calls superclass method StatsD::Instrument::Datagram#value
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 17
def value
  @value ||= case type
  when :_sc then Integer(parsed_datagram[:value])
  when :_e then parsed_datagram[:value].gsub('\n', "\n")
  else super
  end
end

Protected Instance Methods

parsed_datagram() click to toggle source
# File lib/statsd/instrument/dogstatsd_datagram.rb, line 55
def parsed_datagram
  @parsed ||= if (match_info = PARSER.match(@source))
    match_info
  else
    raise ArgumentError, "Invalid DogStatsD datagram: #{@source}"
  end
end