Skip to content

Commit

Permalink
Merge pull request #30 from ccnmtl/init-sentry
Browse files Browse the repository at this point in the history
Refactored common sentry setup
  • Loading branch information
ndittren authored Aug 23, 2024
2 parents dbc04ed + ac8fd73 commit a5ad3fb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
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,
)

0 comments on commit a5ad3fb

Please sign in to comment.