Skip to content

Commit

Permalink
Add Django Silk - Ref #777
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeacom committed Apr 4, 2018
1 parent e82624d commit 7072cc1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ webpack-stats.json

# .tfvars files
*.tfvars

*.prof
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*

Expand Down
16 changes: 16 additions & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7072cc1

Please sign in to comment.