Skip to content

Gate Django Silk behind ENABLE_SILK flag#103

Merged
vanajmoorthy merged 1 commit into
mainfrom
chore/silk-enable-flag
May 5, 2026
Merged

Gate Django Silk behind ENABLE_SILK flag#103
vanajmoorthy merged 1 commit into
mainfrom
chore/silk-enable-flag

Conversation

@vanajmoorthy
Copy link
Copy Markdown
Owner

Summary

  • Silk was loaded whenever DEBUG=True, which meant every local Docker run paid Silk's per-request overhead (extra DB writes, profiler hooks) regardless of whether profiling was actually wanted.
  • Replaced the DEBUG gate with a dedicated ENABLE_SILK env var (default False) in settings.py and urls.py.
  • Wired ENABLE_SILK=${ENABLE_SILK:-False} into both web and worker services in docker-compose.local.yml, and documented the flag in .env.example.

How to enable Silk

Add ENABLE_SILK=True to .env, then:

```bash
docker-compose -f docker-compose.local.yml up --build -d

Visit http://localhost:8000/silk/

```

Default is off, so day-to-day Docker runs no longer pay the Silk overhead.

Test plan

  • docker-compose -f docker-compose.local.yml up --build -d with no ENABLE_SILK in .env/silk/ should 404 and silk should not appear in INSTALLED_APPS.
  • Add ENABLE_SILK=True to .env, rebuild — /silk/ loads the Silk dashboard and middleware records requests.

Silk was tied to DEBUG, which meant any local Docker run paid Silk's
per-request overhead (extra DB writes, profiler hooks) whether or not
profiling was actually wanted. Move the gate to a dedicated
ENABLE_SILK env var (default False) so Silk only loads when explicitly
opted in.

Wired into docker-compose.local.yml for both web and worker. To
profile locally: add ENABLE_SILK=True to .env, restart, hit /silk/.
@vanajmoorthy vanajmoorthy merged commit 75832f5 into main May 5, 2026
1 check passed
@vanajmoorthy vanajmoorthy deleted the chore/silk-enable-flag branch May 5, 2026 19:30
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.

1 participant