Skip to content

Commit

Permalink
sentry setup
Browse files Browse the repository at this point in the history
  • Loading branch information
swietlikm committed Dec 28, 2023
1 parent d9d19cf commit 1340874
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
29 changes: 27 additions & 2 deletions Dshop/Dshop/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
import json
import logging
import os
from pathlib import Path

import sentry_sdk
from decouple import config
import json
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -218,4 +223,24 @@
"VERSION": "1.0.0",
"SERVE_PERMISSIONS": ["rest_framework.permissions.IsAdminUser"],
"SERVE_INCLUDE_SCHEMA": False,
}
}

# Sentry
SENTRY_DSN = config(
"SENTRY_DSN",
default='https://545276765834eb4685af9a56c4fad326@o4506418469928960.ingest.sentry.io/4506418471632896'
)
SENTRY_LOG_LEVEL = config("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)

sentry_logging = LoggingIntegration(
level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
event_level=logging.ERROR, # Send errors as events
)

integrations = [sentry_logging, DjangoIntegration()]
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=integrations,
environment=config("SENTRY_ENVIRONMENT", default="local"),
traces_sample_rate=config("SENTRY_TRACES_SAMPLE_RATE", default=0.0),
)
47 changes: 46 additions & 1 deletion Dshop/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Dshop/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ django-tinymce = "^3.6.1"
dj-shop-cart = "^7.0.3"
djangorestframework="3.14.0"
drf-spectacular="0.26.5"
sentry-sdk = "^1.39.1"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
Expand Down

0 comments on commit 1340874

Please sign in to comment.