Skip to content

Commit

Permalink
opentelemetry-instrumentation-system-metrics: don't report files desc…
Browse files Browse the repository at this point in the history
…riptors on windows
  • Loading branch information
xrmx committed Nov 4, 2024
1 parent 07c3324 commit 6fd85dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ def _instrument(self, **kwargs):
unit="switches",
)

if "process.open_file_descriptor.count" in self._config:
if (
sys.platform != "win32"
and "process.open_file_descriptor.count" in self._config
):
self._meter.create_observable_up_down_counter(
name="process.open_file_descriptor.count",
callbacks=[self._get_open_file_descriptors],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# pylint: disable=protected-access

import sys
from collections import namedtuple
from platform import python_implementation
from unittest import mock, skipIf
Expand Down Expand Up @@ -118,15 +119,16 @@ def test_system_metrics_instrument(self):
f"process.runtime.{self.implementation}.thread_count",
f"process.runtime.{self.implementation}.context_switches",
f"process.runtime.{self.implementation}.cpu.utilization",
"process.open_file_descriptor.count",
]

on_windows = sys.platform == "win32"
if self.implementation == "pypy":
self.assertEqual(len(metric_names), 21)
self.assertEqual(len(metric_names), 21 if on_windows else 20)
else:
self.assertEqual(len(metric_names), 22)
self.assertEqual(len(metric_names), 22 if on_windows else 21)
observer_names.append(
f"process.runtime.{self.implementation}.gc_count",
"process.open_file_descriptor.count",
)

for observer in metric_names:
Expand Down

0 comments on commit 6fd85dd

Please sign in to comment.