Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable more Sentry features #3662

Merged
merged 8 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions backend/pycon/celery.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
from datetime import timedelta
import logging
import os
from celery import Celery

logger = logging.getLogger(__name__)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pycon.settings.prod")

app = Celery("pycon")
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()


@app.on_after_configure.connect
def setup_periodic_tasks(sender, **kwargs):
try:
add = sender.add_periodic_task

add(timedelta(minutes=2), debug_cron)
except Exception:
logger.exception("setup_periodic_tasks")


@app.task
def debug_cron():
print("debug cron")
26 changes: 24 additions & 2 deletions backend/pycon/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import stripe
import environ
import sentry_sdk
from django.utils.translation import gettext_lazy as _
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.strawberry import StrawberryIntegration
from sentry_sdk.integrations.celery import CeleryIntegration

root = environ.Path(__file__) - 3

Expand All @@ -12,12 +17,31 @@

environ.Env.read_env(root(".env"))

ENVIRONMENT = env("ENV", default="local")

DEBUG = env("DEBUG")

ALLOWED_HOSTS = env("ALLOWED_HOSTS")

FRONTEND_URL = env("FRONTEND_URL")

SENTRY_DSN = env("SENTRY_DSN", default="")

if SENTRY_DSN:
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=[
DjangoIntegration(),
AwsLambdaIntegration(),
StrawberryIntegration(async_execution=False),
CeleryIntegration(monitor_beat_tasks=True),
],
traces_sample_rate=0.4,
profiles_sample_rate=0.4,
send_default_pii=True,
environment=ENVIRONMENT,
)

# Application definition

INSTALLED_APPS = [
Expand Down Expand Up @@ -207,8 +231,6 @@

SIMULATE_PRETIX_DB = True

ENVIRONMENT = env("ENV", default="local")

LOGGING = {
"version": 1,
"disable_existing_loggers": False,
Expand Down
2 changes: 0 additions & 2 deletions backend/pycon/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

SECRET_KEY = env("SECRET_KEY")

SENTRY_DSN = env("SENTRY_DSN", default="")

AWS_STORAGE_BUCKET_NAME = env("AWS_MEDIA_BUCKET", default=None)
AWS_S3_REGION_NAME = env("AWS_REGION_NAME", default="eu-central-1")
AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID", default=None)
Expand Down
20 changes: 0 additions & 20 deletions backend/wsgi_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
import traceback
from logging import getLogger

import sentry_sdk
from django.apps import apps
from django.conf import settings
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.strawberry import StrawberryIntegration

# imports serverless_wsgi from the root
import serverless_wsgi
Expand All @@ -29,22 +25,6 @@
logger = getLogger(__name__)


SENTRY_DSN = settings.SENTRY_DSN

if SENTRY_DSN:
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=[
DjangoIntegration(),
AwsLambdaIntegration(),
StrawberryIntegration(async_execution=False),
],
traces_sample_rate=0.2,
send_default_pii=True,
environment=settings.ENVIRONMENT,
)


def import_app(config):
"""Load the application WSGI handler"""
wsgi_fqn = config["app"].rsplit(".", 1)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ x-defaults:
OAUTHLIB_INSECURE_TRANSPORT: ${OAUTHLIB_INSECURE_TRANSPORT}
DEEPL_AUTH_KEY: ${DEEPL_AUTH_KEY:-}
FLODESK_API_KEY: ${FLODESK_API_KEY}
SENTRY_DSN: ${SENTRY_DSN:-}
FLODESK_SEGMENT_ID: ${FLODESK_SEGMENT_ID}
CELERY_BROKER_URL: redis://redis:6379/9
CELERY_RESULT_BACKEND: redis://redis:6379/10
Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@mdx-js/loader": "^1.6.19",
"@next/mdx": "^10.0.0",
"@python-italia/pycon-styleguide": "0.1.181",
"@sentry/nextjs": "^7.77.0",
"@sentry/nextjs": "^7.91.0",
"@theme-ui/core": "^0.15.3",
"@theme-ui/css": "^0.15.3",
"@theme-ui/match-media": "^0.15.3",
Expand All @@ -56,7 +56,7 @@
"isomorphic-fetch": "^3.0.0",
"marksy": "^8.0.0",
"moment": "^2.29.1",
"next": "14.0.3",
"next": "14.0.4",
"next-cookies": "^2.0.3",
"pdfkit": "^0.13.0",
"react": "^18.2.0",
Expand Down
Loading
Loading