Class: Fluent::StatsdOutput

Inherits:
BufferedOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_statsd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatsdOutput

Returns a new instance of StatsdOutput.



13
14
15
# File 'lib/fluent/plugin/out_statsd.rb', line 13

def initialize
  super
end

Instance Attribute Details

#statsdObject (readonly)

Returns the value of attribute statsd.



11
12
13
# File 'lib/fluent/plugin/out_statsd.rb', line 11

def statsd
  @statsd
end

Instance Method Details

#configure(conf) ⇒ Object



17
18
19
20
# File 'lib/fluent/plugin/out_statsd.rb', line 17

def configure(conf)
  super
  @statsd = Statsd.new(host, port)
end

#format(tag, time, record) ⇒ Object



30
31
32
# File 'lib/fluent/plugin/out_statsd.rb', line 30

def format(tag, time, record)
  record.to_msgpack
end

#shutdownObject



26
27
28
# File 'lib/fluent/plugin/out_statsd.rb', line 26

def shutdown
  super
end

#startObject



22
23
24
# File 'lib/fluent/plugin/out_statsd.rb', line 22

def start
  super
end

#write(chunk) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fluent/plugin/out_statsd.rb', line 34

def write(chunk)
  chunk.msgpack_each {|record|
    if statsd_type = record['statsd_type']
      case statsd_type
      when 'timing'
        @statsd.timing record['statsd_key'], record['statsd_timing'].to_f
      when 'gauge'
        @statsd.gauge record['statsd_key'], record['statsd_gauge'].to_f
      when 'count'
        @statsd.count record['statsd_key'], record['statsd_count'].to_f
      when 'set'
        @statsd.set record['statsd_key'], record['statsd_set']
      when 'increment'
        @statsd.increment record['statsd_key']
      when 'decrement'
        @statsd.decrement record['statsd_key']
      end
    end
  }
end