Skip to content

Commit

Permalink
Merge pull request #384 from hellohaptik/develop
Browse files Browse the repository at this point in the history
Develop to Master Sync
  • Loading branch information
ankur09011 authored Nov 19, 2020
2 parents 3d21f67 + e850e1c commit b6ece21
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions chatbot_ner/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import os
import sys

from chatbot_ner.setup_sentry import setup_sentry

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

# Quick-start development settings - unsuitable for production
Expand All @@ -28,6 +30,10 @@

ALLOWED_HOSTS = ['*']

# setup sentry

setup_sentry()

# Application definition

INSTALLED_APPS = [
Expand Down
35 changes: 35 additions & 0 deletions chatbot_ner/setup_sentry.py
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
)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b6ece21

Please sign in to comment.