Skip to content

Commit c813444

Browse files
mrugeshmasterxrmx
authored andcommitted
Divided proc_cpu_percent by 100 to get value between 0 and 1 (open-telemetry#2812)
1 parent 7cbbfa2 commit c813444

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020

2121
## Fixed
2222

23+
- `opentelemetry-instrumentation-system-metrics` fix `process.runtime.cpu.utilization` values to be shown in range of 0 to 1
24+
([2812](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2812))
2325
- `opentelemetry-instrumentation-fastapi` fix `fastapi` auto-instrumentation by removing `fastapi-slim` support, `fastapi-slim` itself is discontinued from maintainers
2426
([2783](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2783))
2527
- `opentelemetry-instrumentation-aws-lambda` Avoid exception when a handler is not present.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def _get_runtime_cpu_utilization(
729729
"""Observer callback for runtime CPU utilization"""
730730
proc_cpu_percent = self._proc.cpu_percent()
731731
yield Observation(
732-
proc_cpu_percent,
732+
proc_cpu_percent / 100,
733733
self._runtime_cpu_utilization_labels.copy(),
734734
)
735735

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ def test_runtime_thread_num(self, mock_process_thread_num):
839839
def test_runtime_cpu_percent(self, mock_process_cpu_percent):
840840
mock_process_cpu_percent.configure_mock(**{"return_value": 42})
841841

842-
expected = [_SystemMetricsResult({}, 42)]
842+
expected = [_SystemMetricsResult({}, 0.42)]
843843
self._test_metrics(
844844
f"process.runtime.{self.implementation}.cpu.utilization", expected
845845
)

0 commit comments

Comments
 (0)