Skip to content

Commit 324ec1d

Browse files
Jonathan Erbdavid-marchand
Jonathan Erb
authored andcommitted
telemetry: fix empty JSON dictionaries
Fix to allow telemetry to handle empty dictionaries correctly. This patch resolves an issue where empty dictionaries are reported by telemetry as '[]' rather than '{}'. Initializing the output buffer based on the container type resolves the issue. Fixes: c933bb5 ("telemetry: support array values in data object") Cc: [email protected] Signed-off-by: Jonathan Erb <[email protected]> Acked-by: Ciara Power <[email protected]>
1 parent ec932cb commit 324ec1d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ John Ousterhout <[email protected]>
676676
John Romein <[email protected]>
677677
John W. Linville <[email protected]>
678678
679-
679+
Jonathan Erb <jonathan.erb@threater.com> <jonathan.erb@threatblockr.com> <[email protected]>
680680
Jonathan Tsai <[email protected]>
681681
Jon DeVree <[email protected]>
682682
Jon Loeliger <[email protected]>

lib/telemetry/telemetry.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
170170
d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)
171171
return snprintf(out_buf, buf_len, "null");
172172

173-
used = rte_tel_json_empty_array(out_buf, buf_len, 0);
173+
if (d->type == TEL_DICT)
174+
used = rte_tel_json_empty_obj(out_buf, buf_len, 0);
175+
else
176+
used = rte_tel_json_empty_array(out_buf, buf_len, 0);
177+
174178
if (d->type == TEL_ARRAY_UINT)
175179
for (i = 0; i < d->data_len; i++)
176180
used = rte_tel_json_add_array_uint(out_buf,

0 commit comments

Comments
 (0)