Use sentry in all environments
It still is optional though
This commit is contained in:
parent
db5780f9f1
commit
fee2a4f17b
8 changed files with 77 additions and 13 deletions
|
|
@ -5,6 +5,6 @@ RUN pip install poetry
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY poetry.lock pyproject.toml /app/
|
COPY poetry.lock pyproject.toml /app/
|
||||||
|
|
||||||
RUN poetry config virtualenvs.create false && poetry install --no-interaction
|
RUN poetry config virtualenvs.create false && poetry install --no-interaction --extras sentry
|
||||||
|
|
||||||
COPY . /app/
|
COPY . /app/
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ python-tests:
|
||||||
- pip install poetry --quiet
|
- pip install poetry --quiet
|
||||||
- poetry config cache-dir .cache/poetry
|
- poetry config cache-dir .cache/poetry
|
||||||
- poetry config virtualenvs.in-project true
|
- poetry config virtualenvs.in-project true
|
||||||
- poetry install --no-interaction --quiet
|
- poetry install --no-interaction --quiet --extras sentry
|
||||||
script:
|
script:
|
||||||
- poetry run coverage run src/manage.py test newsreader
|
- poetry run coverage run src/manage.py test newsreader
|
||||||
- poetry run coverage report
|
- poetry run coverage report
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,13 @@ import os
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from .version import get_current_version
|
|
||||||
|
try:
|
||||||
|
from sentry_sdk.integrations.celery import CeleryIntegration
|
||||||
|
from sentry_sdk.integrations.django import DjangoIntegration
|
||||||
|
except ImportError:
|
||||||
|
CeleryIntegration = None
|
||||||
|
DjangoIntegration = None
|
||||||
|
|
||||||
|
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent
|
||||||
|
|
@ -199,7 +205,7 @@ STATICFILES_FINDERS = [
|
||||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
|
||||||
# Project settings
|
# Project settings
|
||||||
VERSION = get_current_version()
|
ENVIRONMENT = "development"
|
||||||
|
|
||||||
# Reddit integration
|
# Reddit integration
|
||||||
REDDIT_CLIENT_ID = "CLIENT_ID"
|
REDDIT_CLIENT_ID = "CLIENT_ID"
|
||||||
|
|
@ -246,3 +252,13 @@ CELERY_WORKER_HIJACK_ROOT_LOGGER = False
|
||||||
REGISTRATION_OPEN = True
|
REGISTRATION_OPEN = True
|
||||||
REGISTRATION_AUTO_LOGIN = True
|
REGISTRATION_AUTO_LOGIN = True
|
||||||
ACCOUNT_ACTIVATION_DAYS = 7
|
ACCOUNT_ACTIVATION_DAYS = 7
|
||||||
|
|
||||||
|
# Sentry
|
||||||
|
SENTRY_CONFIG = {
|
||||||
|
"dsn": os.environ.get("SENTRY_DSN"),
|
||||||
|
"send_default_pii": True,
|
||||||
|
"environment": ENVIRONMENT,
|
||||||
|
"integrations": [DjangoIntegration(), CeleryIntegration()]
|
||||||
|
if DjangoIntegration and CeleryIntegration
|
||||||
|
else [],
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from .base import * # isort:skip
|
from .base import * # isort:skip
|
||||||
|
from .version import get_current_version
|
||||||
|
|
||||||
|
|
||||||
SECRET_KEY = "mv4&5#+)-=abz3^&1r^nk_ca6y54--p(4n4cg%z*g&rb64j%wl"
|
SECRET_KEY = "mv4&5#+)-=abz3^&1r^nk_ca6y54--p(4n4cg%z*g&rb64j%wl"
|
||||||
|
|
@ -9,11 +10,21 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
|
||||||
INSTALLED_APPS += ["debug_toolbar", "django_extensions"]
|
INSTALLED_APPS += ["debug_toolbar", "django_extensions"]
|
||||||
|
|
||||||
|
# Project settings
|
||||||
|
VERSION = get_current_version()
|
||||||
|
|
||||||
# Third party settings
|
# Third party settings
|
||||||
AXES_FAILURE_LIMIT = 50
|
AXES_FAILURE_LIMIT = 50
|
||||||
AXES_COOLOFF_TIME = None
|
AXES_COOLOFF_TIME = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from .local import * # noqa
|
from .local import * # noqa
|
||||||
|
|
||||||
|
# Optionally use sentry integration
|
||||||
|
from sentry_sdk import init as sentry_init
|
||||||
|
|
||||||
|
SENTRY_CONFIG.update({"release": VERSION})
|
||||||
|
|
||||||
|
sentry_init(**SENTRY_CONFIG)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from .base import * # isort:skip
|
from .base import * # isort:skip
|
||||||
|
from .version import get_current_version
|
||||||
|
|
||||||
|
|
||||||
SECRET_KEY = "=q(ztyo)b6noom#a164g&s9vcj1aawa^g#ing_ir99=_zl4g&$"
|
SECRET_KEY = "=q(ztyo)b6noom#a164g&s9vcj1aawa^g#ing_ir99=_zl4g&$"
|
||||||
|
|
@ -30,6 +31,10 @@ CACHES = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Project settings
|
||||||
|
VERSION = get_current_version()
|
||||||
|
ENVIRONMENT = "docker"
|
||||||
|
|
||||||
# Third party settings
|
# Third party settings
|
||||||
# Axes
|
# Axes
|
||||||
AXES_FAILURE_LIMIT = 50
|
AXES_FAILURE_LIMIT = 50
|
||||||
|
|
@ -41,5 +46,12 @@ CELERY_BROKER_URL = "amqp://guest:guest@rabbitmq:5672//"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from .local import * # noqa
|
from .local import * # noqa
|
||||||
|
|
||||||
|
# Optionally use sentry integration
|
||||||
|
from sentry_sdk import init as sentry_init
|
||||||
|
|
||||||
|
SENTRY_CONFIG.update({"release": VERSION, "environment": ENVIRONMENT})
|
||||||
|
|
||||||
|
sentry_init(**SENTRY_CONFIG)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from .base import * # isort:skip
|
from .base import * # isort:skip
|
||||||
|
from .version import get_current_version
|
||||||
|
|
||||||
|
|
||||||
SECRET_KEY = "29%lkw+&n%^w4k#@_db2mo%*tc&xzb)x7xuq*(0$eucii%4r0c"
|
SECRET_KEY = "29%lkw+&n%^w4k#@_db2mo%*tc&xzb)x7xuq*(0$eucii%4r0c"
|
||||||
|
|
@ -17,3 +18,17 @@ CACHES = {
|
||||||
"LOCATION": "memcached:11211",
|
"LOCATION": "memcached:11211",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Project settings
|
||||||
|
VERSION = get_current_version()
|
||||||
|
ENVIRONMENT = "gitlab"
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Optionally use sentry integration
|
||||||
|
from sentry_sdk import init as sentry_init
|
||||||
|
|
||||||
|
SENTRY_CONFIG.update({"release": VERSION, "environment": ENVIRONMENT})
|
||||||
|
|
||||||
|
sentry_init(**SENTRY_CONFIG)
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ import os
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
from .version import get_current_version
|
||||||
|
|
||||||
|
|
||||||
from .base import * # isort:skip
|
from .base import * # isort:skip
|
||||||
|
|
||||||
|
|
@ -58,6 +60,10 @@ EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD", "")
|
||||||
EMAIL_USE_TLS = bool(os.environ.get("EMAIL_USE_TLS"))
|
EMAIL_USE_TLS = bool(os.environ.get("EMAIL_USE_TLS"))
|
||||||
EMAIL_USE_SSL = bool(os.environ.get("EMAIL_USE_SSL"))
|
EMAIL_USE_SSL = bool(os.environ.get("EMAIL_USE_SSL"))
|
||||||
|
|
||||||
|
# Project settings
|
||||||
|
VERSION = get_current_version(debug=False)
|
||||||
|
ENVIRONMENT = "production"
|
||||||
|
|
||||||
# Reddit integration
|
# Reddit integration
|
||||||
REDDIT_CLIENT_ID = os.environ.get("REDDIT_CLIENT_ID", "")
|
REDDIT_CLIENT_ID = os.environ.get("REDDIT_CLIENT_ID", "")
|
||||||
REDDIT_CLIENT_SECRET = os.environ.get("REDDIT_CLIENT_SECRET", "")
|
REDDIT_CLIENT_SECRET = os.environ.get("REDDIT_CLIENT_SECRET", "")
|
||||||
|
|
@ -76,14 +82,9 @@ REGISTRATION_OPEN = False
|
||||||
# Optionally use sentry integration
|
# Optionally use sentry integration
|
||||||
try:
|
try:
|
||||||
from sentry_sdk import init as sentry_init
|
from sentry_sdk import init as sentry_init
|
||||||
from sentry_sdk.integrations.celery import CeleryIntegration
|
|
||||||
from sentry_sdk.integrations.django import DjangoIntegration
|
|
||||||
|
|
||||||
sentry_init(
|
SENTRY_CONFIG.update({"release": VERSION, "environment": ENVIRONMENT})
|
||||||
dsn=os.environ.get("SENTRY_DSN"),
|
|
||||||
integrations=[DjangoIntegration(), CeleryIntegration()],
|
sentry_init(**SENTRY_CONFIG)
|
||||||
send_default_pii=False,
|
|
||||||
release=VERSION,
|
|
||||||
)
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,19 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def get_current_version():
|
def get_current_version(debug=True):
|
||||||
if "VERSION" in os.environ:
|
if "VERSION" in os.environ:
|
||||||
return os.environ["VERSION"]
|
return os.environ["VERSION"]
|
||||||
|
|
||||||
|
if debug:
|
||||||
|
try:
|
||||||
|
output = subprocess.check_output(
|
||||||
|
["git", "show", "--no-patch", "--format=%s"], universal_newlines=True
|
||||||
|
)
|
||||||
|
return output.strip()
|
||||||
|
except (subprocess.CalledProcessError, OSError):
|
||||||
|
return ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(
|
||||||
["git", "describe", "--tags"], universal_newlines=True
|
["git", "describe", "--tags"], universal_newlines=True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue