Class: Fluent::StatsdOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::StatsdOutput
show all
- Defined in:
- lib/fluent/plugin/out_statsd.rb
Defined Under Namespace
Classes: RubyStringParser
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of StatsdOutput.
25
26
27
|
# File 'lib/fluent/plugin/out_statsd.rb', line 25
def initialize
super
end
|
Instance Attribute Details
#statsd ⇒ Object
Returns the value of attribute statsd.
23
24
25
|
# File 'lib/fluent/plugin/out_statsd.rb', line 23
def statsd
@statsd
end
|
Instance Method Details
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/fluent/plugin/out_statsd.rb', line 29
def configure(conf)
super
@statsd = Statsd::Batch.new(Statsd.new(host, port))
@statsd.namespace = namespace if namespace
if batch_byte_size
@statsd.batch_size = nil
@statsd.batch_byte_size = batch_byte_size
end
log.info(statsd)
@metrics = conf.elements.select {|elem| elem.name == 'metric' }
log.info(@metrics)
end
|
53
54
55
|
# File 'lib/fluent/plugin/out_statsd.rb', line 53
def format(tag, time, record)
[tag, record].to_msgpack
end
|
#shutdown ⇒ Object
48
49
50
51
|
# File 'lib/fluent/plugin/out_statsd.rb', line 48
def shutdown
super
@statsd.flush
end
|
#start ⇒ Object
44
45
46
|
# File 'lib/fluent/plugin/out_statsd.rb', line 44
def start
super
end
|
#write(chunk) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/fluent/plugin/out_statsd.rb', line 57
def write(chunk)
chunk.msgpack_each do |tag, record|
parser = RubyStringParser.new(record: record, tag: tag)
@metrics.each do |metric|
arg_names = %w{statsd_type statsd_key statsd_val statsd_rate}
send_to_statsd(*metric.values_at(*arg_names).map {|str| parser.parse(str) })
end
end
@statsd.flush
end
|