Skip to content

Commit

Permalink
Improved lengthy warning details messages when resource not found
Browse files Browse the repository at this point in the history
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 <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Mar 1, 2024
1 parent 1876b48 commit 68b3ec3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions docs/changes.rst
Expand Up @@ -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`_.
Expand Down
20 changes: 10 additions & 10 deletions zhmc_prometheus_exporter/zhmc_prometheus_exporter.py
Expand Up @@ -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
Expand Down

0 comments on commit 68b3ec3

Please sign in to comment.