Class: StatsD::Instrument::Backends::UDPBackend::DogStatsDProtocol
- Inherits:
-
Object
- Object
- StatsD::Instrument::Backends::UDPBackend::DogStatsDProtocol
- Defined in:
- lib/statsd/instrument/backends/udp_backend.rb
Constant Summary collapse
- EVENT_OPTIONS =
{ date_happened: 'd', hostname: 'h', aggregation_key: 'k', priority: 'p', source_type_name: 's', alert_type: 't', }
- SERVICE_CHECK_OPTIONS =
{ timestamp: 'd', hostname: 'h', message: 'm', }
Instance Method Summary collapse
Instance Method Details
#generate_packet(metric) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/statsd/instrument/backends/udp_backend.rb', line 26 def generate_packet(metric) packet = "" if metric.type == :_e escaped_title = metric.name.tr('\n', '\\n') escaped_text = metric.value.tr('\n', '\\n') packet << "_e{#{escaped_title.size},#{escaped_text.size}}:#{escaped_title}|#{escaped_text}" packet << (metric, EVENT_OPTIONS) elsif metric.type == :_sc packet << "_sc|#{metric.name}|#{metric.value}" packet << (metric, SERVICE_CHECK_OPTIONS) else packet << "#{metric.name}:#{metric.value}|#{metric.type}" end packet << "|@#{metric.sample_rate}" if metric.sample_rate < 1 packet << "|##{metric..join(',')}" if metric. packet end |
#supported?(metric) ⇒ Boolean
22 23 24 |
# File 'lib/statsd/instrument/backends/udp_backend.rb', line 22 def supported?(metric) [:c, :ms, :g, :h, :s, :_e, :_sc].include?(metric.type) end |