Skip to main content

Trace your python process line by line with low overhead!

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.

Dependencies

Installation

pip install beetrace

Usage & Example

To trace the Python process, use the -p parameter to pass the pid value.

beetrace -p {pid of process}

Let's take a look at the quick example.


$ 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:

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
...
...
...
$ 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>
...                                    ...                                                ...
...                                    ...                                                ...
...                                    ...                                                ...
...                                    ...                                                ...

Download files

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

Source Distribution

beetrace-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

beetrace-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file beetrace-0.1.0.tar.gz.

File metadata

  • Download URL: beetrace-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for beetrace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc31629d624c6916779cc3518e400e23d179b5e3cf0b67f205b712c521e46ddd
MD5 70c392b4641b6fd9b61cae7121578280
BLAKE2b-256 38bd8830685b7ae4c7576ccdf011c7b87d6926d542ef01dde2d006d1d198c294

See more details on using hashes here.

File details

Details for the file beetrace-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: beetrace-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for beetrace-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 422f254d933f924ad48b88030d283d6a40df52eff445ff36d3fe5ed28bfde966
MD5 acd6ca64f340c73a8ca926df8b8321e1
BLAKE2b-256 8616e19159c8b67d3ddc5589c752eab85c7a4647c5afacbf7759d78fa8f8ea11

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page