Skip to content

Commit 04befde

Browse files
41kssteveny91
andauthored
Infiniband: Skip errors when reading unimplemented metrics (#22158)
* Infiniband: Skip errors when reading unimplemented metrics * Infiniband: Add changelog for bug fix * Update infiniband/changelog.d/22158.added Co-authored-by: Steven Yuen <[email protected]> --------- Co-authored-by: Steven Yuen <[email protected]>
1 parent 35a4b90 commit 04befde

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

infiniband/changelog.d/22158.added

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Skip errors when reading unimplemented metrics

infiniband/datadog_checks/infiniband/check.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ def _collect_status_metrics(self, port_path, tags):
121121
self.monotonic_count(f"port_{status_file}.count", value, metric_tags)
122122

123123
def _submit_counter_metric(self, file_path, metric_name, tags):
124-
with open(file_path, "r") as f:
125-
value = int(f.read().strip())
124+
try:
125+
with open(file_path, "r") as f:
126+
value = int(f.read().strip())
126127

127-
if self.collection_type in {'gauge', 'both'}:
128-
self.gauge(metric_name, value, tags)
128+
if self.collection_type in {'gauge', 'both'}:
129+
self.gauge(metric_name, value, tags)
129130

130-
if self.collection_type in {'monotonic_count', 'both'}:
131-
self.monotonic_count(f"{metric_name}.count", value, tags)
131+
if self.collection_type in {'monotonic_count', 'both'}:
132+
self.monotonic_count(f"{metric_name}.count", value, tags)
133+
except OSError as e:
134+
self.log.debug("Failed to read value from %s: %s", file_path, e)

0 commit comments

Comments
 (0)