Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions healthcheck/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from logging import Filter

class HealthCheckFilter(Filter):
def filter(self, record):
# Should return True for all requests except successful healthcheck requests
return record.status_code != 204 or not (
record.args[0].startswith('GET /ping ') or
record.args[0].startswith('GET /ping/')
)
12 changes: 10 additions & 2 deletions openstax/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@
logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False,
'filters': {
'healthcheck_filter': {
'()': 'healthcheck.filter.HealthCheckFilter'
},
},
'formatters': {
'default': {
# exact format is not important, this is the minimum information
Expand All @@ -300,7 +305,7 @@
'django.server': DEFAULT_LOGGING['formatters']['django.server'],
},
'handlers': {
#disable logs set with null handler
# disable logs set with null handler
'null': {
'class': 'logging.NullHandler',
},
Expand All @@ -309,7 +314,10 @@
'class': 'logging.StreamHandler',
'formatter': 'default',
},
'django.server': DEFAULT_LOGGING['handlers']['django.server'],
'django.server': {
**DEFAULT_LOGGING['handlers']['django.server'],
'filters': ['healthcheck_filter']
},
},
'loggers': {
# default for all undefined Python modules
Expand Down