Skip to main content

Generate flamecharts and error graphs from python stacktraces

Project description

pystackflame

Generate flamecharts from Python stacktraces in logs

pystackflame is a command-line tool that parses Python logs for stack traces and turns them into flamecharts or weighed graphs for performance analysis, visualization, and debugging.


Features

  • Generate FlameGraph-compatible output
  • Pickle rustworkx-based graphs
  • Build weighted execution graphs from logs using rustworkx
  • Python 3.14+ support
  • Fast and lightweight CLI built with click
  • Developer-friendly with optional linting via ruff

Installation

We recommend using uv for fast dependency management:

uv sync -p 3.14
source .venv/bin/activate
pystackflame --help

Possible applications

Web Service Error Hotspots

Aggregate Python exceptions in your web server (e.g. Flask/FastAPI/Django) logs to quickly pinpoint which request-handling paths are failing most often without any need of restarting your application.

pystackflame flame /var/log/myapp/**/*.log -o web_errors.flame

Analysis of the historical data

Identify problematic places in the codebase that require the most attention.

pystackflame flame /var/log/all_logs_we_have/**/*.log -o errors.flame
./flamegraph.pl errors.flame > example.svg

Performance Regression Detection in CI

As part of your GitHub Actions or GitLab CI pipeline, run against the previous and current test logs to compare flamecharts—spot new slow-paths introduced by recent commits.

pystackflame flame old_tests.log -o baseline.flame
pystackflame flame new_tests.log -o current.flame

Visualize of diff the two SVGs or flame files to analyze regressions

Batch-Job Profiling

For long-running data-processing jobs (ETL, ML training, batch analytics), collect stacktraces on failure or periodically dump traces, then visualize the cumulative “hot” stacks to optimize slow stages.

pystackflame flame /logs/batch_job_*.log -o batch_profile.flame

Chaos-Engineering Fault Analysis

During fault-injection experiments, collect and compare flamecharts from healthy vs. faulted runs to understand how injected errors propagate.

pystackflame flame healthy.log -o healthy.flame
pystackflame flame chaos.log   -o chaos.flame

Advanced filtering

You can specify an option --trace-filter / -tf [PATH_PREFIX] to filter tracebacks to include only those paths that start with the given prefix and filter out the prefix out from the output. This is useful to restrict the flamechart or graph output to only relevant code paths with relevant names.

Additionally, you can specify multiple --exclude / -e [PATH_PREFIX] to exclude traces that starts from the given path prefix. Wildcard is supported as well.

Example

This command

pystackflame flame ~/test.log -tf '/opt/app/venv/lib64/python3.9/site-packages' 

Will produce the following flame data output

package;database;session.py;wrapper 2
package;apihelper.py;_make_request 2
package;apihelper.py;_check_result 2

And this command

pystackflame flame ~/test.log

Will give you this

/;opt;app;venv;lib64;python3.9;site-packages;package;database;session.py;wrapper 2
/;opt;app;venv;lib64;python3.9;site-packages;package;apihelper.py;_make_request 2
/;opt;app;venv;lib64;python3.9;site-packages;package;apihelper.py;_check_result 2

However, this command

pystackflame flame ~/test.log -tf '/opt/app/venv/lib64/python3.9/site-packages/package/apihelper.py' 

Will produce the following output

_make_request 2
_check_result 2

Usage

  • The filter must start with / (absolute path).
  • * can be used to match any folder (e.g., /var/log/app-logs/dates/*/application).
  • The filter must not end with /.

Result:

  • Only stack trace frames that match the filter will be added to the flamechart or graph.
  • Useful for narrowing down logs to project-specific code or a specific dependency tree.

Project details


Download files

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

Source Distribution

pystackflame-0.1.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

pystackflame-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file pystackflame-0.1.2.tar.gz.

File metadata

  • Download URL: pystackflame-0.1.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for pystackflame-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d061d4cf90bd96232a26975ad17592e9ecc8a28fd4997d88de90dce70aa0ba84
MD5 b9473b7187f2e7920e2da731ee88aebc
BLAKE2b-256 8613d12a0b257bc21e37d871aa4e400d044ef0eea593a2a9fa795fa7d945e30a

See more details on using hashes here.

File details

Details for the file pystackflame-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pystackflame-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 df42295e204fde5bd831cc41c019eb845732f81ff4d6d664bae2d7f7ea2df8d0
MD5 8ac81e8017eaae6b770573bf4ee37f5e
BLAKE2b-256 7d7bfcc5c4676f086d9e93b650e3a830575ac15a6030cc1167aac7662cc93e24

See more details on using hashes here.

Supported by

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