Skip to content

Commit

Permalink
Fixed pre-commit check fail
Browse files Browse the repository at this point in the history
  • Loading branch information
sudip-khanal committed Feb 7, 2025
1 parent 728ad76 commit 7256744
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
12 changes: 4 additions & 8 deletions main/sentry.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
from enum import Enum
import sentry_sdk

import sentry_sdk
from celery.exceptions import Retry as CeleryRetry
from django.core.exceptions import PermissionDenied

from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.redis import RedisIntegration
from sentry_sdk.integrations.logging import ignore_logger
from sentry_sdk.integrations.redis import RedisIntegration

IGNORED_ERRORS = [
PermissionDenied,
CeleryRetry,
]
IGNORED_LOGGERS = [
"django.core.exceptions.ObjectDoesNotExist",

]

for _logger in IGNORED_LOGGERS:
Expand All @@ -41,12 +39,10 @@ def init_sentry(app_type, tags={}, **config):

class SentryTag:
class Tag(str, Enum):
_BASE = 'ai-chatbot.'
FEED = _BASE + 'feed'
_BASE = "ai-chatbot."
FEED = _BASE + "feed"

@staticmethod
def set_tags(kwargs: dict[Tag, int | str]):
for key, value in kwargs.items():
sentry_sdk.set_tag(key.value, value)


20 changes: 10 additions & 10 deletions main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

import os
from pathlib import Path
from main import sentry

import environ

from main import sentry

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

Expand All @@ -29,7 +30,6 @@
APP_ENVIRONMENT=str,
APP_DOMAIN=str,
DJANGO_APP_TYPE=str, # web/worker/hook

# Storage
DJANGO_STATIC_ROOT=(str, os.path.join(BASE_DIR, "assets/static")), # Where to store
DJANGO_MEDIA_ROOT=(str, os.path.join(BASE_DIR, "assets/media")), # Where to store
Expand Down Expand Up @@ -237,19 +237,19 @@


# Sentry Config
SENTRY_DSN = env('SENTRY_DSN')
SENTRY_DSN = env("SENTRY_DSN")
SENTRY_ENABLED = False

if SENTRY_DSN:
SENTRY_ENABLED = True
SENTRY_CONFIG = {
'app_type':env('DJANGO_APP_TYPE'),
'dsn': SENTRY_DSN,
'send_default_pii': True,
'traces_sample_rate': env('SENTRY_TRACES_SAMPLE_RATE'),
'profiles_sample_rate': env('SENTRY_PROFILE_SAMPLE_RATE'),
'tags': {
'site': ','.join(set(ALLOWED_HOSTS)),
"app_type": env("DJANGO_APP_TYPE"),
"dsn": SENTRY_DSN,
"send_default_pii": True,
"traces_sample_rate": env("SENTRY_TRACES_SAMPLE_RATE"),
"profiles_sample_rate": env("SENTRY_PROFILE_SAMPLE_RATE"),
"tags": {
"site": ",".join(set(ALLOWED_HOSTS)),
},
}
sentry.init_sentry(**SENTRY_CONFIG)
Expand Down

0 comments on commit 7256744

Please sign in to comment.