- 
                Notifications
    
You must be signed in to change notification settings  - Fork 805
 
          Remove sin & sout states from system.swap.* if they can not be computed
          #3741
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| 
           Spending some more time with the code, I came to the realisation I over-compensated with the metric removals. The error message states that   | 
    
64a6eb0    to
    82bf62b      
    Compare
  
    system.swap.* metrics if they can not be computedsin & sout states from system.swap.* if they can not be computed
      | 
               | 
          ||
| @staticmethod | ||
| @contextmanager | ||
| def _suppress_psutil_swap_warnings(): | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate in which cases we are going to need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
psutil.swap_memory will always produce a warning when invoked from gauge callbacks in conditions #3740 describes (in spite of the states specified in the config). As a result, the output stream will repeatedly contain:
/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()
On each callback. What I tried to do here was silence this particular warning and only log a warning message to the user once (when the instrumentor is initialized).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so you are removing sin and sout from the config to not report them but psutil will get a warning because it tries to read them anyway.
Description
Changes:
SystemMetricsInstrumentor.system.network.connections, then the metric will be removed and a warning is logged.system.swap.usageorsystem.swap.utilization, thesinandsoutstates will be removed from both metrics if/proc/vmstatis not found, and a warning is logged.RuntimeWarningemitted bypsutilis (narrowly) suppressed wheneverpsutil.swap_memoryis called in gauge callbacks.Fixes #3740
Type of change
Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Added a dedicated test for this functionality:
Ran it against several Python versions as follows:
Note that it's set to only run on Linux.
Does This PR Require a Core Repo Change?
No.
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.