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 E6BEE43D55; Wed, 27 Mar 2024 16:18:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 74046402B2; Wed, 27 Mar 2024 16:18:55 +0100 (CET) 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 4D918402A3 for ; Wed, 27 Mar 2024 16:18:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711552732; 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=Jz0idjAEEdNs08Bfj+fAjxp+5jUmBAFL8KopEXJv5lw=; b=Y77n6SwwsvVdQBG+sopuv3u1ncLyAeSICBPwtQSOBFwBRx/u5RAbHVh0veMTLFM3Vc336T R0Smvp0DHWNNZk9vuwol2D1Muroo2V98aCtMmpXNu6/O8SsvLVuSllbm6p5s1wX7llJPex J9aDbzZmkRta6SCdCHjPhVrPJa9f81I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-220-en1I-f6TOPW7Yr628ahn7Q-1; Wed, 27 Mar 2024 11:18:51 -0400 X-MC-Unique: en1I-f6TOPW7Yr628ahn7Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A13A185A78E for ; Wed, 27 Mar 2024 15:18:51 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 620BB492BDA; Wed, 27 Mar 2024 15:18:50 +0000 (UTC) From: Anthony Harivel To: rjarry@redhat.com Cc: dev@dpdk.org Subject: [RFC PATCH] usertools: add telemetry exporter Date: Wed, 27 Mar 2024 16:18:36 +0100 Message-ID: <20240327151842.169512-1-aharivel@redhat.com> In-Reply-To: <20230926163442.844006-2-rjarry@redhat.com> References: <20230926163442.844006-2-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 Hi Robin, Thanks for this patch. I did test it and it works as expected. Nonetheless, maybe we can improve on some parts. In 'class TelemetrySocket', there is: ... self.sock.connect(path) data = json.loads(self.sock.recv(1024).decode()) ... Maybe we can improve with something like: try: rcv_data = self.sock.recv(1024) if rcv_data: data = 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. 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 SyntaxError. That could help to debug! 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 metric name must be present in info(). """ try: metrics = [] metrics_data = 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 could handle errors better and the exporter can continue functioning 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 ! I can also propose an enhanced version of your patch if you prefer. Regards, Anthony