diff --git a/.github/workflows/generate_workflows.py b/.github/workflows/generate_workflows.py index bda8eee82..ce6b56abe 100644 --- a/.github/workflows/generate_workflows.py +++ b/.github/workflows/generate_workflows.py @@ -9,6 +9,8 @@ from generate_workflows_lib import ( tox_ini_path = Path(__file__).parent.parent.parent.joinpath("tox.ini") workflows_directory_path = Path(__file__).parent -generate_test_workflow(tox_ini_path, workflows_directory_path, "ubuntu-latest") +generate_test_workflow( + tox_ini_path, workflows_directory_path, "ubuntu-latest", "windows-latest" +) generate_lint_workflow(tox_ini_path, workflows_directory_path) generate_misc_workflow(tox_ini_path, workflows_directory_path) diff --git a/.github/workflows/generate_workflows_lib/src/generate_workflows_lib/__init__.py b/.github/workflows/generate_workflows_lib/src/generate_workflows_lib/__init__.py index 0308fbe5f..d0889abc4 100644 --- a/.github/workflows/generate_workflows_lib/src/generate_workflows_lib/__init__.py +++ b/.github/workflows/generate_workflows_lib/src/generate_workflows_lib/__init__.py @@ -55,6 +55,14 @@ def get_test_job_datas(tox_envs: list, operating_systems: list) -> list: "py312": "3.12", } + # we enable windows testing only for packages with windows specific code paths + per_tox_env_os_enablement = { + "windows-latest": { + "py312-test-instrumentation-botocore", + "py312-test-instrumentation-system-metrics", + }, + } + test_job_datas = [] for operating_system in operating_systems: @@ -71,6 +79,14 @@ def get_test_job_datas(tox_envs: list, operating_systems: list) -> list: ] tox_env = tox_test_env_match.string + # if we have an entry for the os add only jobs for tox env manually configured + packages_manually_enabled = per_tox_env_os_enablement.get( + operating_system + ) + if packages_manually_enabled: + if tox_env not in packages_manually_enabled: + continue + test_requirements = groups["test_requirements"] if test_requirements is None: diff --git a/.github/workflows/test_1.yml b/.github/workflows/test_1.yml index 30e02c563..2615280e4 100644 --- a/.github/workflows/test_1.yml +++ b/.github/workflows/test_1.yml @@ -3903,3 +3903,45 @@ jobs: - name: Run tests run: tox -e pypy3-test-processor-baggage -- -ra + + py312-test-instrumentation-botocore_windows-latest: + name: instrumentation-botocore 3.12 Windows + runs-on: windows-latest + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install tox + run: pip install tox + + - name: Configure git to support long filenames + run: git config --system core.longpaths true + + - name: Run tests + run: tox -e py312-test-instrumentation-botocore -- -ra + + py312-test-instrumentation-system-metrics_windows-latest: + name: instrumentation-system-metrics 3.12 Windows + runs-on: windows-latest + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install tox + run: pip install tox + + - name: Configure git to support long filenames + run: git config --system core.longpaths true + + - name: Run tests + run: tox -e py312-test-instrumentation-system-metrics -- -ra diff --git a/CHANGELOG.md b/CHANGELOG.md index 47191002d..04498c863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#2940](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2940)) - `opentelemetry-instrumentation-dbapi` sqlcommenter key values created from PostgreSQL, MySQL systems ([#2897](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2897)) +- `opentelemetry-instrumentation-system-metrics`: don't report open file descriptors on Windows + ([#2946](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2946)) ### Breaking changes diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py index 0953e65fb..4e1ee2a5d 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py @@ -397,7 +397,10 @@ class SystemMetricsInstrumentor(BaseInstrumentor): 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], diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py b/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py index bf3a5c6ee..83abcff4c 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py @@ -14,6 +14,7 @@ # pylint: disable=protected-access +import sys from collections import namedtuple from platform import python_implementation from unittest import mock, skipIf @@ -118,21 +119,30 @@ class TestSystemMetrics(TestBase): 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), 20 if on_windows else 21) else: - self.assertEqual(len(metric_names), 22) + self.assertEqual(len(metric_names), 21 if on_windows else 22) observer_names.append( f"process.runtime.{self.implementation}.gc_count", ) + if not on_windows: + observer_names.append( + "process.open_file_descriptor.count", + ) for observer in metric_names: self.assertIn(observer, observer_names) observer_names.remove(observer) + if on_windows: + self.assertNotIn( + "process.open_file_descriptor.count", observer_names + ) + def test_runtime_metrics_instrument(self): runtime_config = { "process.runtime.memory": ["rss", "vms"], @@ -844,6 +854,7 @@ class TestSystemMetrics(TestBase): f"process.runtime.{self.implementation}.cpu.utilization", expected ) + @skipIf(sys.platform == "win32", "No file descriptors on Windows") @mock.patch("psutil.Process.num_fds") def test_open_file_descriptor_count(self, mock_process_num_fds): mock_process_num_fds.configure_mock(**{"return_value": 3})