-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #384 from hellohaptik/develop
Develop to Master Sync
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from __future__ import absolute_import | ||
|
||
import os | ||
import sys | ||
|
||
# HAPTIK Environment and CAS name | ||
ENVIRONMENT = os.environ.get('ENVIRONMENT') or os.environ.get('HAPTIK_ENV') | ||
CLIENT_APPLICATIONS_SETUP_NAME = os.environ.get('CLIENT_APPLICATIONS_SETUP_NAME') | ||
|
||
# Support for Sentry DSN | ||
SENTRY_DSN = os.environ.get('SENTRY_DSN') | ||
SENTRY_ENABLED = os.environ.get('SENTRY_ENABLED') | ||
SENTRY_ENABLED = True if SENTRY_ENABLED == 'True' and 'test' not in sys.argv else False | ||
|
||
|
||
def setup_sentry(): | ||
""" | ||
Setup sentry if enabled in the environment | ||
""" | ||
if SENTRY_ENABLED: | ||
import sentry_sdk | ||
from sentry_sdk.integrations.django import DjangoIntegration | ||
from sentry_sdk.integrations.logging import LoggingIntegration | ||
|
||
def before_sentry_send(event, hint): | ||
event.setdefault("tags", {})["cas_name"] = CLIENT_APPLICATIONS_SETUP_NAME | ||
return event | ||
|
||
sentry_sdk.init( | ||
dsn=SENTRY_DSN, | ||
integrations=[DjangoIntegration(), LoggingIntegration()], | ||
environment=ENVIRONMENT, | ||
sample_rate=0.1, | ||
before_send=before_sentry_send | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ flake8==3.4.1 | |
pyaml==19.4.1 | ||
coverage==4.5.3 | ||
nose-exclude==0.5.0 | ||
sentry-sdk==0.14.1 |