Divided proc_cpu_percent by 100 to get value between 0 and 1 (#2812)

This commit is contained in:
Mrugesh Master
2024-08-21 15:24:46 -07:00
committed by GitHub
parent dda369b724
commit 1ad9d90308
3 changed files with 4 additions and 2 deletions

View File

@ -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.

View File

@ -729,7 +729,7 @@ class SystemMetricsInstrumentor(BaseInstrumentor):
"""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(),
)

View File

@ -839,7 +839,7 @@ class TestSystemMetrics(TestBase):
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
)