All of lore.kernel.org
 help / color / mirror / Atom feed
From: fengchengwen <fengchengwen@huawei.com>
To: Bruce Richardson <bruce.richardson@intel.com>, <dev@dpdk.org>
Subject: Re: [PATCH v2 00/13] telemetry JSON escaping and other enhancements
Date: Wed, 27 Jul 2022 09:51:04 +0800	[thread overview]
Message-ID: <a968875c-7758-2e92-515f-f6aab2628e72@huawei.com> (raw)
In-Reply-To: <20220725163543.875775-1-bruce.richardson@intel.com>

Hi Bruce,

I think escape the string at begin (following function) seem more simple:
	rte_tel_data_string
	rte_tel_data_add_array_string
	rte_tel_data_add_dict_string

int
rte_tel_data_string(struct rte_tel_data *d, const char *str)
{
	d->type = RTE_TEL_STRING;
	d->data_len = strlcpy(d->data.str, str, sizeof(d->data.str));
		// e.g. do escape here!
	if (d->data_len >= RTE_TEL_MAX_SINGLE_STRING_LEN) {
		d->data_len = RTE_TEL_MAX_SINGLE_STRING_LEN - 1;
		return E2BIG; /* not necessarily and error, just truncation */
	}
	return 0;
}

Advantages:
1. simpler implementation
2. application are directly visible the result (by judge API retval) without waiting for JSON encapsulation.

Disadvantages:
1. not friend for new output format, but currently telemetry deep depend on json, so I think it's OK for it.


