-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ba6c6ba
Showing
18 changed files
with
1,447 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Editors | ||
.idea/ | ||
.tags | ||
*.iml | ||
*.iws | ||
*.sublime-project | ||
*.sublime-workspace | ||
*.sw? | ||
*~ | ||
**/.ropeproject | ||
.vscode | ||
Session.vim | ||
|
||
# IPython Notebook | ||
.ipynb_checkpoints | ||
|
||
# Mac | ||
.DS_Store | ||
Icon | ||
|
||
# Distribution / packaging | ||
.Python | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
*.egg | ||
*.egg-info/ | ||
eggs/ | ||
.eggs/ | ||
.mypy_cache/ | ||
dist/ | ||
build/ | ||
|
||
# Testing | ||
.coverage | ||
.cache | ||
coverage.xml | ||
*.cover | ||
junit_results.xml | ||
coverage/ | ||
.pytest_cache/ | ||
|
||
# Logging | ||
log/ | ||
|
||
# Environments | ||
.env | ||
.envrc | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License | ||
|
||
Copyright 2018 https://schireson.com | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include src/flask_flamegraph/flamegraph.pl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.PHONY: install-deps lint sync-deps build test clean version | ||
|
||
install-deps: | ||
pip install -r deps/dev-requirements.txt | ||
pip install -r deps/requirements.txt | ||
pip install --no-deps -e . | ||
|
||
lint: | ||
bin/lint | ||
|
||
sync-deps: | ||
pip install pip-tools | ||
|
||
pip-compile -o deps/dev-requirements.txt deps/dev-requirements.in | ||
pip-compile -o deps/requirements.txt deps/requirements.in | ||
|
||
build: | ||
python setup.py bdist_wheel | ||
|
||
test: | ||
pytest | ||
|
||
clean: | ||
rm -f junit_results.xml .coverage | ||
rm -rf build dist coverage .mypy_cache .eggs | ||
|
||
version: | ||
python setup.py -V |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 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](images/example.png) | ||
|
||
## 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](https://github.com/quantus/flask-debugtoolbar-flamegraph), | ||
but with inspiration from [sqltap](https://github.com/inconshreveable/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](https://github.com/brendangregg/FlameGraph) | ||
project iteself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash -u | ||
|
||
echo "testing isort" | ||
isort --recursive --diff --quiet --check src tests || exit 1 | ||
|
||
echo "testing flake8" | ||
flake8 --config ../../.flake8.ini src tests || exit 1 | ||
|
||
echo "testing pydocstyle" | ||
pydocstyle || exit 1 | ||
|
||
echo "testing mypy" | ||
mypy --config-file ../../.mypy.ini src tests || exit 1 | ||
|
||
echo "testing bandit" | ||
bandit -r src || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
bandit==1.4.0 | ||
coverage==4.5 | ||
flake8==3.5.0 | ||
flask==0.12.2 | ||
isort==4.3.3 | ||
mypy==0.570 | ||
pydocstyle==2.1.1 | ||
pytest-cov==2.5.1 | ||
pytest==3.4.0 | ||
wheel==0.30.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# This file is autogenerated by pip-compile | ||
# To update, run: | ||
# | ||
# pip-compile --output-file deps/dev-requirements.txt deps/dev-requirements.in | ||
# | ||
attrs==18.1.0 # via pytest | ||
bandit==1.4.0 | ||
click==6.7 # via flask | ||
coverage==4.5 | ||
flake8==3.5.0 | ||
flask==0.12.2 | ||
gitdb2==2.0.3 # via gitpython | ||
gitpython==2.1.9 # via bandit | ||
isort==4.3.3 | ||
itsdangerous==0.24 # via flask | ||
jinja2==2.10 # via flask | ||
markupsafe==1.0 # via jinja2 | ||
mccabe==0.6.1 # via flake8 | ||
mypy==0.570 | ||
pbr==4.0.2 # via stevedore | ||
pluggy==0.6.0 # via pytest | ||
py==1.5.3 # via pytest | ||
pycodestyle==2.3.1 # via flake8 | ||
pydocstyle==2.1.1 | ||
pyflakes==1.6.0 # via flake8 | ||
pytest-cov==2.5.1 | ||
pytest==3.4.0 | ||
pyyaml==3.12 # via bandit | ||
six==1.11.0 # via bandit, pydocstyle, pytest, stevedore | ||
smmap2==2.0.3 # via gitdb2 | ||
snowballstemmer==1.2.1 # via pydocstyle | ||
stevedore==1.28.0 # via bandit | ||
typed-ast==1.1.0 # via mypy | ||
werkzeug==0.14.1 # via flask | ||
wheel==0.30.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# | ||
# This file is autogenerated by pip-compile | ||
# To update, run: | ||
# | ||
# pip-compile --output-file deps/requirements-py2.txt deps/requirements.in | ||
# | ||
asn1crypto==0.24.0 # via cryptography | ||
attrs==17.4.0 | ||
aws-encryption-sdk==1.3.4 | ||
boto3==1.5.26 | ||
botocore==1.8.50 # via boto3, s3transfer | ||
certifi==2018.4.16 # via requests | ||
cffi==1.11.5 # via cryptography | ||
chardet==3.0.4 # via requests | ||
contextlib2==0.5.5 # via raven | ||
cryptography==2.2.2 # via aws-encryption-sdk | ||
docutils==0.14 # via botocore | ||
ecdsa==0.13 # via python-jose | ||
enum34==1.1.6 # via cryptography | ||
functools32==3.2.3.post2 # via jsonschema | ||
future==0.16.0 # via python-jose | ||
futures==3.2.0 # via s3transfer | ||
idna==2.6 # via cryptography, requests | ||
ipaddress==1.0.22 # via cryptography | ||
jmespath==0.9.3 # via boto3, botocore | ||
jsonschema==2.6.0 | ||
pendulum==1.4.4 | ||
pika==0.11.2 | ||
pycparser==2.18 # via cffi | ||
pycryptodome==3.6.1 # via python-jose | ||
python-dateutil==2.7.2 # via botocore, pendulum | ||
python-jose==2.0.2 | ||
pytz==2018.4 # via tzlocal | ||
pytzdata==2018.4 # via pendulum | ||
pyyaml==3.12 | ||
raven==6.5.0 | ||
requests==2.18.4 | ||
s3transfer==0.1.13 # via boto3 | ||
six==1.11.0 # via cryptography, python-dateutil, python-jose | ||
tzlocal==1.5.1 # via pendulum | ||
urllib3==1.22 # via requests | ||
wrapt==1.10.11 # via aws-encryption-sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
werkzeug~=0.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# | ||
# This file is autogenerated by pip-compile | ||
# To update, run: | ||
# | ||
# pip-compile --output-file deps/requirements.txt deps/requirements.in | ||
# | ||
werkzeug==0.14.1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from setuptools import find_packages, setup | ||
|
||
|
||
def parse_requirements(filename): | ||
with open(filename) as f: | ||
lineiter = (line.strip() for line in f) | ||
return [ | ||
line.replace(' \\', '').strip() | ||
for line in lineiter | ||
if ( | ||
line and | ||
not line.startswith("#") and | ||
not line.startswith("-e") and | ||
not line.startswith("--hash") | ||
) | ||
] | ||
|
||
|
||
INSTALL_REQUIREMENTS = parse_requirements('deps/requirements.in') | ||
|
||
SETUP_REQUIREMENTS = [ | ||
'pytest-runner', | ||
] | ||
|
||
|
||
setup( | ||
name='flask_flamegraph', | ||
url='https://github.com/schireson/flask-flamegraph', | ||
author='Schireson', | ||
author_email='[email protected]', | ||
version='0.0.1', | ||
classifiers=[ | ||
'Intended Audience :: Developers', | ||
'Programming Language :: Python :: 3.6', | ||
'Schireson Proprietary', | ||
], | ||
packages=find_packages(where='src', exclude=['tests']), | ||
package_dir={'': 'src'}, | ||
include_package_data=True, | ||
install_requires=INSTALL_REQUIREMENTS, | ||
setup_requires=SETUP_REQUIREMENTS, | ||
test_suite='tests', | ||
zip_safe=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from flask_flamegraph.wsgi import FlaskFlamegraph # noqa |
Oops, something went wrong.