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.
22
23
24
|
# File 'lib/fluent/plugin/out_statsd.rb', line 22
def initialize
super
end
|
Instance Attribute Details
#statsd ⇒ Object
Returns the value of attribute statsd.
20
21
22
|
# File 'lib/fluent/plugin/out_statsd.rb', line 20
def statsd
@statsd
end
|
Instance Method Details
26
27
28
29
30
31
32
33
34
|
# File 'lib/fluent/plugin/out_statsd.rb', line 26
def configure(conf)
super
@statsd = Statsd.new(host, port)
@statsd.namespace = namespace if namespace
log.info(statsd)
@metrics = conf.elements.select {|elem| elem.name == 'metric' }
log.info(@metrics)
end
|
44
45
46
|
# File 'lib/fluent/plugin/out_statsd.rb', line 44
def format(tag, time, record)
[tag, record].to_msgpack
end
|
#shutdown ⇒ Object
40
41
42
|
# File 'lib/fluent/plugin/out_statsd.rb', line 40
def shutdown
super
end
|
#start ⇒ Object
36
37
38
|
# File 'lib/fluent/plugin/out_statsd.rb', line 36
def start
super
end
|
#write(chunk) ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/fluent/plugin/out_statsd.rb', line 48
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}
send_to_statsd(*metric.values_at(*arg_names).map {|str| parser.parse(str) })
end
end
end
|