The Flask integration adds support for the Flask Web Framework.
sentry-sdkfrom PyPI with the
$ pip install --upgrade 'sentry-sdk[flask]==0.7.10'
To configure the SDK, initialize it with the integration before or after your app has been initialized:
import sentry_sdk from sentry_sdk.integrations.flask import FlaskIntegration sentry_sdk.init( dsn="___PUBLIC_DSN___", integrations=[FlaskIntegration()] ) app = Flask(__name__)
The Sentry Python SDK will install the Flask integration for all of your apps. It hooks into Flask’s signals, not anything on the app object.
All exceptions leading to an Internal Server Error are reported.
Request data is attached to all events: HTTP method, URL, headers, form data, JSON payloads. Sentry excludes raw bodies and multipart file uploads. Sentry also excludes personally identifiable information (such as user ids, usernames, cookies, authorization headers, IP addresses) unless you set
If you use
flask-loginand have set
send_default_pii=Truein your call to
init, user data is attached to the event. Apart from the user ID we will try to access the attributes
usernameon your user object to capture some more data.
app.loggeror any logger will create breadcrumbs when the Logging integration is enabled (done by default).
You can pass the following keyword arguments to
@app.route("/myurl/<foo>") def myendpoint(): return "ok"
In the above code, you would set the transaction to:
/myurl/if you set
transaction_style="url". This matches the behavior of the old Raven SDK.
myendpointif you set
The default is
You can use the user feedback feature with this integration. For more information see User Feedback.