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 19D264383B; Fri, 5 Jan 2024 10:03:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 328B2402EC; Fri, 5 Jan 2024 10:03:06 +0100 (CET) Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) by mails.dpdk.org (Postfix) with ESMTP id 33E5B40268 for ; Sun, 24 Dec 2023 23:02:07 +0100 (CET) Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-67fe0210665so5784486d6.1 for ; Sun, 24 Dec 2023 14:02:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=threater-com.20230601.gappssmtp.com; s=20230601; t=1703455326; x=1704060126; 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=qkH1KqvcdfTtiUUuEYmmWfwOMWbJKllCMFMO9u7gootuWomSuHTIT9gOX3414NMdYM 0uA8p8wPVPrVz9KAG1ZGkRciQV6FtO8vtQNj9lzah9xN/S3YiG8wOsaInI1nBwpUa2oF t34BZYXWeXUFqPJGKCNRz4wwhQag96GuKvQ8Eb91mOcIRVrocwKURDmQwysMoQb39TFY VPszXRuWmGf36BBCFlcRAaF6Y6/pc19Zjhe6wZtAUgAQOD6+85+dfdOKQquzd4XWQ3+C z1h1uDdIye3t3wTQAE0lZf+ss59ixVfqAEPADAthoe0PWPTqi78LTcNbt5btt9DM9wbA BUVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703455326; x=1704060126; 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=cfqU7vCL3uxPSkunwIcbelg3Y7umdj0i20L/p5ZqpSnHKG/6zNAa13CLFDXF86KVvx T9X8vu/6PvCB3HB/hf9h5UvTlOj2jLMF9I1+CzN1c7B/KQp2j7lOCQoK0+TEKslnBt4g ZqcbdKjehWxM7upLOArEEOk2eIqd13qqFV/4QczZkh7d6cHsTtPA2DngotqKfMa2hmaV o1ijZeH2/iNapFghXYh6NCTmp3FAvB73MDTU83BUCKV7E7dj04Xvqkm0Bk+D4toAJ4P8 yBaOuNA3cNNxnRKhbothDjYAZHjyXkzulNoVbwM7nZfyA0r3d6VD/T6SpQTK12b3ZTHi fQRg== X-Gm-Message-State: AOJu0Yy8fDvuG41BuN/E4BCcaYDpzIflq35SE9dSA96CIHkietMdUllx SSKbwfmeqwxO5+PZzrXFE13rxEuqcAPw5A== X-Google-Smtp-Source: AGHT+IHpCZolmxEz4ZSeDTpvWTbJnfWk0ugpPQR6fbtdPaYLnkPkDhfhqIkzY65ojS/rBrH3kx9AtQ== X-Received: by 2002:a05:620a:108a:b0:77e:fba3:757e with SMTP id g10-20020a05620a108a00b0077efba3757emr5731221qkk.118.1703455326414; Sun, 24 Dec 2023 14:02:06 -0800 (PST) Received: from localhost.localdomain (dyn-170-246-97.myactv.net. [24.170.246.97]) by smtp.gmail.com with ESMTPSA id bi5-20020a05620a318500b0077efb969151sm3045939qkb.59.2023.12.24.14.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 14:02:05 -0800 (PST) From: Jonathan Erb To: ciara.power@intel.com Cc: dev@dpdk.org, Jonathan Erb Subject: [PATCH v2 1/2] telemetry: correct json empty dictionaries Date: Sun, 24 Dec 2023 17:02:00 -0500 Message-Id: <20231224220201.762377-1-jonathan.erb@threater.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 05 Jan 2024 10:03:03 +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, -- 2.34.1