✨(backend) report selfcheck status to Sentry crons

Use the new (documented) env var MESSAGES_SELFCHECK_SENTRY_MONITOR_SLUG
to enable
This commit is contained in:
Sylvain Zimmer
2026-06-04 00:23:52 +02:00
parent b68f0c4d37
commit bb3672b83e
6 changed files with 203 additions and 3 deletions
+14
View File
@@ -247,6 +247,20 @@ _Those settings are deprecated and will be removed in the future._
| `NEXT_PUBLIC_SENTRY_DSN` | None | Sentry DSN for error tracking | Optional |
| `NEXT_PUBLIC_SENTRY_ENVIRONMENT` | None | Sentry environment for error tracking | Optional ('production', 'development', 'staging') |
### Selfcheck
End-to-end mail delivery probe — see [selfcheck.md](selfcheck.md) for details.
| Variable | Default | Description | Required |
|----------|---------|-------------|----------|
| `MESSAGES_SELFCHECK_FROM` | None | Email address the selfcheck sends from. Leave unset to disable the selfcheck. | Optional |
| `MESSAGES_SELFCHECK_TO` | None | Email address the selfcheck sends to. Leave unset to disable the selfcheck. | Optional |
| `MESSAGES_SELFCHECK_SECRET` | `self-check-secret-for-dev` | Secret string embedded in the test message body | Optional |
| `MESSAGES_SELFCHECK_INTERVAL` | `600` | Interval between selfcheck runs, in seconds | Optional |
| `MESSAGES_SELFCHECK_TIMEOUT` | `60` | Timeout for message reception, in seconds | Optional |
| `MESSAGES_SELFCHECK_WEBHOOK_URL` | None | Webhook URL POSTed on each successful selfcheck (updown.io-compatible heartbeat) | Optional |
| `MESSAGES_SELFCHECK_SENTRY_MONITOR_SLUG` | None | Sentry cron monitor slug. When set (with `SENTRY_DSN`), each run is reported as a Sentry check-in. | Optional |
### Logging
| Variable | Default | Description | Required |
+14
View File
@@ -28,6 +28,10 @@ Optionally, to enable uptime alerting via a selfcheck webhook:
- `MESSAGES_SELFCHECK_WEBHOOK_URL`: URL of the selfcheck webhook endpoint (default: `None` - disabled)
Optionally, to report selfcheck runs to [Sentry Crons](https://docs.sentry.io/product/crons/):
- `MESSAGES_SELFCHECK_SENTRY_MONITOR_SLUG`: Slug of the Sentry cron monitor (default: `None` - disabled). Requires `SENTRY_DSN` to also be set.
## Usage
### Manual Execution
@@ -95,6 +99,16 @@ The POST body includes timing data:
{"send_time": 0.15, "reception_time": 2.34}
```
### Sentry Crons
When `MESSAGES_SELFCHECK_SENTRY_MONITOR_SLUG` is configured (and `SENTRY_DSN` is set), each selfcheck run is reported to [Sentry Crons](https://docs.sentry.io/product/crons/):
- An `in_progress` check-in is opened before the test message is sent.
- The check-in is closed with status `ok` on success or `error` on failure.
- On success, the reported `duration` is `send_time + reception_time`, excluding the post-run cleanup pause.
Configure the monitor schedule (interval and grace period) in the Sentry UI to match `MESSAGES_SELFCHECK_INTERVAL`. Runs skipped because `MESSAGES_SELFCHECK_FROM` or `MESSAGES_SELFCHECK_TO` is empty do not produce a check-in.
## Security Considerations
- The selfcheck uses dedicated test mailboxes that are separate from user data