Skip to content

Commit 205db0c

Browse files
committed
Remove system.swap.* metrics if /proc/vmstat is not available
1 parent d8facf6 commit 205db0c

File tree

1 file changed

+7
-0
lines changed
  • instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@
153153
# see https://github.com/giampaolo/psutil/issues/1219
154154
_DEFAULT_CONFIG.pop("system.network.connections")
155155

156+
if psutil.LINUX:
157+
# see https://github.com/open-telemetry/opentelemetry-python-contrib/issues/3740
158+
vmstat = os.path.join(psutil.PROCFS_PATH, "vmstat")
159+
if not os.path.exists(vmstat):
160+
_DEFAULT_CONFIG.pop("system.swap.usage")
161+
_DEFAULT_CONFIG.pop("system.swap.utilization")
162+
156163

157164
class SystemMetricsInstrumentor(BaseInstrumentor):
158165
def __init__(

0 commit comments

Comments
 (0)