I use local Sentry in Docker (sentry, version 9.1.2
).
Package:
sentry-sdk[flask]==0.19.5
Source code of Flask application:
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
...
...
# Initialization
try:
sentry_sdk.init(
dsn=f"http://{SENTRY_KEY}@{SENTRY_HOST}/{PROJECT_ID}",
integrations=[FlaskIntegration()],
traces_sample_rate=1.0
)
except Exception as err:
logging.error(f'Can not connect to Sentry instance! {err}')
Test route:
@app.route('/test-sentry', methods=["GET"])
def trigger_error():
division_by_zero = 1 / 0
If I run app on localhost, like flask run app
and sent request localhost:5000/test-sentry
, it throws ZeroDivisionError: division by zero
exception and sent it to Sentry. The exception appears on the project page. Also the exception appears in the internal
project.
If I run app in Docker (image based on python:3.8-slim
and run with gunicorn==20.0.4
), it also throws a ZeroDivisionError: division by zero
exception and sends it to Sentry, but the exception does not appear on the project page. But the exception in the internal
project comes again.
Exception in internal
project: