Skip to main content

Panopticon

License: MIT Code style: black Build Status codecov Alpha

Panopticon is a debugger-powered tracer for Python code to quickly visualize and explore code execution. Traces generated are Catapult compatible — available at `chrome://tracing` if you're using Chrome.

Alpha: I'm still working on adding tests, polishing the api, and cleaning up the code in general. Expect the API to change drastically as it meanders towards v1. It should still be immediately useful as a debugging tool. Please report issues if you come across bugs!

Sample trace with async functions

Usage

You can read a more detailed guide with several examples of simple Python programs, different interfaces to visualize them and the corresponding traces at explog.in/panopticon.

Run a command directly

python3 -m panopticon -c "print('hello')" -o print_hello.trace

Run a file

python3 -m panopticon -o file.trace file.py 

In code

from panopticon import record_trace

with record_trace("print_hello.trace"):
    print("Hello")

Probe a specific function

It can be tricky to control how a program is executed: using the probe decorator allows instrumenting a specific function instead.

from panopticon.probe import probe
from panopticon.trace import StreamingTrace

@probe(trace=StreamingTrace(open("probe.trace", "w")))
def myfunction():
    ...

Asynchronous Functions

Python supports suspending and continuing execution of a frame through generators, coroutines and asynchronous generators. Panopticon creates "flow" events to connect a single frame executing through time, making it easier to visualize what's actually happening.

You can enable/disable connections for different types of functions by choosing to enable/disable flow events in Catpult (top-right).

Changelog

0.0.3

  • Added basic support for capturing arguments in traces
  • New utility to "flatten" complex or sparse traces for readability
  • Improved naming behavior when self is modified
  • Extremely basic support for async probes

0.0.2

  • Added a simplified record_trace API
  • Added support for @probe to instrument functions and classes

0.0.1

  • Initial version of Panopticon
  • CLI supports running commands and files for tracing

Download files

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

Source Distribution

panopticon-0.0.3.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

panopticon-0.0.3-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file panopticon-0.0.3.tar.gz.

File metadata

  • Download URL: panopticon-0.0.3.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for panopticon-0.0.3.tar.gz
Algorithm Hash digest
SHA256 4b242272b7c6d9a59dc7d6511849b7d7a7bdc1ae1376a97fd45650f9da4b57b4
MD5 d74effdb41566a513694774e0760754a
BLAKE2b-256 902811dec0c13f311bd2c2f48fec6a0bad68fc6cb7daee9309a6676de7643e29

See more details on using hashes here.

File details

Details for the file panopticon-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: panopticon-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for panopticon-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1433b8054422a82310939ec9e1e3a916fb7f146f7e9ca974a4d84ca18784392a
MD5 5d0e5775dafba1247364f6f7fbf14d7e
BLAKE2b-256 6606f8c3abc21c73a0d4477e5ff894ba98c67839caf65af4dfeeb2407ecd2fff

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.4

2 files

This release

0.0.3 This release

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page