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.
This commit is contained in:
parent
5142c61707
commit
d67e2045a0
|
@ -16,7 +16,11 @@ class MetricsWorker
|
||||||
new_hash = hash.symbolize_keys
|
new_hash = hash.symbolize_keys
|
||||||
|
|
||||||
new_hash[:tags].each do |key, value|
|
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
|
end
|
||||||
|
|
||||||
new_hash
|
new_hash
|
||||||
|
|
|
@ -30,6 +30,14 @@ describe MetricsWorker do
|
||||||
|
|
||||||
expect(metrics).to eq([{ values: {}, tags: { 'foo' => 'bar\\=' } }])
|
expect(metrics).to eq([{ values: {}, tags: { 'foo' => 'bar\\=' } }])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'drops empty tags' do
|
||||||
|
metrics = worker.prepare_metrics([
|
||||||
|
{ 'values' => {}, 'tags' => { 'cats' => '', 'dogs' => nil }}
|
||||||
|
])
|
||||||
|
|
||||||
|
expect(metrics).to eq([{ values: {}, tags: {} }])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#escape_value' do
|
describe '#escape_value' do
|
||||||
|
|
Loading…
Reference in New Issue