Skip to contentSkip to conversation

telemetry: correct json empty dictionaries

PATCH In review Jonathan Erb 4 participants 10 messages Jan 5, 2024 – Feb 12, 2024

lore
Share & tools
lore
#0 lore raw

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
index ab0742a382..a3302ba7a1 100644
@@ -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
index 92982842a8..0788a32210 100644
@@ -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
#1 lore raw

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
index 0788a32210..eef4ac7bb7 100644
@@ -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
#2 lore raw
Quoted 3 lines · Jonathan Erb

Fix use of incorrect enum name.

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
index 0788a32210..eef4ac7bb7 100644
@@ -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
Acked-by on v2 1/2
#3 lore raw
In reply to Jonathan Erb
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.

One minor comment below.

Quoted 10 lines
---
 .mailmap                  | 2 +-
 lib/telemetry/telemetry.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
.mailmap +0 -0
index ab0742a382..a3302ba7a1 100644

.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 -0
 Jonathan Tsai <[email protected]>
 Jon DeVree <[email protected]>
 Jon Loeliger <[email protected]>
lib/telemetry/telemetry.c +5 -1
index 92982842a8..0788a32210 100644
@@ -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
Acked-by on v2 1/2
#4 lore raw
In reply to Jonathan Erb

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 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 +0 -0
index ab0742a382..a3302ba7a1 100644
@@ -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]> diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 92982842a8..0788a32210 100644

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)
lib/telemetry/telemetry.c +0 -1
 		for (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,

#5 lore raw

PATCH 1/1 telemetry: correct json empty dictionaries

In reply to 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.

---
 .mailmap                  | 2 +-
 lib/telemetry/telemetry.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
.mailmap +1 -1
index ab0742a382..a6b66ab3ad 100644
@@ -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
index 92982842a8..eef4ac7bb7 100644
@@ -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
Acked-by on v1 1/1
#6 lore raw
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 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 +0 -0
index ab0742a382..a6b66ab3ad 100644
@@ -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]> diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 92982842a8..eef4ac7bb7 100644

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)
lib/telemetry/telemetry.c +0 -1
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_uint(out_buf,
--
Quoted 1 line

2.34.1

#7 lore raw
In reply to Jonathan Erb
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.

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
author Acked-by Bruce Richardson
#8 lore raw

David,

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.

Thanks for the fix.
Could you point at the change that introduced this issue?

I will add the Fixes: tag when applying.

Acked-by Ciara Power on v1 1/1
#9 lore raw
In reply to Jonathan Erb
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.

Fixes c933bb5177ca ("telemetry: support array values in data object")
Quoted 1 line

Applied thanks.

Signature · 1 line
David Marchand