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 C6DFB43DAC; Mon, 1 Apr 2024 23:28:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B340402A3; Mon, 1 Apr 2024 23:28:29 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id BFC68402D9 for ; Mon, 1 Apr 2024 23:28:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712006907; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bKUWhSQATwqihfdGhB1DJi0RaYI+dj/ks6Wro3YmRYw=; b=V0DHdk/ESEScoWudt46IFbJDSRIU3fDKhFjl8N4IJctVAQMCPT7MiCiaM7F15eJAK5xNNA bORZYN/bnGvHJSiFSwSer6teKLBRQD05yIk856GConTZB0OuCj64xaTiVa30ciWacSQ3yo 28wPzu3WETi+VYYDfAsbW2QWGmgZEcc= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44-699dfV6gOkGpmFI2JrkzOg-1; Mon, 01 Apr 2024 17:28:25 -0400 X-MC-Unique: 699dfV6gOkGpmFI2JrkzOg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4156e6f39c6so2270855e9.0 for ; Mon, 01 Apr 2024 14:28:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712006904; x=1712611704; h=in-reply-to:references:user-agent:to:from:cc:subject:message-id :date:content-transfer-encoding:mime-version:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bKUWhSQATwqihfdGhB1DJi0RaYI+dj/ks6Wro3YmRYw=; b=VzO9SWcJ/qWrKFYMz2xuWQRjScCrPt5DpSpjfuZ4ictbKH0i8D7FJMN+nWCU3AKzuB x5TJzfsbgM2NhsfKtETKNf0vysVUIKaw42Jux5xkvD4+0xKVEcOsJcpqm84QqIXD9OeE qz2UM1d5C1Zhfknb1m8Z+g/jNJNhM9ScVNE5gA/0NUm94JJaeJnTQwDoVmN9tbamacqI 0s5P9kOtK+f2gWSvYFgtehgddcrKnczL06haqxtUgXhDCTaPrao93Dy4TnqpY5MLDaeA eKka/tNnzMQBOBoyjZxflFxFfIlj6NY6sRtwbDHqbRWA4js+3hmSMDrfeZ4Pe5IXbClR QRvg== X-Gm-Message-State: AOJu0YzzKLO/qZAzR00dsTeY1d+gyYkS1eF/BSm0UBi0D72Dkq030oIv px17GY0EXaTqsclotiJPnundjgv8CUbwa/4ykWa4ov2VEYk4CIbi6ED04Q1ztmdpxKgn+2xlDdE YMUaLMFss17eF5WInwUpZQVKQqqAMfRcsED8n4mOqz1u+3B7t X-Received: by 2002:a05:600c:3d90:b0:415:6b33:39f0 with SMTP id bi16-20020a05600c3d9000b004156b3339f0mr1817448wmb.27.1712006904042; Mon, 01 Apr 2024 14:28:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7d3bOJKPt9lVCiQpgUV3GcRffGYsEBA80IN4XK9lGhquOUPMnYYFcE+FTX8XXc64wJ68KSw== X-Received: by 2002:a05:600c:3d90:b0:415:6b33:39f0 with SMTP id bi16-20020a05600c3d9000b004156b3339f0mr1817445wmb.27.1712006903638; Mon, 01 Apr 2024 14:28:23 -0700 (PDT) Received: from localhost (2a01cb000f8b9700ffd8872f0c4ad9d4.ipv6.abo.wanadoo.fr. [2a01:cb00:f8b:9700:ffd8:872f:c4a:d9d4]) by smtp.gmail.com with ESMTPSA id h9-20020a05600c314900b00415b1186ff8sm461979wmo.28.2024.04.01.14.28.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Apr 2024 14:28:22 -0700 (PDT) Mime-Version: 1.0 Date: Mon, 01 Apr 2024 23:28:22 +0200 Message-Id: Subject: Re: [RFC PATCH] usertools: add telemetry exporter Cc: From: "Robin Jarry" To: "Anthony Harivel" User-Agent: aerc/0.17.0-87-gf035bc4dbe48 References: <20230926163442.844006-2-rjarry@redhat.com> <20240327151842.169512-1-aharivel@redhat.com> In-Reply-To: <20240327151842.169512-1-aharivel@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed 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 Anthony Harivel, Mar 27, 2024 at 16:18: > Hi Robin, > > Thanks for this patch. I did test it and it works as expected.=20 > Nonetheless, maybe we can improve on some parts. Hey Anthony, thanks a lot for testing! > In 'class TelemetrySocket', there is: > ... > self.sock.connect(path) > data =3D json.loads(self.sock.recv(1024).decode()) > ... > > Maybe we can improve with something like: > > try: > rcv_data =3D self.sock.recv(1024) > if rcv_data: > data =3D json.loads(rcv_data.decode()) > else: > print("No data received from socket.") > except json.JSONDecodeError as e: > print("Error decoding JSON:", e) > except Exception as e: > print("An error occurred:", e) > > So that it handles a bit better the error cases. This is undesired as it would actually mask the errors from the calling=20 code. Unless you can do something about the error, printing it should be=20 left to the calling code. I will handle these errors better in v2. > In the same way to implement more robust error handling mechanisms in: > def load_endpoints > ... > except Exception as e: > LOG.error("Failed to load endpoint module '%s' from '%s': %s", name, = f, e) > ... > > For example, you might catch FileNotFoundError, ImportError, or SyntaxErr= or. > That could help to debug! We could print the whole stack trace but I don't see what special=20 handling could be done depending on the exception. I will try to make=20 this better for v2. > About TelemetryEndpoint I would see something like: > > class TelemetryEndpoint: > """ > Placeholder class only used for typing annotations. > """ > > @staticmethod > def info() -> typing.Dict[MetricName, MetricInfo]: > """ > Mapping of metric names to their description and type. > """ > raise NotImplementedError() > > @staticmethod > def metrics(sock: TelemetrySocket) -> typing.List[MetricValue]: > """ > Request data from sock and return it as metric values. Each metri= c > name must be present in info(). > """ > try: > metrics =3D [] > metrics_data =3D sock.fetch_metrics_data() > for metric_name, metric_value in metrics_data.items(): > metrics.append((metric_name, metric_value, {})) > return metrics > except Exception as e: > LOG.error("Failed to fetch metrics data: %s", e) > # If unable to fetch metrics data, return an empty list > return [] > > With these changes, the metrics method of the TelemetryEndpoint class=20 > could handle errors better and the exporter can continue functioning=20 > even if there are issues with fetching metrics data. > > I don't know if all of that makes sens or if it's just nitpicking!=20 > I can also propose an enhanced version of your patch if you prefer. As indicated in the docstring, this class is merely a placeholder. Its=20 code is never executed. It only stands to represent what functions must=20 be implemented in endpoints. However, your point is valid. I will update my code to handle errors in=20 endpoints more gracefully and avoid failing the whole request if there=20 is only one error. Thanks for the thorough review!