On 2022/7/26 0:35, Bruce Richardson wrote:
> This patchset contains fixes for the problem of handling characters
> returned by telemetry callbacks which require escaping when encoded in
> JSON format. It also includes unit tests to validate the correct
> encoding in such scenarios and a number of smaller enhancements to
> telemetry and telemetry testing.
> 
> RFC->V2:
> * limited characters allowed in dictionary element names and command
>   names to side-step the encoding problems there.
> * added support for proper escaping of dictionary string values
> * added more testing and test cases
> * added other misc telemetry cleanups and refactoring
> 
> Bruce Richardson (13):
>   test/telemetry_json: print success or failure per subtest
>   telemetry: fix escaping of invalid json characters
>   test/telemetry_json: add test for string character escaping
>   telemetry: add escaping of strings in arrays
>   test/telemetry-json: add test for escaping strings in arrays
>   telemetry: limit characters allowed in dictionary names
>   telemetry: add escaping of strings in dicts
>   test/telemetry_json: add test for string escaping in objects
>   telemetry: limit command characters
>   test/telemetry_data: refactor for maintainability
>   test/telemetry_data: add test cases for character escaping
>   telemetry: eliminate duplicate code for json output
>   telemetry: make help command more helpful
> 
>  app/test/test_telemetry_data.c       | 138 +++++++++++++++++++--------
>  app/test/test_telemetry_json.c       |  98 +++++++++++++++++--
>  doc/guides/rel_notes/deprecation.rst |   8 --
>  lib/telemetry/rte_telemetry.h        |   8 ++
>  lib/telemetry/telemetry.c            |  51 +++++-----
>  lib/telemetry/telemetry_data.c       |  32 +++++++
>  lib/telemetry/telemetry_json.h       |  72 ++++++++++++--
>  7 files changed, 318 insertions(+), 89 deletions(-)
> 
> --
> 2.34.1
> 
> 
> .
> 


  parent reply	other threads:[~2022-07-27  1:51 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 16:42 [RFC PATCH 0/6] add json string escaping to telemetry Bruce Richardson
2022-06-23 16:42 ` [RFC PATCH 1/6] test/telemetry_json: print success or failure per subtest Bruce Richardson
2022-06-23 16:42 ` [RFC PATCH 2/6] telemetry: fix escaping of invalid json characters Bruce Richardson
2022-06-23 18:34   ` Morten Brørup
2022-06-23 18:39     ` Stephen Hemminger
2022-06-23 18:48       ` Morten Brørup
2022-06-24  8:00         ` Bruce Richardson
2022-06-24 11:16           ` Bruce Richardson
2022-06-24 11:29             ` Morten Brørup
2022-06-24 15:06               ` Stephen Hemminger
2022-06-24  8:03     ` Bruce Richardson
2022-06-23 16:42 ` [RFC PATCH 3/6] telemetry: use json string function for string outputs Bruce Richardson
2022-06-23 16:42 ` [RFC PATCH 4/6] test/telemetry_json: add test for string character escaping Bruce Richardson
2022-06-23 16:42 ` [RFC PATCH 5/6] telemetry: add escaping of strings in arrays Bruce Richardson
2022-06-23 16:42 ` [RFC PATCH 6/6] test/telemetry-json: add test case for escaping " Bruce Richardson
2022-06-23 19:04 ` [RFC PATCH 0/6] add json string escaping to telemetry Morten Brørup
2022-06-24  8:13   ` Bruce Richardson
2022-06-24  9:12     ` Morten Brørup
2022-06-24  9:17       ` Bruce Richardson
2022-06-24 10:22         ` Morten Brørup
2022-07-14 15:42 ` Morten Brørup
2022-07-25 16:38   ` Bruce Richardson
2022-07-25 16:35 ` [PATCH v2 00/13] telemetry JSON escaping and other enhancements Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 01/13] test/telemetry_json: print success or failure per subtest Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 02/13] telemetry: fix escaping of invalid json characters Bruce Richardson
2022-07-26 18:25     ` Morten Brørup
2022-07-27  8:21       ` Bruce Richardson
2022-07-27  1:13     ` fengchengwen
2022-07-27  8:27       ` Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 03/13] test/telemetry_json: add test for string character escaping Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 04/13] telemetry: add escaping of strings in arrays Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 05/13] test/telemetry-json: add test for escaping " Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 06/13] telemetry: limit characters allowed in dictionary names Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 07/13] telemetry: add escaping of strings in dicts Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 08/13] test/telemetry_json: add test for string escaping in objects Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 09/13] telemetry: limit command characters Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 10/13] test/telemetry_data: refactor for maintainability Bruce Richardson
2022-08-23 12:33     ` Power, Ciara
2022-07-25 16:35   ` [PATCH v2 11/13] test/telemetry_data: add test cases for character escaping Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 12/13] telemetry: eliminate duplicate code for json output Bruce Richardson
2022-07-25 16:35   ` [PATCH v2 13/13] telemetry: make help command more helpful Bruce Richardson
2022-07-26 14:36   ` [PATCH v2 00/13] telemetry JSON escaping and other enhancements Morten Brørup
2022-07-27  1:51   ` fengchengwen [this message]
2022-07-27  9:12     ` Bruce Richardson
2022-07-27  9:49       ` Morten Brørup
2022-08-23 12:35   ` Power, Ciara
2022-09-09  9:35 ` [PATCH v3 " Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 01/13] telemetry: limit characters allowed in dictionary names Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 02/13] test/telemetry_json: print success or failure per subtest Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 03/13] telemetry: fix escaping of invalid json characters Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 04/13] test/telemetry_json: add test for string character escaping Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 05/13] telemetry: add escaping of strings in arrays Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 06/13] test/telemetry-json: add test for escaping " Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 07/13] telemetry: add escaping of strings in dicts Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 08/13] test/telemetry_json: add test for string escaping in objects Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 09/13] telemetry: limit command characters Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 10/13] test/telemetry_data: refactor for maintainability Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 11/13] test/telemetry_data: add test cases for character escaping Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 12/13] telemetry: eliminate duplicate code for json output Bruce Richardson
2022-09-09  9:35   ` [PATCH v3 13/13] telemetry: make help command more helpful Bruce Richardson
2022-09-13  0:35   ` [PATCH v3 00/13] telemetry JSON escaping and other enhancements fengchengwen
2022-09-26 11:52   ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a968875c-7758-2e92-515f-f6aab2628e72@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.