Remove empty fields from resource metadata

Change-Id: I6d8b1678e2e26e541d41d5894890cad57f4488a8
This commit is contained in:
Ildar Svetlov 2017-02-14 14:31:46 +04:00 committed by Ilya Tyaptin
parent 5494211a42
commit 0b9de5bc89
1 changed files with 8 additions and 3 deletions

View File

@ -68,11 +68,16 @@ function add_resource_to_payload(sample, payload)
local counter_name, _ = string.gsub(sample.counter_name, "%.", "\\")
local metadata = sample.resource_metadata
local local_metadata = {}
if type(metadata) == 'table' then
for name, value in ipairs(metadata) do
local transform = transform_functions[name]
if transform ~= nil then
metadata[name] = transform(value)
if value ~= '' and value ~= nil then
if transform ~= nil then
value = transform(value)
end
local_metadata[name] = value
end
end
end
@ -81,7 +86,7 @@ function add_resource_to_payload(sample, payload)
timestamp = utils.format_datetime(sample.timestamp),
resource_id = sample.resource_id,
source = sample.source or "",
metadata = sample.resource_metadata,
metadata = local_metadata,
user_id = sample.user_id,
project_id = sample.project_id,
meter = {