1. Add better_exceptions traceback to every error sent to Sentry.
2. Add real time CPU, MEMORY, DISK to every error sent to Sentry.
3. Discard the event if he meet certain criteria before sending it to Sentry.
4. Add additional info to every error sent to Sentry.
5. Add the recommended settings Sentry.
6. Making sure Sentry Init will happen only once.
import sentry_sdk
from sentry_starter_kit import SentryInit, SentryProjects
from sentry_starter_kit.consts import SentryConsts
from sentry_starter_kit.utils import set_tags
def main():
SentryInit(project_type=SentryProjects.TEST_1)
add_additional_info_to_sentry()
def add_additional_info_to_sentry() -> None:
set_tags({
SentryConsts.APPLICATION: 'my_application',
SentryConsts.LOGGER: 'my_logger'
})
sentry_sdk.set_user({
SentryConsts.USER_NAME: 'my_user_name',
})
sentry_sdk.set_context('MY Context', {
SentryConsts.COMPUTER_NAME: 'my_computer_name',
SentryConsts.HOST_IP: '192.168.1.1',
})