diff --git a/.gitignore b/.gitignore index 4476b397be1..10cf3b671c7 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ webpack-stats.json # .tfvars files *.tfvars + +*.prof diff --git a/Dockerfile b/Dockerfile index ea480f5deed..7d6bd0d5dc0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.6-slim-jessie ENV PYTHONUNBUFFERED 1 RUN mkdir /code && \ apt-get update && \ - apt-get install -y --no-install-recommends wget git dos2unix gcc libc6-dev libc-dev libssl-dev make automake libtool autoconf pkg-config libffi-dev && \ + apt-get install -y --no-install-recommends graphviz wget git dos2unix gcc libc6-dev libc-dev libssl-dev make automake libtool autoconf pkg-config libffi-dev && \ pip3 install dumb-init && \ rm -rf /var/lib/apt/lists/* diff --git a/app/app/settings.py b/app/app/settings.py index 007c0e3e18f..3d88c1f5dfe 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -343,3 +343,19 @@ # COLO Coin COLO_ACCOUNT_ADDRESS = env('COLO_ACCOUNT_ADDRESS', default='') COLO_ACCOUNT_PRIVATE_KEY = env('COLO_ACCOUNT_PRIVATE_KEY', default='') + +# Silk Profiling and Performance Monitoring +ENABLE_SILK = env.bool('ENABLE_SILK', default=DEBUG) +if ENABLE_SILK: + INSTALLED_APPS += ['silk'] + MIDDLEWARE += ('silk.middleware.SilkyMiddleware', ) + SILKY_PYTHON_PROFILER = env.bool('SILKY_PYTHON_PROFILER', default=True) + SILKY_PYTHON_PROFILER_BINARY = env.bool('SILKY_PYTHON_PROFILER_BINARY', default=False) + SILKY_AUTHENTICATION = env.bool('SILKY_AUTHENTICATION', default=False) + SILKY_AUTHORISATION = env.bool('SILKY_AUTHORISATION', default=False) + SILKY_META = env.bool('SILKY_META', default=True) + SILKY_INTERCEPT_PERCENT = env.int('SILKY_INTERCEPT_PERCENT', default=50) + SILKY_MAX_RECORDED_REQUESTS = env.int('SILKY_MAX_RECORDED_REQUESTS', default=10000) + SILKY_DYNAMIC_PROFILING = env.dict('SILKY_DYNAMIC_PROFILING', default={}) + SILKY_MAX_RECORDED_REQUESTS_CHECK_PERCENT = env.int( + 'SILKY_MAX_RECORDED_REQUESTS_CHECK_PERCENT', default=10) diff --git a/app/app/urls.py b/app/app/urls.py index 33f6170bd6e..fb32a914dc6 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -197,9 +197,11 @@ path(settings.SENDGRID_EVENT_HOOK_URL, marketing.webhookviews.process, name='sendgrid_event_process'), # gitcoinbot url(settings.GITHUB_EVENT_HOOK_URL, gitcoinbot.views.payload, name='payload'), - ] +if settings.ENABLE_SILK: + urlpatterns += [url(r'^silk/', include('silk.urls', namespace='silk'))] + handler403 = 'retail.views.handler403' handler404 = 'retail.views.handler404' handler500 = 'retail.views.handler500' diff --git a/requirements/base.txt b/requirements/base.txt index caabbe3a9d0..b5092b74cc9 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -41,3 +41,4 @@ eth-utils==1.0.0b2 jsondiff==1.1.1 django-ipware==2.0.1 geoip2==2.7.0 +django-silk==2.0.0