Skip to content

Commit

Permalink
Merge pull request #6185 from akatsoulas/django-silk
Browse files Browse the repository at this point in the history
Use django-silk for profiling
  • Loading branch information
akatsoulas authored Aug 16, 2024
2 parents 26cf4a0 + 7e6fcfe commit e460ff9
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 37 deletions.
1 change: 1 addition & 0 deletions .env-dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=
EMAIL_PORT=1025
EMAIL_USE_TLS=False
USE_DJANGO_SILK=True
16 changes: 7 additions & 9 deletions kitsune/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,21 +991,19 @@ def JINJA_CONFIG():
AXES_BEHIND_REVERSE_PROXY = config("AXES_BEHIND_REVERSE_PROXY", default=not DEBUG, cast=bool)
AXES_REVERSE_PROXY_HEADER = config("AXES_REVERSE_PROXY_HEADER", default="HTTP_X_CLUSTER_CLIENT_IP")

USE_DEBUG_TOOLBAR = config("USE_DEBUG_TOOLBAR", default=False, cast=bool)
USE_DJANGO_SILK = config("USE_DJANGO_SILK", default=False, cast=bool)


def show_toolbar_callback(*args):
return DEBUG and USE_DEBUG_TOOLBAR
def show_debug_callback(*args):
return DEBUG and USE_DJANGO_SILK


SHOW_DEBUG_TOOLBAR = show_toolbar_callback()
SHOW_DEBUG_INFO = show_debug_callback()

if SHOW_DEBUG_TOOLBAR:
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": "kitsune.settings.show_toolbar_callback"}
if SHOW_DEBUG_INFO:
INSTALLED_APPS = INSTALLED_APPS + ("silk",)

INSTALLED_APPS = INSTALLED_APPS + ("debug_toolbar",)

MIDDLEWARE = ("debug_toolbar.middleware.DebugToolbarMiddleware",) + MIDDLEWARE
MIDDLEWARE = ("silk.middleware.SilkyMiddleware",) + MIDDLEWARE

# Set this to True to wrap each HTTP request in a transaction on this database.
ATOMIC_REQUESTS = config("ATOMIC_REQUESTS", default=True, cast=bool)
Expand Down
8 changes: 2 additions & 6 deletions kitsune/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,8 @@
),
]

if settings.SHOW_DEBUG_TOOLBAR:
import debug_toolbar

urlpatterns += [
re_path("__debug__/", include(debug_toolbar.urls)),
]
if settings.SHOW_DEBUG_INFO:
urlpatterns += [path("silk/", include("silk.urls", namespace="silk"))]


if settings.ENABLE_ADMIN:
Expand Down
68 changes: 47 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ google-analytics-data = "0.18.7"
pyparsing = "3.1.2"
wagtail = "6.1.3"
wagtail-localize = "1.9"
django-silk = "^5.1.0"
requests = "^2.32.3"

[tool.poetry.group.dev.dependencies]
ipdb = "^0.13.11"
isort = "^5.13.2"
pep8 = "^1.7.1"
appnope = "^0.1.3"
argparse = "^1.4.0"
django-debug-toolbar = "^3.8.1"
django-cache-panel = "^0.1"
jsonschema = "^4.20.0"
pre-commit = "^3.6.0"
Expand Down

0 comments on commit e460ff9

Please sign in to comment.