Class: StatsD::Instrument::DogStatsDDatagram

Inherits:
Datagram
  • Object
show all
Defined in:
lib/statsd/instrument/dogstatsd_datagram.rb

Overview

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.

The Datagram class parses and inspects a StatsD datagrams

Instance Attribute Summary

Attributes inherited from Datagram

#source

Instance Method Summary collapse

Methods inherited from Datagram

#eql?, #hash, #initialize, #inspect, #sample_rate, #tags, #type

Constructor Details

This class inherits a constructor from StatsD::Instrument::Datagram

Instance Method Details

#aggregation_keyObject



33
34
35
# File 'lib/statsd/instrument/dogstatsd_datagram.rb', line 33

def aggregation_key
  parsed_datagram[:aggregation_key]
end

#alert_typeObject



45
46
47
# File 'lib/statsd/instrument/dogstatsd_datagram.rb', line 45

def alert_type
  parsed_datagram[:alert_type]
end

#hostnameObject



25
26
27
# File 'lib/statsd/instrument/dogstatsd_datagram.rb', line 25

def hostname
  parsed_datagram[:hostname]
end

#messageObject



49
50
51
# File 'lib/statsd/instrument/dogstatsd_datagram.rb', line 49

def message
  parsed_datagram[:message]
end

#nameObject



10
11
12
13
14
15
# 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

#priorityObject



41
42
43
# File 'lib/statsd/instrument/dogstatsd_datagram.rb', line 41

def priority
  parsed_datagram[:priority]
end

#source_type_nameObject



37
38
39
# File 'lib/statsd/instrument/dogstatsd_datagram.rb', line 37

def source_type_name
  parsed_datagram[:source_type_name]
end

#timestampObject



29
30
31
# File 'lib/statsd/instrument/dogstatsd_datagram.rb', line 29

def timestamp
  Time.at(Integer(parsed_datagram[:timestamp])).utc
end

#valueObject



17
18
19
20
21
22
23
# 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