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

Refactored common sentry setup #30

Merged
merged 1 commit into from
Aug 23, 2024
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
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.3.4
====================
* Introduced init_sentry function for staging and production.

0.3.3 (2024-08-15)
====================
* Added token process to get_ec2_instance_ip()
Expand Down
19 changes: 10 additions & 9 deletions ctlsettings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def common(**kwargs):
s3static = kwargs.get('s3static', True)
cloudfront = kwargs.get('cloudfront', None)
s3prefix = kwargs.get('s3prefix', 'ctl')
sentry_dsn = kwargs.get('sentry_dsn', None)

DEBUG = False

Expand All @@ -30,14 +29,6 @@ def common(**kwargs):
}
}

if sentry_dsn and \
('migrate' not in sys.argv) and \
('collectstatic' not in sys.argv):
sentry_sdk.init(
dsn=sentry_dsn, # noqa: F405
integrations=[DjangoIntegration()],
)

MEDIA_ROOT = '/var/www/' + project + '/uploads/'

STATICMEDIA_MOUNTS = [
Expand Down Expand Up @@ -98,3 +89,13 @@ def common(**kwargs):
}

return locals()


def init_sentry(sentry_dsn: str) -> None:
if sentry_dsn and \
('migrate' not in sys.argv) and \
('collectstatic' not in sys.argv):
sentry_sdk.init(
dsn=sentry_dsn,
integrations=[DjangoIntegration()],
)
21 changes: 11 additions & 10 deletions ctlsettings/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def common(**kwargs):
s3static = kwargs.get('s3static', True)
cloudfront = kwargs.get('cloudfront', None)
s3prefix = kwargs.get('s3prefix', 'ctl')
sentry_dsn = kwargs.get('sentry_dsn', None)

DEBUG = False
STAGING_ENV = True
Expand All @@ -31,15 +30,6 @@ def common(**kwargs):
}
}

if sentry_dsn and \
('migrate' not in sys.argv) and \
('collectstatic' not in sys.argv):
sentry_sdk.init(
dsn=sentry_dsn, # noqa: F405
integrations=[DjangoIntegration()],
debug=True,
)

STATSD_PREFIX = project + "-staging"

MEDIA_ROOT = '/var/www/' + project + '/uploads/'
Expand Down Expand Up @@ -103,3 +93,14 @@ def common(**kwargs):
}

return locals()


def init_sentry(sentry_dsn: str) -> None:
if sentry_dsn and \
('migrate' not in sys.argv) and \
('collectstatic' not in sys.argv):
sentry_sdk.init(
dsn=sentry_dsn,
integrations=[DjangoIntegration()],
debug=True,
)