{"id":15521043,"url":"https://github.com/sloev/metrace","last_synced_at":"2025-04-23T04:32:21.171Z","repository":{"id":57441242,"uuid":"209016394","full_name":"sloev/metrace","owner":"sloev","description":"Metrace - cpu/memory tracing for process trees","archived":false,"fork":false,"pushed_at":"2020-09-02T21:39:24.000Z","size":1195,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-17T19:18:37.627Z","etag":null,"topics":["cpu","memory","metrics","monitor","python","trace","tracing","tracking"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/metrace/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sloev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-17T09:43:31.000Z","updated_at":"2024-11-28T16:34:29.000Z","dependencies_parsed_at":"2022-09-02T08:30:37.779Z","dependency_job_id":null,"html_url":"https://github.com/sloev/metrace","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloev%2Fmetrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloev%2Fmetrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloev%2Fmetrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloev%2Fmetrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sloev","download_url":"https://codeload.github.com/sloev/metrace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250371934,"owners_count":21419688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpu","memory","metrics","monitor","python","trace","tracing","tracking"],"created_at":"2024-10-02T10:31:55.930Z","updated_at":"2025-04-23T04:32:20.705Z","avatar_url":"https://github.com/sloev.png","language":"Python","funding_links":["https://www.buymeacoffee.com/sloev"],"categories":[],"sub_categories":[],"readme":"[![Latest Version](https://img.shields.io/pypi/v/metrace.svg)](https://pypi.python.org/pypi/metrace) [![Python Support](https://img.shields.io/pypi/pyversions/metrace.svg)](https://pypi.python.org/pypi/metrace)\n\n# Metrace - cpu/memory tracing for process trees\n\n\u003ca href=\"https://www.buymeacoffee.com/sloev\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-pink.png\" alt=\"Buy Me A Coffee\" height=\"51px\" width=\"217px\"\u003e\u003c/a\u003e\n\nMetrace makes it easy to get a nice interactive html plot of the cpu/memory usage of a whole process tree.\n\n\n\u003ckbd\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/sloev/metrace/master/docs/report.png\" width=\"550\"\u003e\n\u003c/kbd\u003e\n\n\n## Install\n\nMetrace depends on `Plotly` and `Psutil`, both will be installed with metrace using pip:\n\n```\n$ pip install metrace\n```\n\n## Client usage (optional)\n\nMetrace 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:\n\n\n\u003ckbd\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/sloev/metrace/master/docs/trace_annotation.png\" width=\"200\"\u003e\n\u003c/kbd\u003e\n\n\nMetrace gives you a context manager `trace` you can wrap code blocks with:\n\n```\n$ cat foobar.py\n\nfrom metrace import trace\n\nwith trace('creating 1000 objects'):\n    l = []\n    for i in range(1000):\n        l.append(object())\n```\n\nTo collect these traces you run your script with metrace as usual:\n\n```\n$ metrace run python foobar.py\n```\n\n## Commandline Usage\n\nAfter installation you will have the **metrace** command available.\n\n```\n$ metrace run python main.py \u0026\u0026 metrace plot\n```\n\n**It has two subcommands:**\n\n### run\n\n```\n$ metrace run python foobar.py\n```\n\nRuns a process and collects cpu/memory metrics for both the process and its children seperately.\n\nMetrace outputs the metrics in a json file in current working directory named like: `metrace_1568385178098218.json` with the number being milliseconds since epoch.\n\n### plot\n\n```\n$ metrace plot\n# or\n# to not open the html report automatically:\n$ metrace plot --autoopen=no\n# or\n# to specify input/output files\n$ metrace plot -i metrace_1568385178098218.json -o metrace_report.html\n```\n\nPlots cpu/memory usage for a given, or latest found, `metrace json file`.\n\nOutput is a html file where you can download the images, zoom in and hover to inspect the different traces.\n\n\n## Samples\n\nDocs folder contains a sample of a [metrace json file](./docs/metrace_1568385178098218.json) and a [metrace html report](./docs/metrace_report.html)\n\n# Attribution\n\n[plotly.min.js](https://github.com/plotly/plotly.js) Licensed under MIT, has been included in this library here: [metrace/plotly_latest.min.js](./metrace/plotly_latest.min.js)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsloev%2Fmetrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsloev%2Fmetrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsloev%2Fmetrace/lists"}