yabirgb / flask-flamegraph

Automatically generate a flamegraph for the last executed request

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flask-flamegraph - a library for profiling flask request.

flask-flamegraph helps you quickly understand:

  • Where all the time is being spent in your endpoints
  • How deep your callstacks are
  • Where the lowest hanging fruit is for optimization

Example image

Quickstart Example

import flask
import flask_flamegraph

flask_flamegraph = flask_flamegraph.FlaskFlamegraph()

def create_app():
    app = flas.Flask(__name__)
    flask_flamegraph.init_app(app)
    return app

if __name__ == '__main__':
    app = create_app()
    app.run()

After this, hit any of your routes, and navigate to http://localhost:5000/__flame__

Testing

Run the tests:

pytest

Attributions

This plugin is largely based upon flask-debugtoolbar-flamegraph, but with inspiration from sqltap for adding a separate __flame__ endpoint to more naturally support json-only apis instead of template rendered pages.

Also, impossible to do without the flamegraph project iteself.

About

Automatically generate a flamegraph for the last executed request

License:MIT License


Languages

Language:Perl 85.8%Language:Python 12.0%Language:Makefile 1.3%Language:Shell 0.9%