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

Add elastic APM config changes #393

Merged
merged 6 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
23 changes: 23 additions & 0 deletions chatbot_ner/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from chatbot_ner.setup_sentry import setup_sentry

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
ENVIRONMENT = os.environ.get('ENVIRONMENT') or os.environ.get('HAPTIK_ENV')

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
Expand Down Expand Up @@ -59,6 +60,28 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

# APM
_elastic_apm_enabled = (os.environ.get('ELASTIC_APM_ENABLED') or '').strip().lower()
ELASTIC_APM_ENABLED = (_elastic_apm_enabled == 'true') and 'test' not in sys.argv
ELASTIC_APM_SERVER_URL = os.environ.get('ELASTIC_APM_SERVER_URL')
if ELASTIC_APM_ENABLED:
minion96 marked this conversation as resolved.
Show resolved Hide resolved
ELASTIC_APM = {
'DEBUG': DEBUG,
'SERVICE_NAME': 'chatbot_ner',
'SERVER_URL': ELASTIC_APM_SERVER_URL,
'SPAN_FRAMES_MIN_DURATION': '5ms',
'STACK_TRACE_LIMIT': 500,
'ENVIRONMENT': ENVIRONMENT,
'TRANSACTION_SAMPLE_RATE': '0.1',
'TRANSACTION_MAX_SPANS': 500,
'INSTRUMENT': 'True',
'DISABLE_SEND': 'False',
'CAPTURE_BODY': 'off',
'SERVER_TIMEOUT': '2s',
}
INSTALLED_APPS.append('elasticapm.contrib.django')
MIDDLEWARE.append('elasticapm.contrib.django.middleware.TracingMiddleware')

ROOT_URLCONF = 'chatbot_ner.urls'

WSGI_APPLICATION = 'chatbot_ner.wsgi.application'
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pytz==2014.2
nltk==3.4.5
numpy==1.16
elasticsearch==5.5.0
elastic-apm==5.10.0
requests==2.20.0
requests-aws4auth==0.9
Django==1.11.29
Expand Down