Skip to content

Make NBResuse more flexible. #35

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

Merged
merged 3 commits into from
Apr 18, 2020
Merged

Make NBResuse more flexible. #35

merged 3 commits into from
Apr 18, 2020

Conversation

krinsman
Copy link
Contributor

First change is to make CPU limit also callable, and thus have almost identical patterns for memory and CPU metrics. Next step is to abstract and generalize those patterns, to allow for potentially arbitrary psutil metrics to be tracked. Third step is to begin to allow the metrics which are tracked to be controlled via the configurations/settings file.

Using these it should soon be possible to track network i/o with NBResuse, compare the psutil documentation.

For system-wide metrics, psutil offers the categories of:

  • CPU metrics
  • Memory metrics
  • Disk metrics
  • Network metrics
  • Sensor metrics
  • Boot time and users (not sure if want/need to include that via NBResuse, but we maybe could)

For process-specific metrics, psutil offers the categories of:

  • I/O counters
  • File descriptors (Unix)
  • handles (Windows)
  • threads
  • CPU (cpu_times, cpu_percent
  • Memory (memory_info, memory_full_info, memory_percent)

By limiting the scope of what NBResuse attempts to support only to metrics which are (1) cross-platform, and which (2) correspond to either a numerical return value or a numerical attribute of a named tuple return value, this might be feasible+maintainable.

…ghly extensible configuration capapble of using (almost) all psutil metrics.
…e with previous versions. However this seems to now be sufficiently abstract as to be at the cusp of rapid 'expandability' in terms of its features. The next step will be to automatically make as many prometheus Gauge's as needed to measure every specificied metric, i.e. without defining them all manually. setattr will be useful for this I believe.
@krinsman krinsman merged commit e44f2a3 into master Apr 18, 2020
@krinsman krinsman deleted the callable_cpu_limit branch April 18, 2020 03:11

MAX_CPU_USAGE = Gauge("max_cpu_usage", "counter for max cpu usage", [])
self.TOTAL_MEMORY_USAGE = Gauge(
Copy link
Contributor Author

@krinsman krinsman Apr 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would eventually like to replace these manually specified attributes and attribute names (one for each gauge) with automatically generated ones based on the user's specified configuration, using for loops similar to what was done here in NBViewer.

https://github.com/jupyter/nbviewer/blob/dda310767d9c209a985abadddfad389c404d12be/nbviewer/providers/base.py#L63

I think computing the value for the third argument of setattr will be more complicated than just getting an entry from a dictionary based on its key, but it should still be regular enough that it could be encompassed in a function, allowing the calls to setattr to still be legible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant