Skip to content

Commit 59fa602

Browse files
committed
added profiling env variable
1 parent fdad5a1 commit 59fa602

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

conditional/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import sentry_sdk
1414
from sentry_sdk.integrations.flask import FlaskIntegration
1515
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
16+
from werkzeug.middleware.profiler import ProfilerMiddleware
1617

1718
app = Flask(__name__)
1819
gzip = Gzip(app)
@@ -29,6 +30,12 @@
2930
db = SQLAlchemy(app)
3031
migrate = Migrate(app, db)
3132

33+
if app.config['PROFILING']:
34+
app.wsgi_app = ProfilerMiddleware(
35+
app.wsgi_app,
36+
restrictions=[30]
37+
)
38+
3239
# Sentry setup
3340
sentry_sdk.init(
3441
dsn=app.config['SENTRY_DSN'],

config.env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
IP = env.get("CONDITIONAL_IP", "0.0.0.0")
1616
PORT = env.get("CONDITIONAL_PORT", 6969)
1717
WEBHOOK_URL = env.get("CONDITIONAL_WEBHOOK_URL", "INSERT URL HERE")
18+
PROFILING = env.get("CONDITIONAL_PROFILING", "false").lower() == "true"
1819

1920
# DB Info
2021
SQLALCHEMY_DATABASE_URI = env.get("SQLALCHEMY_DATABASE_URI", "")

0 commit comments

Comments
 (0)