From patchwork Mon Dec 18 21:47:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Erb X-Patchwork-Id: 135401 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 611B04374A; Wed, 20 Dec 2023 15:35:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9D8742DDB; Wed, 20 Dec 2023 15:35:53 +0100 (CET) Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by mails.dpdk.org (Postfix) with ESMTP id 8E09E4064C for ; Mon, 18 Dec 2023 22:48:30 +0100 (CET) Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3b9e07690ccso2414443b6e.3 for ; Mon, 18 Dec 2023 13:48:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=threater-com.20230601.gappssmtp.com; s=20230601; t=1702936110; x=1703540910; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RXV/8pqaCxI+/nmizlhJ+DLtzJEy/7iURxiM1fsDVEM=; b=bCqhKtfc9481kneR7a82Kh6HQajgNAWPmckC9kvMbMyA/RJEOyIDBkmr3GZMSgtExQ E1ZocJhWvxtOgYQqeRND6Z0LUfzKFR7qnqZ+76a2ovX97qZy1JgL2xaqsw2lnaxDZVna XO7vW3Ukyik13LBilSNJ/VRC6GkzstliVkm8UlCgIrTGAQdUjgd9YLqFqr+KBQIhi6Pb +vOZeKkcfTP9erS+4qe6MJ5UJeHFo+ZpY/hBgSas+XSo1FcBJWOnFuk4nwqg56h7d5+/ m35jemaFrvlsdgF41kxYeb0vfrLPMrAINsfrqKS/YpH/KvsIEw5AJw9I646yW3uerWpo 5w2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702936110; x=1703540910; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RXV/8pqaCxI+/nmizlhJ+DLtzJEy/7iURxiM1fsDVEM=; b=rcvpoksjLRk3veuR+Kyobn/bdTHwqeRGw/ZcYmr+FBEE9aa5Vbm9JemBW2K48ErAS8 c87yiQQsu4Ab1hXAW45v1p5WOBPbOwNCY/efEm+nkYEAQtBHOmWh8lyNnzi69jw7qgC6 qxi9u6GxXJkp53y7hf+lXWiurFeWkOAlNYzWe/JJlvbQQQo1oGtkIRoSBVXE/KLU5oLQ L1UZgwBbKuNKVmDovYOypViG0YOnAHfwHvxtNGN1N3F66SphmsjGQKGlmSnaepqyita4 9akfgbldnheVWJtM2ua3V4A/K+eoYJU0q3Oaucs4Y2OpxUAoaI4srDNKj3NgF84slQC9 ZVfw== X-Gm-Message-State: AOJu0YxMRXmtF31L7vkv10kEzw8xIuyv/VxhtDYdFCFKW+Y7EM1iRFHb IPuUIsirqMWB5dnDMXPyX4//Kg== X-Google-Smtp-Source: AGHT+IGgpyAc9L66JXy22hC3iiTDylYsthgFQK5vL2WfsOzBg5GwEh5MLTGaKdl6tKIfaLctRfT15w== X-Received: by 2002:a05:6808:1708:b0:3b9:d7a0:d152 with SMTP id bc8-20020a056808170800b003b9d7a0d152mr19719948oib.40.1702936109739; Mon, 18 Dec 2023 13:48:29 -0800 (PST) Received: from localhost.localdomain (dyn-170-246-97.myactv.net. [24.170.246.97]) by smtp.gmail.com with ESMTPSA id w18-20020a0cef92000000b0067f2c03d4adsm2432094qvr.100.2023.12.18.13.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 13:48:29 -0800 (PST) From: Jonathan Erb To: ciara.power@intel.com Cc: dev@dpdk.org, Jonathan Erb Subject: [PATCH] telemetry: correct json empty dictionaries Date: Mon, 18 Dec 2023 16:47:59 -0500 Message-Id: <20231218214759.134188-1-jonathan.erb@threater.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 20 Dec 2023 15:35:52 +0100 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 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 --- .mailmap | 2 +- lib/telemetry/telemetry.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index ab0742a382..a3302ba7a1 100644 --- a/.mailmap +++ b/.mailmap @@ -675,7 +675,7 @@ John Ousterhout John Romein John W. Linville Jonas Pfefferle -Jonathan Erb +Jonathan Erb Jonathan Tsai Jon DeVree Jon Loeliger diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 92982842a8..0788a32210 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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,