Skip to content

Commit 54f21d2

Browse files
committed
opentelemetry-instrumentation-system-metrics: don't report files descriptors on windows
1 parent 07c3324 commit 54f21d2

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,10 @@ def _instrument(self, **kwargs):
397397
unit="switches",
398398
)
399399

400-
if "process.open_file_descriptor.count" in self._config:
400+
if (
401+
sys.platform != "win32"
402+
and "process.open_file_descriptor.count" in self._config
403+
):
401404
self._meter.create_observable_up_down_counter(
402405
name="process.open_file_descriptor.count",
403406
callbacks=[self._get_open_file_descriptors],

instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# pylint: disable=protected-access
1616

17+
import sys
1718
from collections import namedtuple
1819
from platform import python_implementation
1920
from unittest import mock, skipIf
@@ -118,16 +119,20 @@ def test_system_metrics_instrument(self):
118119
f"process.runtime.{self.implementation}.thread_count",
119120
f"process.runtime.{self.implementation}.context_switches",
120121
f"process.runtime.{self.implementation}.cpu.utilization",
121-
"process.open_file_descriptor.count",
122122
]
123123

124+
on_windows = sys.platform == "win32"
124125
if self.implementation == "pypy":
125-
self.assertEqual(len(metric_names), 21)
126+
self.assertEqual(len(metric_names), 21 if on_windows else 20)
126127
else:
127-
self.assertEqual(len(metric_names), 22)
128+
self.assertEqual(len(metric_names), 22 if on_windows else 21)
128129
observer_names.append(
129130
f"process.runtime.{self.implementation}.gc_count",
130131
)
132+
if not on_windows:
133+
observer_names.append(
134+
"process.open_file_descriptor.count",
135+
)
131136

132137
for observer in metric_names:
133138
self.assertIn(observer, observer_names)

0 commit comments

Comments
 (0)