mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 13:43:03 +08:00
avoid ZeroDevisionError exception when swap memory is 0 (#1345)
* avoid devidedByZero exception when sawp memory is 0 * lint Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
This commit is contained in:
@ -420,7 +420,9 @@ class SystemMetricsInstrumentor(BaseInstrumentor):
|
|||||||
if hasattr(system_swap, metric):
|
if hasattr(system_swap, metric):
|
||||||
self._system_swap_utilization_labels["state"] = metric
|
self._system_swap_utilization_labels["state"] = metric
|
||||||
yield Observation(
|
yield Observation(
|
||||||
getattr(system_swap, metric) / system_swap.total,
|
getattr(system_swap, metric) / system_swap.total
|
||||||
|
if system_swap.total
|
||||||
|
else 0,
|
||||||
self._system_swap_utilization_labels.copy(),
|
self._system_swap_utilization_labels.copy(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user