Hi. I’m running openedx olive with tutor in production and with devstack on local. The more we use openedx, the more we feel the need of having something like Sentry. Adding Sentry to a Django project is fairly simple in general but in case of openedx I’m not sure what’s the best way of doing it. I couldn’t find any LOGGING thing in settings and I’m not sure where sentry configurations must be added. Is it LMS common, CMS common, both or none? I also tried adding it as a tutor plugin, openedx launches successfully but no error is logged in Sentry.
I’ve had some success integrating Sentry with edx-platform with the following plugin:
from tutor import hooks
hooks.Filters.ENV_PATCHES.add_items(
[
(
"openedx-common-settings",
"""import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
dsn="https://my-sentry-secret@mysentryhost.com/6",
integrations=[DjangoIntegration()]
)""",
),
("openedx-dockerfile-post-python-requirements", "RUN pip install sentry_sdk"),
]
)
Note that this was for an older release of Sentry. I’m not sure what’s the most appropriate way to integrate sentry with a Django app these days.
Thanks a lot! My only problem was with tutor syntax. I had added extra quotations, making the actual code commented. It would be great if tutor would update documentations especially the plugin section. Thanks again for your help.
My plugin is currently as follows. I also added Celery and Redis integrations as well since openedx uses them too. Same can be done for cms.
from tutor import hooks
hooks.Filters.ENV_PATCHES.add_items([
(
"openedx-lms-common-settings",
"""
import logging
from sentry_sdk import init
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.redis import RedisIntegration
init(dsn=<dsn-link>,
environment='production',
traces_sample_rate=1.0,
integrations=[
LoggingIntegration(logging.INFO, logging.ERROR),
DjangoIntegration(),
CeleryIntegration(),
RedisIntegration()
]
)
"""
),
])
For adding sentry-sdk
to requirements, I used the {tutor-dir}/env/build/openedx/requirements/private.txt
file but there are other possible ways as well.