Browse Source

Merge "Remove empty fields from resource metadata"

Jenkins 2 years ago
parent
commit
0e558142e5

+ 8
- 3
deployment_scripts/puppet/modules/telemetry/files/common/resources.lua View File

@@ -68,11 +68,16 @@ function add_resource_to_payload(sample, payload)
68 68
     local counter_name, _ = string.gsub(sample.counter_name, "%.", "\\")
69 69
 
70 70
     local metadata = sample.resource_metadata
71
+    local local_metadata = {}
72
+
71 73
     if type(metadata) == 'table' then
72 74
         for name, value in ipairs(metadata) do
73 75
             local transform = transform_functions[name]
74
-            if transform ~= nil then
75
-                metadata[name] = transform(value)
76
+            if value ~= '' and value ~= nil then
77
+                if transform ~= nil then
78
+                    value = transform(value)
79
+                end
80
+                local_metadata[name] = value
76 81
             end
77 82
         end
78 83
     end
@@ -81,7 +86,7 @@ function add_resource_to_payload(sample, payload)
81 86
         timestamp = utils.format_datetime(sample.timestamp),
82 87
         resource_id = sample.resource_id,
83 88
         source = sample.source or "",
84
-        metadata = sample.resource_metadata,
89
+        metadata = local_metadata,
85 90
         user_id = sample.user_id,
86 91
         project_id = sample.project_id,
87 92
         meter = {

Loading…
Cancel
Save