Skip to content

Commit 76c8452

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

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
([#2940](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2940))
3939
- `opentelemetry-instrumentation-dbapi` sqlcommenter key values created from PostgreSQL, MySQL systems
4040
([#2897](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2897))
41+
- `opentelemetry-instrumentation-system-metrics`: don't report open file descriptors on Windows
42+
([#2946](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2946))
4143

4244
### Breaking changes
4345

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

+4-1
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

+13-3
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,21 +119,30 @@ 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), 20 if on_windows else 21)
126127
else:
127-
self.assertEqual(len(metric_names), 22)
128+
self.assertEqual(len(metric_names), 21 if on_windows else 22)
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)
134139
observer_names.remove(observer)
135140

141+
if on_windows:
142+
self.assertNotIn(
143+
"process.open_file_descriptor.count", observer_names
144+
)
145+
136146
def test_runtime_metrics_instrument(self):
137147
runtime_config = {
138148
"process.runtime.memory": ["rss", "vms"],

0 commit comments

Comments
 (0)