working with sprintf and tag support

This commit is contained in:
John E. Vincent 2011-07-07 04:24:42 -04:00 committed by Pete Fritchman
parent c620a3b8c1
commit 252779a4ba

View file

@ -35,6 +35,10 @@ class LogStash::Outputs::Statsd < LogStash::Outputs::Base
# The sample rate for the metric
config :sample_rate, :validate => :number, :default => 1
# Only handle these tagged events
# Optional.
config :tags, :validate => :array, :default => []
# The final metric sent to statsd will look like the following (assuming defaults)
# logstash.sender.file_name
#
@ -49,8 +53,17 @@ class LogStash::Outputs::Statsd < LogStash::Outputs::Base
public
def receive(event)
if !@tags.empty?
if (event.tags - @tags).size == 0
return
end
end
@client.namespace = event.sprintf(@namespace)
logger.debug("Original sender: #{@sender}")
@sender = event.sprintf(@sender)
logger.debug("Munged sender: #{@sender}")
logger.debug("Event: #{event}")
@increment.each do |metric|
@client.increment(build_stat(event.sprintf(metric)), @sample_rate)
end