open-telemetry / open-telemetry/opentelemetry-python-contrib

Some `system.swap.*` metric states are not available in sandbox runtimes

Open
#3,740 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

Describe your environment

OS: Debian Bookworm Slim 12.11
Python version: 3.13.7
Package version: 1.36.0
Instrumentor version: 0.57b0

What happened?

I'm currently developing a FastAPI web application that I launch in Kubernetes pods. Given that they might require root access, I use the gVisor container runtime. I periodically get warnings in the console that metrics related to swap memory can't be computed, and are set to 0.

Steps to Reproduce
  • Launch a minikube local Kubernetes cluster with gvisor addon enabled.
  • Create a FastAPI server and instrument it with SystemMetricsInstrumentor.
  • Build an OCI-compliant image of this web service.
  • Create a pod from this image on the cluster, using gvisor as the runtimeClassName.
Expected Result

If the metrics can't be computed, then they shouldn't be included (this is already the case for some metrics). There should also be no errors in the console.

Actual Result

I periodically see the following warning in the console:

/home/app/.local/lib/python3.13/site-packages/psutil/__init__.py:2036: RuntimeWarning: 'sin' and 'sout' swap memory stats couldn't be determined and were set to 0 ([Errno 2] No such file or directory: '/proc/vmstat')
  return _psplatform.swap_memory()
Additional context

No response

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/init.py, especially the metric handling around lines 152–154 referenced in the issue. Reproduce the system metrics instrumentation in the described gVisor Kubernetes setup and verify that unavailable swap metrics are omitted without emitting warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, kubernetes, python
Domain
observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.