Skip to content

Commit

Permalink
Divided proc_cpu_percent by 100 to get value between 0 and 1 (#2812)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrugeshmaster authored Aug 21, 2024
1 parent dda369b commit 1ad9d90
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 1ad9d90

Please sign in to comment.