Skip to main content

A simple profiler for flask applications.

Project description

Flask-Perf

PyPI version Build Status

A Flask extension for code and database query profiling.

This profiler is an implementation of the methods described in this post post however the extension allows you to also control profiling through the application config.

Installation

$ pip install flask_perf

Example

from flask import Flask, jsonify
from flask_perf import Profiler

app = Flask(__name__)
app.config["PROFILER_ENABLED"] = True
profiler = Profiler(app) # or profiler.init_app(app)

@app.route("/")
def index():
    return jsonfiy({
        "message": "Hello World!"
    })

Configuration

Config Name Description default
PROFILER_ENABLED Enable the profiler. False
PROFILER_RESTRICTIONS List of profiler restrictions, described in depth in the Official Python Docs []
PROFILER_SQLALCHEMY_ENABLED Enable SQLAlchemy query logging. Note: This option requires that the flask_sqlalchemy package is installed and the SQLALCHEMY_RECORD_QUERIES config option is set to True. False
PROFILER_SQLALCHEMY_THRESHOLD Minimum query duration in seconds to log. 0
PROFILER_SQLALCHEMY_FORMAT Logged SQLAlchemy query format. "statement: {query}\nparameters: {parameters}\nduration: {duration}s\ncontext: {context}\n"

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

Flask-Perf-0.1.4.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

Flask_Perf-0.1.4-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

Supported by

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