Commit d67e2045 authored by Yorick Peterse's avatar Yorick Peterse

Drop empty tag values from metrics

InfluxDB throws an error when trying to store a list of tags where one
or more have an empty value.
parent 5142c617
......@@ -16,7 +16,11 @@ class MetricsWorker
new_hash = hash.symbolize_keys
new_hash[:tags].each do |key, value|
new_hash[:tags][key] = escape_value(value)
if value.blank?
new_hash[:tags].delete(key)
else
new_hash[:tags][key] = escape_value(value)
end
end
new_hash
......
......@@ -30,6 +30,14 @@ describe MetricsWorker do
expect(metrics).to eq([{ values: {}, tags: { 'foo' => 'bar\\=' } }])
end
it 'drops empty tags' do
metrics = worker.prepare_metrics([
{ 'values' => {}, 'tags' => { 'cats' => '', 'dogs' => nil }}
])
expect(metrics).to eq([{ values: {}, tags: {} }])
end
end
describe '#escape_value' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment