Navigation

DTrace and SystemTap are monitoring tools, each providing a way to inspect
what the processes on a computer system are doing. They both use
domain-specific languages allowing a user to write scripts which:

filter which processes are to be observed

gather data from the processes of interest

generate reports on the data

As of Python 3.6, CPython can be built with embedded “markers”, also
known as “probes”, that can be observed by a DTrace or SystemTap script,
making it easier to monitor what the CPython processes on a system are
doing.

CPython implementation detail: DTrace markers are implementation details of the CPython interpreter.
No guarantees are made about probe compatibility between versions of
CPython. DTrace scripts can stop working or work incorrectly without
warning when changing CPython versions.

The following example DTrace script can be used to show the call/return
hierarchy of a Python script, only tracing within the invocation of
a function called “start”. In other words, import-time function
invocations are not going to be listed:

This marker is the converse of function__entry(), and indicates that
execution of a Python function has ended (either via return, or via an
exception). It is only triggered for pure-Python (bytecode) functions.

This probe point is the converse of python.function.return(), and
indicates that execution of a Python function has ended (either via
return, or via an exception). It is only triggered for pure-python
(bytecode) functions.