<div align="center">
<img src="/assets/logo/beetrace.png" width=500px />
<h2>Trace your python process line by line with low overhead!</h2>
</div>
_beatrace_ allows you to trace a Python process line by line or the functions' entries
and returns. It uses USDT(User Statically-Defined Tracing) probes with
[bpftrace](https://github.com/iovisor/bpftrace/).
## Dependencies
- This package is only available for Linux and requires bpftrace. You can look at the
bpftrace installation
[here](https://github.com/iovisor/bpftrace/blob/master/INSTALL.md).
- CPython must be
[configured with the --with-dtrace option](https://docs.python.org/3/using/configure.html#cmdoption-with-dtrace).
## Installation
```bash
pip install beetrace
```
## Usage & Example
To trace the Python process, use the -p parameter to pass the pid value.
```bash
beetrace -p {pid of process}
```
Let's take a look at the quick example.
---
```bash
$ cat -n example.py
1 import os
2 from time import sleep
3
4
5 def c():
6 x = 1
7
8 def b():
9 y = 2
10 c()
11
12
13 def a():
14 z = 1
15 b()
16
17
18 while True:
19 print(f"PID of program: {os.getpid()}")
20 sleep(1)
21 print("Sleep 1 second")
22 a()
```
Output:
```bash
PID of program: 17988
Sleep 1 second
PID of program: 17988
Sleep 1 second
PID of program: 17988
Sleep 1 second
PID of program: 17988
...
...
...
```
```bash
$ beetrace -p 17988
___ ____ ____ ___ ____ ____ ____ ____
|__] |___ |___ | |__/ |__| | |___
|__] |___ |___ | | \ | | |___ |___
PID: 17988 | Tracing from: python3 example.py
Press Control-C to quit.
Path File:Line Function
/tmp example.py:18 <module>
/tmp example.py:19 <module>
/tmp example.py:20 <module>
/tmp example.py:21 <module>
/tmp example.py:22 <module>
/tmp example.py:14 a
/tmp example.py:15 a
/tmp example.py:9 b
/tmp example.py:10 b
/tmp example.py:6 c
/tmp example.py:18 <module>
/tmp example.py:19 <module>
/tmp example.py:20 <module>
/tmp example.py:21 <module>
/tmp example.py:22 <module>
/tmp example.py:14 a
/tmp example.py:15 a
/tmp example.py:9 b
/tmp example.py:10 b
/tmp example.py:6 c
/tmp example.py:18 <module>
/tmp example.py:19 <module>
/tmp example.py:20 <module>
... ... ...
... ... ...
... ... ...
... ... ...
```
Raw data
{
"_id": null,
"home_page": "https://github.com/furkanonder/beetrace/",
"name": "beetrace",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "tracer",
"author": "Furkan Onder",
"author_email": "furkanonder@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/38/bd/8830685b7ae4c7576ccdf011c7b87d6926d542ef01dde2d006d1d198c294/beetrace-0.1.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <img src=\"/assets/logo/beetrace.png\" width=500px />\n <h2>Trace your python process line by line with low overhead!</h2>\n</div>\n\n_beatrace_ allows you to trace a Python process line by line or the functions' entries\nand returns. It uses USDT(User Statically-Defined Tracing) probes with\n[bpftrace](https://github.com/iovisor/bpftrace/).\n\n## Dependencies\n\n- This package is only available for Linux and requires bpftrace. You can look at the\n bpftrace installation\n [here](https://github.com/iovisor/bpftrace/blob/master/INSTALL.md).\n\n- CPython must be\n [configured with the --with-dtrace option](https://docs.python.org/3/using/configure.html#cmdoption-with-dtrace).\n\n## Installation\n\n```bash\npip install beetrace\n```\n\n## Usage & Example\n\nTo trace the Python process, use the -p parameter to pass the pid value.\n\n```bash\nbeetrace -p {pid of process}\n```\n\nLet's take a look at the quick example.\n\n---\n\n```bash\n$ cat -n example.py\n1 import os\n2 from time import sleep\n3\n4\n5 def c():\n6 x = 1\n7\n8 def b():\n9 y = 2\n10 c()\n11\n12\n13 def a():\n14 z = 1\n15 b()\n16\n17\n18 while True:\n19 print(f\"PID of program: {os.getpid()}\")\n20 sleep(1)\n21 print(\"Sleep 1 second\")\n22 a()\n```\n\nOutput:\n\n```bash\nPID of program: 17988\nSleep 1 second\nPID of program: 17988\nSleep 1 second\nPID of program: 17988\nSleep 1 second\nPID of program: 17988\n...\n...\n...\n```\n\n```bash\n$ beetrace -p 17988\n___ ____ ____ ___ ____ ____ ____ ____\n|__] |___ |___ | |__/ |__| | |___\n|__] |___ |___ | | \\ | | |___ |___\n\nPID: 17988 | Tracing from: python3 example.py\n\nPress Control-C to quit.\n\nPath File:Line Function\n/tmp example.py:18 <module>\n/tmp example.py:19 <module>\n/tmp example.py:20 <module>\n/tmp example.py:21 <module>\n/tmp example.py:22 <module>\n/tmp example.py:14 a\n/tmp example.py:15 a\n/tmp example.py:9 b\n/tmp example.py:10 b\n/tmp example.py:6 c\n/tmp example.py:18 <module>\n/tmp example.py:19 <module>\n/tmp example.py:20 <module>\n/tmp example.py:21 <module>\n/tmp example.py:22 <module>\n/tmp example.py:14 a\n/tmp example.py:15 a\n/tmp example.py:9 b\n/tmp example.py:10 b\n/tmp example.py:6 c\n/tmp example.py:18 <module>\n/tmp example.py:19 <module>\n/tmp example.py:20 <module>\n... ... ...\n... ... ...\n... ... ...\n... ... ...\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Trace your python process line by line with low overhead!",
"version": "0.1.0",
"split_keywords": [
"tracer"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8616e19159c8b67d3ddc5589c752eab85c7a4647c5afacbf7759d78fa8f8ea11",
"md5": "acd6ca64f340c73a8ca926df8b8321e1",
"sha256": "422f254d933f924ad48b88030d283d6a40df52eff445ff36d3fe5ed28bfde966"
},
"downloads": -1,
"filename": "beetrace-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "acd6ca64f340c73a8ca926df8b8321e1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5584,
"upload_time": "2023-01-14T00:03:38",
"upload_time_iso_8601": "2023-01-14T00:03:38.750296Z",
"url": "https://files.pythonhosted.org/packages/86/16/e19159c8b67d3ddc5589c752eab85c7a4647c5afacbf7759d78fa8f8ea11/beetrace-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "38bd8830685b7ae4c7576ccdf011c7b87d6926d542ef01dde2d006d1d198c294",
"md5": "70c392b4641b6fd9b61cae7121578280",
"sha256": "cc31629d624c6916779cc3518e400e23d179b5e3cf0b67f205b712c521e46ddd"
},
"downloads": -1,
"filename": "beetrace-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "70c392b4641b6fd9b61cae7121578280",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 5238,
"upload_time": "2023-01-14T00:03:40",
"upload_time_iso_8601": "2023-01-14T00:03:40.988153Z",
"url": "https://files.pythonhosted.org/packages/38/bd/8830685b7ae4c7576ccdf011c7b87d6926d542ef01dde2d006d1d198c294/beetrace-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-14 00:03:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "furkanonder",
"github_project": "beetrace",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "beetrace"
}