Skip to main content

flask-pypprof

Blueprint for pprof profiling endpoints a la GO's that can be added to python Flask applications. flask-pypprof is a wrapper of pypprof and based on django-pypprof ideas.

Installation

pip install flask-pypprof

Usage

To add the pprof endpoints to your application, simply register the blueprint:

from flask_pypprof import get_pprof_blueprint

app.register_blueprint(get_pprof_blueprint())

Once registered, you will be able to access the following endpoints:

  • /debug/pprof/profile: will return a CPU profile
  • /debug/pprof/heap: will return a heap profile
  • /debug/pprof/thread: will return a thread profile
  • /debug/pprof/wall: will return a wall time profile(work in progress)

Configuration

You can configure the memory sample rate by setting the following environment variable:

  • MEMORY_PROFILER_ENABLED: enables the memory profiler (default: false)
  • MEMORY_SAMPLE_RATE: sets the memory profiling sample rate (default: 128 * 1024)
export MEMORY_PROFILER_ENABLED = false
export MEMORY_SAMPLE_RATE = 128 * 1024

Fetching profiles from your application

Fetch a 30 seconds CPU profile:

go tool pprof -http=:8088 http://localhost:8081/debug/pprof/profile?seconds=30

Fetch a heap profile:

go tool pprof -http=:8088 http://localhost:8081/debug/pprof/heap

image_2023-05-09_16-27-22

Compatibility

Python 3.8, 3.9, 3.10 and Flask >= 2.0.0 and Linux only.

Known issues

License

This code base is available under the Apache License, version 2.

Metadata

Release files for flask-pypprof 0.1.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-pypprof 0.1.18
File Size Uploaded
flask_pypprof-0.1.18.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flask-pypprof 0.1.18
File Interpreter ABI Platform
flask_pypprof-0.1.18-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / flask_pypprof-0.1.18.tar.gz

Download URL flask_pypprof-0.1.18.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4f7e01499ac4e10d4ccc60070d6d27ac0e613ce9fade9e141e162c381a0b6319
BLAKE2b-256 checksum
How to use checksums
b9383d05f3daaf2b16905877c955e5e6e3ebf67f534e178720e23fa61e57683a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.4 Linux/6.2.0-1015-azure

Release files / flask_pypprof-0.1.18-py3-none-any.whl

Download URL flask_pypprof-0.1.18-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2bf8af0675006127ff439acffda2c9b3ee444b672d21ceb44ed32ebdd8b9849
BLAKE2b-256 checksum
How to use checksums
f920f6f418cec270209cd6dea1f368b41f7b1c03798fe0e5eb913443c5d21a75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.4 Linux/6.2.0-1015-azure

Release history Release notifications | RSS feed

This release

0.1.18 This release

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release 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