Module: Fluent::StatsitePlugin::Parser

Included in:
StatsiteParser
Defined in:
lib/fluent/plugin/statsite/parser.rb

Instance Method Summary collapse

Instance Method Details

#build_record(k, v) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fluent/plugin/statsite/parser.rb', line 10

def build_record(k,v)
  type, key, statistic, range = k.split(".", 4)

  case type
  when 'timers' then 1
    if statistic == 'histogram'
      {type: type, key: key, value: v.to_i, statistic: statistic, range: range[4..-1]}
    elsif statistic == 'count'
      {type: type, key: key, value: v.to_i, statistic: statistic}
    else
      {type: type, key: key, value: v.to_f, statistic: statistic}
    end
  when 'kv', 'gauges', 'counts'
    {type: type, key: key, value: v.to_f}
  when 'sets'
    {type: type, key: key, value: v.to_i}
  end
end

#parse_line(line) ⇒ Object



4
5
6
7
8
# File 'lib/fluent/plugin/statsite/parser.rb', line 4

def parse_line(line)
  k,v,t = line.chomp.split('|')
  record = build_record(k,v)
  [t.to_i, record]
end