Merge "Remove empty fields from resource metadata"
This commit is contained in:
commit
0e558142e5
|
@ -68,11 +68,16 @@ function add_resource_to_payload(sample, payload)
|
||||||
local counter_name, _ = string.gsub(sample.counter_name, "%.", "\\")
|
local counter_name, _ = string.gsub(sample.counter_name, "%.", "\\")
|
||||||
|
|
||||||
local metadata = sample.resource_metadata
|
local metadata = sample.resource_metadata
|
||||||
|
local local_metadata = {}
|
||||||
|
|
||||||
if type(metadata) == 'table' then
|
if type(metadata) == 'table' then
|
||||||
for name, value in ipairs(metadata) do
|
for name, value in ipairs(metadata) do
|
||||||
local transform = transform_functions[name]
|
local transform = transform_functions[name]
|
||||||
if transform ~= nil then
|
if value ~= '' and value ~= nil then
|
||||||
metadata[name] = transform(value)
|
if transform ~= nil then
|
||||||
|
value = transform(value)
|
||||||
|
end
|
||||||
|
local_metadata[name] = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -81,7 +86,7 @@ function add_resource_to_payload(sample, payload)
|
||||||
timestamp = utils.format_datetime(sample.timestamp),
|
timestamp = utils.format_datetime(sample.timestamp),
|
||||||
resource_id = sample.resource_id,
|
resource_id = sample.resource_id,
|
||||||
source = sample.source or "",
|
source = sample.source or "",
|
||||||
metadata = sample.resource_metadata,
|
metadata = local_metadata,
|
||||||
user_id = sample.user_id,
|
user_id = sample.user_id,
|
||||||
project_id = sample.project_id,
|
project_id = sample.project_id,
|
||||||
meter = {
|
meter = {
|
||||||
|
|
Loading…
Reference in New Issue