diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c31e01235..5abca8227a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Fixed +- `opentelemetry-instrumentation-system-metrics` fix `process.runtime.cpu.utilization` values to be shown in range of 0 to 1 + ([2812](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2812)) - `opentelemetry-instrumentation-fastapi` fix `fastapi` auto-instrumentation by removing `fastapi-slim` support, `fastapi-slim` itself is discontinued from maintainers ([2783](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2783)) - `opentelemetry-instrumentation-aws-lambda` Avoid exception when a handler is not present. 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 b7ffb25431..1b9a36c4cb 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 @@ -729,7 +729,7 @@ def _get_runtime_cpu_utilization( """Observer callback for runtime CPU utilization""" proc_cpu_percent = self._proc.cpu_percent() yield Observation( - proc_cpu_percent, + proc_cpu_percent / 100, self._runtime_cpu_utilization_labels.copy(), ) 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 1d6f08892e..bf3a5c6ee2 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py @@ -839,7 +839,7 @@ def test_runtime_thread_num(self, mock_process_thread_num): def test_runtime_cpu_percent(self, mock_process_cpu_percent): mock_process_cpu_percent.configure_mock(**{"return_value": 42}) - expected = [_SystemMetricsResult({}, 42)] + expected = [_SystemMetricsResult({}, 0.42)] self._test_metrics( f"process.runtime.{self.implementation}.cpu.utilization", expected )