From 68b3ec3d471f7f60ed67525beb5ba620b81693e5 Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Sat, 24 Feb 2024 18:26:54 +0100 Subject: [PATCH] Improved lengthy warning details messages when resource not found Details: * Improved the lengthy warning details messages when resources have not been found to a more condensed and useful format. (issue #473) Signed-off-by: Andreas Maier --- docs/changes.rst | 3 +++ .../zhmc_prometheus_exporter.py | 20 +++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index 317c403..07e2d92 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -139,6 +139,9 @@ will also work with the prior version of the file (but not vice versa). * Disabled the use of Python builtins in the evaluation of 'fetch-condition' and 'export-condition' in the metric definition file. (issue #463) +* Improved the lengthy warning details messages when resources have not been + found to a more condensed and useful format. (issue #473) + **Known issues:** * See `list of open issues`_. diff --git a/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py b/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py index 74cc887..247eb7b 100755 --- a/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py +++ b/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py @@ -966,19 +966,19 @@ def resource(self, uri, object_value): format(uri, mgd.name)) for mgr in exc.managers: res_class = mgr.class_name - logprint(logging.WARNING, PRINT_ALWAYS, + logprint(logging.WARNING, PRINT_VV, "Warning details: List of {} resources found:". format(res_class)) - res_dict = {} - resources = mgr.list() - for res in resources: - res_dict[res.uri] = res - logprint(logging.WARNING, PRINT_ALWAYS, - repr(res_dict)) - logprint(logging.WARNING, PRINT_ALWAYS, + for res in mgr.list(): + logprint(logging.WARNING, PRINT_VV, + "Warning details: Resource found: {} ({})". + format(res.uri, res.name)) + logprint(logging.WARNING, PRINT_VV, "Warning details: Current resource cache:") - logprint(logging.WARNING, PRINT_ALWAYS, - repr(self._resources)) + for res in self._resources.values(): + logprint(logging.WARNING, PRINT_VV, + "Warning details: Resource cache: {} ({})". + format(res.uri, res.name)) raise self._resources[uri] = _resource return _resource