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 Django-debug-toolbar for profiling requests performance #768

Merged
merged 5 commits into from
May 18, 2020

Conversation

fuziontech
Copy link
Member

@fuziontech fuziontech commented May 14, 2020

Changes

  • Add django-debug-toolbar for profiling what is slowing down funnel generation.
  • Forward port to Postgres from docker-compose for running queries direct to Postgres

Really helps figure out what Django is trying to do on the backend and if it's the DB that's the problem or the app.
image

This is only enabled when DEBUG is True

Checklist

  • [ NA ] All querysets/queries filter by Team (if applicable)
  • [ NA ] Backend tests (if applicable)

requirements.txt Outdated
@@ -82,4 +82,4 @@ wcwidth==0.1.9
Werkzeug==1.0.0
whitenoise==5.0.1
zipp==3.1.0

django-debug-toolbar==2.2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to move this into requirements/dev.in and compile it with pip-compile requirements/dev.in

@@ -85,7 +85,8 @@ def get_env(key):
'rest_framework',
'loginas',
'corsheaders',
'social_django'
'social_django',
'debug_toolbar'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b/c of the below comment, this package won't always be here. Could do something like

try:
    import debug_toolbar
    INSTALLED_APPS.append('debug_toolbar')
    MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware')
except ImportError:
    pass

posthog/urls.py Outdated
@@ -180,11 +180,14 @@ def logout(request):
]

if settings.DEBUG:
import debug_toolbar # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably have the same try/except pattern in case someone uses DEBUG to debug live and hasn't installed debug_toolbarr

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds safe


# Load debug_toolbar if we can (DEBUG and Dev modes)
try:
import debug_toolbar # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be easier to just add the module to mypy.ini

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@timgl timgl merged commit 0f1d74d into PostHog:master May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants