From patchwork Thu Jan 18 17:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Erb X-Patchwork-Id: 135978 X-Patchwork-Delegate: david.marchand@redhat.com 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 A85CC438FC; Fri, 19 Jan 2024 08:48:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D5924111C; Fri, 19 Jan 2024 08:48:43 +0100 (CET) Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by mails.dpdk.org (Postfix) with ESMTP id BAC1B40295 for ; Thu, 18 Jan 2024 18:26:07 +0100 (CET) Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-42a0fa5d202so11063941cf.2 for ; Thu, 18 Jan 2024 09:26:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=threater-com.20230601.gappssmtp.com; s=20230601; t=1705598767; x=1706203567; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TQ1UumE0WwaJ+jUwR/6ya6+Rg7byKLEVwWV0UleFmyA=; b=ezoMdEyIHkIy1LaqFj43SfPndKucwM32AmCATYmOHZUYDzsZDxPu2o3ogToIOvVx7c 8zTgMJZP/5hgb7TBYEk81/XD/O8ppbnKSCwEtnStKNd8hLeZuWzEHD+kb5MgU6SIaSd7 VbtLTYweBGWDB5Eejg+/eKOqvW43HWNflafkT6Nxhh/g9LMYeygyQausLTr5cuBl7D8/ IbvEP2NfKWL/CMs4fCEIgyeJZ7MK3eiai4ruSbXy2dVdjLufHVnKFQdSafb41bR00Yuc +GTjrkrWIXl4jdel1JbZPkxC+gzsodxAeLr7J/LXBtztXVDLFt9I6QvfZUBSGuFjvqWc KwfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705598767; x=1706203567; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TQ1UumE0WwaJ+jUwR/6ya6+Rg7byKLEVwWV0UleFmyA=; b=Gbpvb/Pr9744HREiUhdcSeJhQOwTAqhb0Gn4RL5D2ApkmPBPgfQQnV+a5ozPXnvUg/ TYmIVAELSnnjo5aYbE1McK4xdqSw8FvWkR3tO8XbiARFI/vI1xYL3lLXYNPGPTszcR81 m/KQUkfWndSBGwOqfB3tow0MTQ3O7y05rWyoOjAfZRc0e3Svjan5zIG2Sy8d2wYvy9gY XW3HGPzGigpB8pPxSPWOIouSILiRb7530xOoMZXZAiWcaWy3eiaRpjOtpa+ldc133i78 hVZC9Mm2NZTHrPvERORfZLUu7fG9Zx9ag0pSCHQ+47P2ExKUkwtFMQxEHYQMkFKplj6F gpJQ== X-Gm-Message-State: AOJu0Yyredd5s4x+B5lZ8yhV1aqrScyY1fdZ3mzPJt23rBF2DVDytZIG YEW6wetB6yQRMDuLIRFdQbsD7Zzk2AA/QWSgqihWW9szDA0SpnZNFJfzpxE8iDQ= X-Google-Smtp-Source: AGHT+IEq1a7y2g3hNlp1AqovfOejppet6jxA3a59nn5bMOlb0YzSu0mbphVF5a5DqFqtIungOgepRg== X-Received: by 2002:ac8:5994:0:b0:429:e2fa:fdc0 with SMTP id e20-20020ac85994000000b00429e2fafdc0mr1088265qte.43.1705598767109; Thu, 18 Jan 2024 09:26:07 -0800 (PST) Received: from localhost.localdomain (dyn-170-246-97.myactv.net. [24.170.246.97]) by smtp.gmail.com with ESMTPSA id bb21-20020a05622a1b1500b0042a04add8a4sm2618914qtb.60.2024.01.18.09.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 09:26:06 -0800 (PST) From: Jonathan Erb To: ciara.power@intel.com Cc: dev@dpdk.org, bruce.richardson@intel.com, Jonathan Erb Subject: [PATCH] telemetry: correct json empty dictionaries Date: Thu, 18 Jan 2024 12:26:02 -0500 Message-Id: <20240118172602.898004-1-jonathan.erb@threater.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231224220201.762377-1-jonathan.erb@threater.com> References: <20231224220201.762377-1-jonathan.erb@threater.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 19 Jan 2024 08:48:40 +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 Acked-by: Ciara Power Acked-by: Ciara Power --- .mailmap | 2 +- lib/telemetry/telemetry.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index ab0742a382..a6b66ab3ad 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..eef4ac7bb7 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 == 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,