Class: StatsD::Instrument::DogStatsDDatagramBuilder
- Inherits:
-
DatagramBuilder
- Object
- DatagramBuilder
- StatsD::Instrument::DogStatsDDatagramBuilder
- Defined in:
- lib/statsd/instrument/dogstatsd_datagram_builder.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.
Instance Method Summary collapse
-
#_e(title, text, timestamp: nil, hostname: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil, tags: nil) ⇒ String
Constricts an event datagram.
-
#_sc(name, status, timestamp: nil, hostname: nil, tags: nil, message: nil) ⇒ String
Constricts a service check datagram.
- #latency_metric_type ⇒ Object
Methods inherited from DatagramBuilder
#c, #d, #datagram_class, #g, #h, #initialize, #kv, #ms, #s, unsupported_datagram_types
Constructor Details
This class inherits a constructor from StatsD::Instrument::DatagramBuilder
Instance Method Details
#_e(title, text, timestamp: nil, hostname: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil, tags: nil) ⇒ String
Constricts an event datagram.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/statsd/instrument/dogstatsd_datagram_builder.rb', line 27 def _e(title, text, timestamp: nil, hostname: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil, tags: nil) escaped_title = "#{@prefix}#{title}".gsub("\n", '\n') escaped_text = text.gsub("\n", '\n') = () + datagram = +"_e{#{escaped_title.length},#{escaped_text.length}}:#{escaped_title}|#{escaped_text}" datagram << "|h:#{hostname}" if hostname datagram << "|d:#{.to_i}" if datagram << "|k:#{aggregation_key}" if aggregation_key datagram << "|p:#{priority}" if priority datagram << "|s:#{source_type_name}" if source_type_name datagram << "|t:#{alert_type}" if alert_type datagram << "|##{.join(',')}" unless .empty? datagram end |
#_sc(name, status, timestamp: nil, hostname: nil, tags: nil, message: nil) ⇒ String
Constricts a service check datagram.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/statsd/instrument/dogstatsd_datagram_builder.rb', line 57 def _sc(name, status, timestamp: nil, hostname: nil, tags: nil, message: nil) status_number = status.is_a?(Integer) ? status : SERVICE_CHECK_STATUS_VALUES.fetch(status.to_sym) = () + datagram = +"_sc|#{@prefix}#{normalize_name(name)}|#{status_number}" datagram << "|h:#{hostname}" if hostname datagram << "|d:#{.to_i}" if datagram << "|##{.join(',')}" unless .empty? datagram << "|m:#{normalize_name()}" if datagram end |
#latency_metric_type ⇒ Object
8 9 10 |
# File 'lib/statsd/instrument/dogstatsd_datagram_builder.rb', line 8 def latency_metric_type :d end |