telemetry: correct json empty dictionaries
PATCH v2 1/2 telemetry: correct json empty 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.
--- .mailmap | 2 +- lib/telemetry/telemetry.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
.mailmap +1 -1
@@ -675,7 +675,7 @@ John Ousterhout <[email protected]> John Romein <[email protected]> John W. Linville <[email protected]> Jonas Pfefferle <[email protected]> <[email protected]> -Jonathan Erb <[email protected]> <[email protected]> +Jonathan Erb <[email protected]> Jonathan Tsai <[email protected]> Jon DeVree <[email protected]> Jon Loeliger <[email protected]>
lib/telemetry/telemetry.c +5 -1
@@ -169,7 +169,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)return snprintf (out_buf, buf_len,"null" ); - used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==RTE_TEL_DICT ) + used =rte_tel_json_empty_obj (out_buf, buf_len,0 ); +else + used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==TEL_ARRAY_UINT )for (i =0 ; i < d->data_len; i++) used = rte_tel_json_add_array_uint(out_buf,
Signature · 1 line
2.34.1
PATCH v2 2/2 telemetry: correct json empty dictionaries
Fix use of incorrect enum name.
--- lib/telemetry/telemetry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/telemetry/telemetry.c +1 -1
@@ -169,7 +169,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)return snprintf (out_buf, buf_len,"null" ); -if (d->type ==RTE_TEL_DICT ) +if (d->type ==TEL_DICT ) used =rte_tel_json_empty_obj (out_buf, buf_len,0 );else used =rte_tel_json_empty_array (out_buf, buf_len,0 );
Signature · 1 line
2.34.1
Quoted 3 lines · Jonathan Erb
Fix use of incorrect enum name.
Signed-off-by Jonathan Erb <[email protected]>
Please merge this fix into patch 1, so we only have a single commit to the repo.
Thanks,
/Bruce
Quoted 20 lines
--- lib/telemetry/telemetry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/telemetry/telemetry.c +1
-1@@ -169,7 +169,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)return snprintf (out_buf, buf_len,"null" ); -if (d->type ==RTE_TEL_DICT ) +if (d->type ==TEL_DICT ) used =rte_tel_json_empty_obj (out_buf, buf_len,0 );else used =rte_tel_json_empty_array (out_buf, buf_len,0 );Signature · 1 line
2.34.1
Quoted 7 lines · Jonathan Erb
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.
Signed-off-by Jonathan Erb <[email protected]>
One minor comment below.
Quoted 10 lines
--- .mailmap | 2 +- lib/telemetry/telemetry.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-).mailmap +0
-0
.mailmap John Ousterhout <[email protected]> · line 678
Quoted 5 lines
.mailmap +1
-1@@ -675,7 +675,7 @@ John Ousterhout <[email protected]> John Romein <[email protected]> John W. Linville <[email protected]> Jonas Pfefferle <[email protected]> <[email protected]> -Jonathan Erb <[email protected]> <[email protected]> +Jonathan Erb <[email protected]>
FYI, it's advisable to keep old email addresses in this file, since it is then used to map the older email addresses to the new one. Just add your new correct email address as the first one on the line.
Quoted 23 lines
.mailmap +0
-0Jonathan Tsai <[email protected]> Jon DeVree <[email protected]> Jon Loeliger <[email protected]>lib/telemetry/telemetry.c +5
-1@@ -169,7 +169,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)return snprintf (out_buf, buf_len,"null" ); - used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==RTE_TEL_DICT ) + used =rte_tel_json_empty_obj (out_buf, buf_len,0 ); +else + used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==TEL_ARRAY_UINT )for (i =0 ; i < d->data_len; i++) used = rte_tel_json_add_array_uint(out_buf,Signature · 1 line
2.34.1
Hi Jonathan,
Quoted 49 lines
-----Original Message-----
From: Jonathan Erb <[email protected]>
Sent: Sunday, December 24, 2023 10:02 PM
To: Power, Ciara <[email protected]>
Cc: [email protected]; Jonathan Erb <[email protected]>
Subject: [PATCH v2 1/2] telemetry: correct json empty dictionariesFix 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.
Signed-off-by Jonathan Erb <[email protected]>--- .mailmap | 2 +- lib/telemetry/telemetry.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-).mailmap +0
-0@@ -675,7 +675,7 @@ John Ousterhout <[email protected]> JohnRomein <[email protected]> John W. Linville <[email protected]> Jonas Pfefferle <[email protected]> <[email protected]> -Jonathan Erb <[email protected]> <[email protected]> +Jonathan Erb <[email protected]>
Jonathan Tsai <[email protected]> Jon DeVree <[email protected]>
Jon Loeliger <[email protected]> diff --gita/lib/telemetry/telemetry.cb/lib/telemetry/telemetry.cindex92982842a8..0788a32210100644lib/telemetry/telemetry.c +5
-1@@ -169,7 +169,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)return snprintf (out_buf, buf_len,"null" ); - used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==RTE_TEL_DICT ) + used =rte_tel_json_empty_obj (out_buf, buf_len,0 ); +else + used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==TEL_ARRAY_UINT )lib/telemetry/telemetry.c +0
-1for (i =0 ; i < d->data_len; i++) used = rte_tel_json_add_array_uint(out_buf, --
Quoted 1 line
2.34.1
+1 for Bruce's suggestion to squash patch #2 into this one.
Thanks,
PATCH 1/1 telemetry: correct json empty dictionaries
In reply to Jonathan ErbFix 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.
--- .mailmap | 2 +- lib/telemetry/telemetry.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
.mailmap +1 -1
@@ -675,7 +675,7 @@ John Ousterhout <[email protected]> John Romein <[email protected]> John W. Linville <[email protected]> Jonas Pfefferle <[email protected]> <[email protected]> -Jonathan Erb <[email protected]> <[email protected]> +Jonathan Erb <[email protected]> <[email protected]> <[email protected]> Jonathan Tsai <[email protected]> Jon DeVree <[email protected]> Jon Loeliger <[email protected]>
lib/telemetry/telemetry.c +5 -1
@@ -169,7 +169,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)return snprintf (out_buf, buf_len,"null" ); - used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==TEL_DICT ) + used =rte_tel_json_empty_obj (out_buf, buf_len,0 ); +else + used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==TEL_ARRAY_UINT )for (i =0 ; i < d->data_len; i++) used = rte_tel_json_add_array_uint(out_buf,
Signature · 1 line
2.34.1
Quoted 53 lines
-----Original Message-----
From: Jonathan Erb <[email protected]>
Sent: Thursday, January 18, 2024 5:26 PM
To: Power, Ciara <[email protected]>
Cc: [email protected]; Richardson, Bruce <[email protected]>; Jonathan Erb <[email protected]>
Subject: [PATCH] telemetry: correct json empty dictionariesFix 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.
Signed-off-by Jonathan Erb <[email protected]>--- .mailmap | 2 +- lib/telemetry/telemetry.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-).mailmap +0
-0@@ -675,7 +675,7 @@ John Ousterhout <[email protected]> JohnRomein <[email protected]> John W. Linville <[email protected]> Jonas Pfefferle <[email protected]> <[email protected]> -Jonathan Erb <[email protected]> <[email protected]> +Jonathan Erb <[email protected]> +<[email protected]> <[email protected]>
Jonathan Tsai <[email protected]> Jon DeVree <[email protected]>
Jon Loeliger <[email protected]> diff --gita/lib/telemetry/telemetry.cb/lib/telemetry/telemetry.cindex92982842a8..eef4ac7bb7100644lib/telemetry/telemetry.c +5
-1@@ -169,7 +169,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)return snprintf (out_buf, buf_len,"null" ); - used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==TEL_DICT ) + used =rte_tel_json_empty_obj (out_buf, buf_len,0 ); +else + used =rte_tel_json_empty_array (out_buf, buf_len,0 ); +if (d->type ==TEL_ARRAY_UINT )lib/telemetry/telemetry.c +0
-1for (i =0 ; i < d->data_len; i++) used = rte_tel_json_add_array_uint(out_buf, --
Quoted 1 line
2.34.1
Quoted 8 lines · Jonathan Erb
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.
Signed-off-by Jonathan Erb <[email protected]>
Thanks for the fix.
Could you point at the change that introduced this issue?
I will add the Fixes: tag when applying.
Signature · 1 line
David Marchand
Jonathan Erb
Acked-by Bruce RichardsonDavid,
It was just a minor oversight in following commit:
commit c933bb5177cac5fbf4533e357d466cff1f3e6c97
Author: Ciara Power <[email protected]>
Date: Wed Sep 23 12:12:26 2020 +0100
telemetry: support array values in data object
Arrays of type uint64_t/int/string can now be included within an array or dict. One level of embedded containers is supported. This is necessary to allow for instances such as the ethdev queue stats to be reported as a list of uint64_t values, rather than having multiple dict entries with one uint64_t value for each queue stat.
The memory management APIs provided by telemetry simplify the memory allocation/free aspect of the embedded container. The rte_tel_data_alloc function is called in the library/app callback to return a pointer to a container that has been allocated memory. When adding this container to an array/dict, a parameter is passed to indicate if the memory should be freed by telemetry after use. This will allow reuse of the allocated memory if the library/app wishes to do so.
Quoted 14 lines · David Marchand
Quoted 7 lines · Jonathan Erb
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.
Signed-off-by Jonathan Erb <[email protected]>Thanks for the fix.
Could you point at the change that introduced this issue?I will add the Fixes: tag when applying.
Quoted 7 lines · Jonathan Erb
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.
Quoted 1 line
Signed-off-by Jonathan Erb <[email protected]>
Applied thanks.
Signature · 1 line
David Marchand