lib/fluent/plugin/datadog_metrics_sender.rb in fluent-plugin-jfrog-send-metrics-0.1.3 vs lib/fluent/plugin/datadog_metrics_sender.rb in fluent-plugin-jfrog-send-metrics-0.1.4
- old
+ new
@@ -6,10 +6,27 @@
def initialize(apikey, url)
@apikey = apikey
@url = url
end
- def send_metrics(metrics_data)
+ def add_custom_data(ddtags, record)
+ if ddtags.length() > 0
+ record_series = record['series']
+ data_array = []
+ record_series.each do |interim_data|
+ interim_data['tags'] ||= []
+ interim_data['tags'].push(*ddtags)
+ data_array << interim_data
+ end
+ record['series'] = data_array
+ return record
+ end
+ return record
+ end
+
+ def send_metrics(ddtags, record)
+ puts "Additional tags to be added to metrics are", ddtags
+ metrics_data = add_custom_data(ddtags, record)
puts "Sending received metrics data"
response = RestClient::Request.new(
method: :post,
url: @url,
payload: metrics_data.to_json,