Skip to main content

cpu and memory tracing for process trees

Project description

Latest Version Python Support

Metrace - cpu/memory tracing for process trees

Metrace makes it easy to get a nice interactive html plot of the cpu/memory usage of a whole process tree.

Install

Metrace depends on Plotly and Psutil, both will be installed with metrace using pip:

$ pip install metrace

Client usage (optional)

Metrace lets you annotate specific parts of your code with scopes and these will become part of your final plot output and end up look like this:

Metrace gives you a context manager trace you can wrap code blocks with:

$ cat foobar.py

from metrace import trace

with trace('creating 1000 objects'):
    l = []
    for i in range(1000):
        l.append(object())

To collect these traces you run your script with metrace as usual:

$ metrace run python foobar.py

Commandline Usage

After installation you will have the metrace command available.

$ metrace run python main.py && metrace plot

It has two subcommands:

run

$ metrace run python foobar.py

Runs a process and collects cpu/memory metrics for both the process and its children seperately.

Metrace outputs the metrics in a json file in current working directory named like: metrace_1568385178098218.json with the number being milliseconds since epoch.

plot

$ metrace plot
# or
# to not open the html report automatically:
$ metrace plot --autoopen=no
# or
# to specify input/output files
$ metrace plot -i metrace_1568385178098218.json -o metrace_report.html

Plots cpu/memory usage for a given, or latest found, metrace json file.

Output is a html file where you can download the images, zoom in and hover to inspect the different traces.

Samples

Docs folder contains a sample of a metrace json file and a metrace html report

Attribution

plotly.min.js Licensed under MIT, has been included in this library here: metrace/plotly_latest.min.js

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metrace-1.0.1.tar.gz (966.5 kB view details)

Uploaded Source

File details

Details for the file metrace-1.0.1.tar.gz.

File metadata

  • Download URL: metrace-1.0.1.tar.gz
  • Upload date:
  • Size: 966.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

File hashes

Hashes for metrace-1.0.1.tar.gz
Algorithm Hash digest
SHA256 be9fe736163a695e5f1bd3fb4ee53a500b65ca427d75615d9c908b27ab7ca6bc
MD5 e9e4f102c15d1f984a2d395ec7b6739e
BLAKE2b-256 c0fca1c4b5ba8953e0230af9c093888fb3730ddf3bd97d63840b1cbf58caf8df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page