lib/logstash/outputs/graphite.rb in logstash-output-graphite-1.0.1 vs lib/logstash/outputs/graphite.rb in logstash-output-graphite-1.0.2

- old
+ new

@@ -102,13 +102,14 @@ sleep(@reconnect_interval) retry end end # def connect - def construct_metric_name(metric) + def construct_metric_name(event, metric) if @metrics_format - return @metrics_format.gsub(METRIC_PLACEHOLDER, metric) + sprinted = event.sprintf(@metrics_format) + return sprinted.gsub(METRIC_PLACEHOLDER, metric) end metric end @@ -173,18 +174,18 @@ end def metrics_lines_for_event(event, metric, value, timestamp) if event[metric].is_a?(Hash) dotify(event[metric], metric).map do |k,v| - metrics_line(k, v, timestamp) + metrics_line(event, k, v, timestamp) end else - metrics_line(event.sprintf(metric), event.sprintf(value).to_f, timestamp) + metrics_line(event, event.sprintf(metric), event.sprintf(value).to_f, timestamp) end end - def metrics_line(name, value, timestamp) - "#{construct_metric_name(name)} #{value} #{timestamp}" + def metrics_line(event, name, value, timestamp) + "#{construct_metric_name(event, name)} #{value} #{timestamp}" end # Take a nested ruby hash of the form {:a => {:b => 2}, c: => 3} and # turn it into a hash of the form # { "a.b" => 2, "c" => 3}