You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Health checks. Include content_studio.health.urls at the root of
your site for the endpoints a container orchestrator calls: /healthz
answers when the process is up, /readyz checks the database
(SELECT 1) and the cache (a set and a get), and /statusz adds the
worker. Each check answers ok, error or off, only error makes the
answer 503, and the answers need no login and carry no details. content_studio.health.middleware.HealthCheckMiddleware, placed above SecurityMiddleware, answers /healthz and /readyz before Django
checks the Host header, so a healthcheck on the container's internal IP
works. A worker heartbeat stamps the cache every minute and when a worker
starts; with Huey it runs on Huey's consumer by itself, stays out of the
recent runs and periodic tasks on the task dashboard and status page, and
out of Huey's stats records. Other backends call content_studio.health.beat() from their own scheduler. The worker is off when tasks run in the request or the cache is per process, and an error when its heartbeat is older than HEALTH_WORKER_STALE_AFTER
(180 seconds). manage.py content_studio_worker_alive exits with 1
then, for the worker container's healthcheck. The system status page
gains a Worker row and its Database and Cache rows run the same checks. TaskAdapter has three new optional methods, register_periodic_task(), on_worker_startup() and runs_in_request(), which HueyAdapter implements. manage.py check
warns with content_studio.W036 when the middleware comes after SecurityMiddleware or CommonMiddleware, and with content_studio.W037 when tasks run on workers but the default cache is
per process.
Error reports. Content Studio can report server errors while DEBUG
is off. Off by default; set ERROR_REPORTS to "email" and every new
line logged at ERROR or above (a 500, a failed task, your own logger.error()) is mailed to ERROR_EMAIL, or the active superusers,
and with the notifications app is a "Server errors" notification of the
superusers. The same error (logger, exception type and line) is reported
at most once an hour, and its unread notification counts up instead of
repeating. Set it to "sentry" and errors go to Sentry with SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_RELEASE and SENTRY_TRACES_SAMPLE_RATE, tagged with the request ID and without
personal data; install django-content-studio[sentry]. Every setting
takes the plain string an environment variable gives. The system status
page shows an Error reports row and, in email mode, a Recent errors card
with the viewer's latest 8 error notifications. manage.py check reports
a setting that cannot work as content_studio.E064, warns with content_studio.W038 when Django's mail_admins would mail every error
too, and with content_studio.W039 for Sentry mode without a DSN.
Logging.content_studio.logs adds RequestIdMiddleware, which
gives each request an ID (a plain forwarded X-Request-ID, or a new one),
returns it in the response, puts it on every log line and writes one
access log line per request on content_studio.access (successful health
checks left out). logging_settings("json") builds a LOGGING setting
with JSON or plain lines and the request ID; JsonFormatter, PlainFormatter, RequestIdFilter and get_request_id() work in your
own.