ImportError: No module named sentry_sdk.integrations.wsgi

Viewed 405

I'm trying to upgrade the implementation of the old Sentry config to the new one for my wsgi configuration in my django project but I'm getting the following error.

ImportError: No module named sentry_sdk.integrations.wsgi

Earlier I had:

from raven.contrib.django.raven_compat.middleware.wsgi import Sentry

Now I have:

from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware

My sentry init is in settings.py file as:

sentry_sdk.init(
dsn=SENTRY_CONFIG.get("dsn", ""),
environment=SENTRY_CONFIG["environment"],
integrations=[
    DjangoIntegration(),
    CeleryIntegration(),
    sentry_logging,
],
attach_stacktrace=True,
send_default_pii=True,

)

Using: Django==4.0.3 sentry-sdk==1.5.8 python3.8

Any help is appreciated, thanks in advance!

1 Answers
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration

sentry_environment = env('SENTRY_ENVIRONMENT',default='local')

sentry_sdk.init(
    dsn=env('SENTRY_DSN'),
    integrations=[DjangoIntegration()],
    traces_sample_rate=1.0,

    # If you wish to associate users to errors (assuming you are using
    # django.contrib.auth) you may enable sending PII data.
    send_default_pii=True,
    environment=sentry_environment,
)
Related