i am following the exact setup given in sentry docs, and sentry doesn’t send any events
i am debugging this issue for several hours now, google stackoverflow, nothing helped.
below are the details
sentry-sdk 2.17.0
django 3.2
djangorestframework 3.14.0
django settings.py
import sentry_sdk
sentry_sdk.init(
dsn="dsn",
)
if not DEBUG:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"verbose": {
"format": "{module}: {message} ({filename}:{lineno})",
"style": "{",
},
},
"handlers": {
"console": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "verbose",
},
"mail_admins": {
"level": "ERROR",
"class": "django.utils.log.AdminEmailHandler",
},
},
"loggers": {
"django": {
"handlers": ["console", "mail_admins"],
"level": "ERROR",
"propagate": True,
},
"saturn": {
"handlers": ["console", "mail_admins"],
"level": "INFO",
"propagate": False,
},
"integrations": {
"handlers": ["console", "mail_admins"],
"level": "INFO",
"propagate": False,
},
"auth": {
"handlers": ["console", "mail_admins"],
"level": "INFO",
"propagate": False,
},
},
}
else:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "verbose",
},
},
"formatters": {
"verbose": {
"format": "{module}: {message}",
"style": "{",
},
},
"loggers": {
"saturn": {
"handlers": ["console"],
"level": "INFO",
"propagate": True,
},
"integrations": {
"handlers": ["console"],
"level": "INFO",
"propagate": True,
},
"auth": {
"handlers": ["console"],
"level": "INFO",
"propagate": True,
},
},
}
REST_FRAMEWORK = {
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly"
],
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_simplejwt.authentication.JWTAuthentication",
"rest_framework.authentication.SessionAuthentication",
),
"DEFAULT_FILTER_BACKENDS": [
"django_filters.rest_framework.DjangoFilterBackend",
],
"EXCEPTION_HANDLER": "api.legacy.views.custom_exception_handler",
}
def custom_exception_handler(exc, context):
# Call REST framework's default exception handler first
response = exception_handler(exc, context)
capture_exception(exc)
request_ = context["request"]
try:
user_id = request_.user.id
except Exception as e:
user_id = "none"
try:
path = request_.path
except Exception as e:
path = "unknown"
app_version, platform = get_platform_version(request_)
if response is not None and exc is not None:
if exc.detail not in ["Authentication credentials were not provided."]:
logger.error("Server Error: %s", exc, exc_info=True)
EmailSender.notifyTechTeam(
exc,
f"REST API Server Error user_id = {user_id} path = {path} platform = {platform} app_version = {app_version} ",
)
return response
url.py
def trigger_error(request):
try:
division_by_zero = 1 / 0
except ZeroDivisionError as e:
capture_exception(e) # Send exception to Sentry
return HttpResponse("Exception captured and sent to Sentry!")
def send_test_message(request):
capture_message("Test message from Django!") # Send message to Sentry
return HttpResponse("Test message sent to Sentry!")
urlpatterns = [
path('admin/', admin.site.urls),
path('sentry-debug/', trigger_error),
path('sentry-message/', send_test_message),
]
init logs of sentry
[sentry] DEBUG: Setting up integrations (with default = True)
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.ariadne.AriadneIntegration: ariadne is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.arq.ArqIntegration: Arq is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.asyncpg.AsyncPGIntegration: asyncpg not installed.
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.boto3.Boto3Integration: botocore is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.bottle.BottleIntegration: Bottle not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.chalice.ChaliceIntegration: Chalice is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.clickhouse_driver.ClickhouseDriverIntegration: clickhouse-driver not installed.
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.cohere.CohereIntegration: Cohere not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.falcon.FalconIntegration: Falcon not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.fastapi.FastApiIntegration: Starlette is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.flask.FlaskIntegration: Flask is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.graphene.GrapheneIntegration: graphene is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.huey.HueyIntegration: Huey is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.pymongo.PyMongoIntegration: Pymongo not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.pyramid.PyramidIntegration: Pyramid not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.quart.QuartIntegration: Quart is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.rq.RqIntegration: RQ not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.sanic.SanicIntegration: Sanic not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.starlette.StarletteIntegration: Starlette is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.starlite.StarliteIntegration: Starlite is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.strawberry.StrawberryIntegration: strawberry-graphql is not installed
[sentry] DEBUG: Setting up previously not enabled integration argv
[sentry] DEBUG: Setting up previously not enabled integration atexit
[sentry] DEBUG: Setting up previously not enabled integration dedupe
[sentry] DEBUG: Setting up previously not enabled integration excepthook
[sentry] DEBUG: Setting up previously not enabled integration logging
[sentry] DEBUG: Setting up previously not enabled integration modules
[sentry] DEBUG: Setting up previously not enabled integration stdlib
[sentry] DEBUG: Setting up previously not enabled integration threading
[sentry] DEBUG: Setting up previously not enabled integration aiohttp
[sentry] DEBUG: Setting up previously not enabled integration anthropic
[sentry] DEBUG: Setting up previously not enabled integration celery
[sentry] DEBUG: Setting up previously not enabled integration django
[sentry] DEBUG: Setting up previously not enabled integration gql
[sentry] DEBUG: Setting up previously not enabled integration httpx
[sentry] DEBUG: Setting up previously not enabled integration huggingface_hub
[sentry] DEBUG: Setting up previously not enabled integration langchain
[sentry] DEBUG: Setting up previously not enabled integration loguru
[sentry] DEBUG: Setting up previously not enabled integration openai
[sentry] DEBUG: Setting up previously not enabled integration redis
[sentry] DEBUG: Setting up previously not enabled integration sqlalchemy
[sentry] DEBUG: Setting up previously not enabled integration tornado
[sentry] DEBUG: Enabling integration argv
[sentry] DEBUG: Enabling integration atexit
[sentry] DEBUG: Enabling integration dedupe
[sentry] DEBUG: Enabling integration excepthook
[sentry] DEBUG: Enabling integration logging
[sentry] DEBUG: Enabling integration modules
[sentry] DEBUG: Enabling integration stdlib
[sentry] DEBUG: Enabling integration threading
[sentry] DEBUG: Enabling integration aiohttp
[sentry] DEBUG: Enabling integration anthropic
[sentry] DEBUG: Enabling integration celery
[sentry] DEBUG: Enabling integration django
[sentry] DEBUG: Enabling integration gql
[sentry] DEBUG: Enabling integration httpx
[sentry] DEBUG: Enabling integration huggingface_hub
[sentry] DEBUG: Enabling integration langchain
[sentry] DEBUG: Enabling integration loguru
[sentry] DEBUG: Enabling integration openai
[sentry] DEBUG: Enabling integration redis
[sentry] DEBUG: Enabling integration sqlalchemy
[sentry] DEBUG: Enabling integration tornado
[sentry] DEBUG: Setting SDK name to 'sentry.python.django'
[sentry] DEBUG: [Profiling] Setting up continuous profiler in thread mode
[sentry] DEBUG: Setting up integrations (with default = False)
[sentry] DEBUG: Setting SDK name to 'sentry.python'
[sentry] DEBUG: [Profiling] Continuous Profiler is already setup