From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3208DA00C2; Fri, 14 Oct 2022 18:10:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE72241144; Fri, 14 Oct 2022 18:10:28 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 2252B40A82 for ; Fri, 14 Oct 2022 18:10:27 +0200 (CEST) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v2] usertools: telemetry json support pretty print Date: Fri, 14 Oct 2022 18:10:24 +0200 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D873E4@smartserver.smartshare.dk> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v2] usertools: telemetry json support pretty print Thread-Index: Adjf4c1jBDTICclFR4qxbzauyx6X2wABID9w References: <20221014023338.51464-1-fengchengwen@huawei.com> <20221014032504.32534-1-fengchengwen@huawei.com> <20221014080111.79c7c0bd@hermes.local> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Bruce Richardson" , "Stephen Hemminger" Cc: "Power, Ciara" , "David Marchand" , "Chengwen Feng" , , X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > Sent: Friday, 14 October 2022 17.30 >=20 > On Fri, Oct 14, 2022 at 08:01:11AM -0700, Stephen Hemminger wrote: > > On Fri, 14 Oct 2022 14:02:10 +0100 > > Bruce Richardson wrote: > > > > > On Fri, Oct 14, 2022 at 12:44:33PM +0000, Power, Ciara wrote: > > > > Hi Chengwen, > > > > > > > > > -----Original Message----- > > > > > From: David Marchand > > > > > Sent: Friday 14 October 2022 10:50 > > > > > To: Chengwen Feng > > > > > Cc: thomas@monjalon.net; dev@dpdk.org; Power, Ciara > > > > > > > > > > Subject: Re: [PATCH v2] usertools: telemetry json support > pretty print > > > > > > > > > > On Fri, Oct 14, 2022 at 5:31 AM Chengwen Feng > > > > > > wrote: > > > > > > > > > > > > Currently, the dpdk-telemetry.py show json in raw format, > which is not > > > > > > good for human reading. > > > > > > > > > > > > E.g. The command '/ethdev/xstats,0' will output: > > > > > > {"/ethdev/xstats": {"rx_good_packets": 0, "tx_good_packets": > 0, > > > > > > "rx_good_bytes": 0, "tx_good_bytes": 0, "rx_missed_errors": > 0, > > > > > > "rx_errors": 0, "tx_errors": 0, "rx_mbuf_allocation_errors": > 0, > > > > > > "rx_q0_packets": 0,...}} > > > > > > > > > > > > This patch supports json pretty print by adding extra > indent=3D4 > > > > > > parameter, so the same command will output: > > > > > > { > > > > > > "/ethdev/xstats": { > > > > > > "rx_good_packets": 0, > > > > > > "tx_good_packets": 0, > > > > > > "rx_good_bytes": 0, > > > > > > "tx_good_bytes": 0, > > > > > > "rx_missed_errors": 0, > > > > > > "rx_errors": 0, > > > > > > "tx_errors": 0, > > > > > > "rx_mbuf_allocation_errors": 0, > > > > > > "rx_q0_packets": 0, > > > > > > ... > > > > > > } > > > > > > } > > > > > > > > > > > > Signed-off-by: Chengwen Feng > > > > > > > > > > It's indeed easier to read, but maybe 4 chars is too much. > > > > > 2 chars seem enough to me. > > > > [CP] > > > > +1 on using 2 chars +1 to 2 spaces, following the convention of the rte__dump() = functions in DPDK. > > > > > > > > > > > > > > In any case I like the idea: > > > > > > I like it too, for interactive use. However, we also have some > hooks in the > > > code for when the app is being run non-interactively i.e. from a > script. In > > > that case, we probably want the indent to be unused. > > > > > > The function "handle_socket()" tracks if the output is a tty via > the "prompt" > > > variable. That could be passed through to the "read_socket()" call > to > > > optionally not-indent the output. > > > > > > /Bruce > > > > Convention in other tools is a -p flag for "pretty output" >=20 > Since we already support detecting interactive use, I think having the > pretty output by default in that case is probably good. +1 to pretty by default. > For non- > interactive > use a -p flag might make sense, but even then I'm not sure it's hugely > worthwhile. +1 to Bruce's comment about not being worthwhile. And we would need the = inverse of -p. :-) Closely related: If we agree that the JSON output is either for human or machine = consumption, why don't we give JANSSON the JSON_COMPACT flag to save = some spaces?