Skip to content

Commit

Permalink
Add gc debugging flag to help debug prod thumbnails leak (#3354)
Browse files Browse the repository at this point in the history
* Add gc debugging flag to help debug prod thumbnails leak

* Add documentation to the new environment variable

* Simplify setting aggregation
  • Loading branch information
sarayourfriend authored Nov 14, 2023
1 parent 822863f commit 7ed521c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/conf/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ def get_asgi_application():

if settings.ENVIRONMENT == "local":
static_files_application = ASGIStaticFilesHandler(application)


if settings.GC_DEBUG_LOGGING:
import gc

setting = 0
for flag in settings.GC_DEBUG_LOGGING:
setting |= getattr(gc, flag)

gc.set_debug(setting)
6 changes: 6 additions & 0 deletions api/conf/settings/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ def health_check_filter(record: LogRecord) -> bool:
LOG_LEVEL = config("LOG_LEVEL", default="INFO").upper()
DJANGO_DB_LOGGING = config("DJANGO_DB_LOGGING", cast=bool, default=False)

# Set to a pipe-delimited string of gc debugging flags
# https://docs.python.org/3/library/gc.html#gc.DEBUG_STATS
GC_DEBUG_LOGGING = config(
"GC_DEBUG_LOGGING", cast=lambda x: x.split("|") if x else [], default=""
)

# https://github.com/dabapps/django-log-request-id#logging-all-requests
LOG_REQUESTS = True

Expand Down

0 comments on commit 7ed521c

Please sign in to comment.