Remove the metrics dashboard and monitoring package (v2.12.0)
The in-memory metrics system covered one gunicorn process at a time, was lost on restart and was never used. Remove /admin/metrics-dashboard, /admin/metrics, starpunk/monitoring, the HTTP/query timing, memory monitor, feed counters, METRICS_* settings and psutil. Keep /health, /admin/health (without its metrics block), pool stats and the feed cache. ADR-072. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6a916ba7d
commit
742e2e3ec3
36 files changed
+153
-2963
No files matched your search
@@ -218,8 +218,7 @@ server process enforces one shared limit. Old windows are pruned as it goes.
|
||||
timeout; `DB_POOL_SIZE` and `DB_TIMEOUT` can be set only through the
|
||||
`create_app()` config dict). Connections use `sqlite3.Row` rows,
|
||||
`check_same_thread=False`, `PRAGMA journal_mode=WAL` and (since v2.11.0)
|
||||
`PRAGMA foreign_keys=ON`, so `ON DELETE CASCADE`/`SET NULL` run, and are wrapped
|
||||
in `MonitoredConnection` for query timing when metrics are on. `get_db()`
|
||||
`PRAGMA foreign_keys=ON`, so `ON DELETE CASCADE`/`SET NULL` run. `get_db()`
|
||||
stores one connection in `flask.g` per request or app context; on teardown
|
||||
it goes back to the pool, rolled back first if a transaction was left
|
||||
open.
|
||||
|
||||
@@ -235,15 +235,12 @@ starts only if at least one is.
|
||||
| `THREADS_MAX_MEDIA` | `4` | |
|
||||
| `SYNDICATION_POLL_INTERVAL` | `10` | Seconds |
|
||||
|
||||
### Metrics and debugging
|
||||
### Debugging
|
||||
|
||||
The `METRICS_*` variables were removed in v2.12.0 and are ignored if set.
|
||||
|
||||
| Variable | Default | Notes |
|
||||
|----------|---------|-------|
|
||||
| `METRICS_ENABLED` | `true` | HTTP/database metrics and the memory monitor |
|
||||
| `METRICS_SLOW_QUERY_THRESHOLD` | `1.0` | Seconds |
|
||||
| `METRICS_SAMPLING_RATE` | `1.0` | |
|
||||
| `METRICS_BUFFER_SIZE` | `1000` | |
|
||||
| `METRICS_MEMORY_INTERVAL` | `30` | Seconds |
|
||||
| `DEBUG_SAVE_FAILED_UPLOADS` | `false` | Keep failed uploads in `debug/` |
|
||||
| `DEBUG_FILE_MAX_AGE_DAYS` | `7` | |
|
||||
| `DEBUG_FILE_MAX_SIZE_MB` | `100` | |
|
||||
|
||||
@@ -43,8 +43,6 @@ Key decisions:
|
||||
[ADR-058](../decisions/ADR-058-image-optimization-strategy.md) (media),
|
||||
[ADR-034](../decisions/ADR-034-full-text-search.md) (search),
|
||||
[ADR-052](../decisions/ADR-052-configuration-system-architecture.md) (configuration),
|
||||
[ADR-053](../decisions/ADR-053-performance-monitoring-strategy.md) and
|
||||
[ADR-060](../decisions/ADR-060-production-hotfix-metrics-dashboard.md) (metrics),
|
||||
[ADR-054](../decisions/ADR-054-structured-logging-architecture.md) (logging),
|
||||
[ADR-055](../decisions/ADR-055-error-handling-philosophy.md) (errors).
|
||||
|
||||
@@ -65,7 +63,6 @@ Key decisions:
|
||||
│ webmention worker works its queues only while holding a lock │
|
||||
│ websub worker works its queues only while holding a lock │
|
||||
│ syndication worker claims rows with a lease in SQLite │
|
||||
│ memory monitor per-process metrics │
|
||||
└───────────────┬──────────────────────────────┬─────────────────────┘
|
||||
│ │
|
||||
┌───────▼────────┐ ┌──────────▼──────────────────┐
|
||||
@@ -86,7 +83,7 @@ Key decisions:
|
||||
validates configuration, configures logging, cleans up old debug and
|
||||
temporary upload files, creates the schema and runs migrations (under a
|
||||
lock, see [database.md](database.md)), creates the connection pool,
|
||||
installs the HTTP metrics middleware, configures the feed cache and rate
|
||||
configures the feed cache and rate
|
||||
limiters, fills the FTS index if it is empty, registers blueprints, error
|
||||
handlers and template helpers, and starts the background threads.
|
||||
3. `before_request` assigns a correlation ID (included in every log line) and,
|
||||
@@ -94,8 +91,7 @@ Key decisions:
|
||||
4. The blueprint handler runs. Database access goes through `get_db()`, which
|
||||
hands out a pooled, request-scoped SQLite connection.
|
||||
5. `after_request` hooks add `Link: </webmention>; rel="webmention"` to HTML
|
||||
responses, WebSub `Link rel=hub` / `rel=self` headers to topic responses,
|
||||
and request metrics with an `X-Request-ID` header.
|
||||
responses, WebSub `Link rel=hub` / `rel=self` headers to topic responses.
|
||||
6. Errors are rendered by the central handlers in `starpunk/errors.py`
|
||||
(JSON for Micropub, HTML pages from `templates/<code>.html` elsewhere).
|
||||
|
||||
@@ -141,7 +137,6 @@ wait for outbound network calls; the workers make them later.
|
||||
| `errors.py` | Central error handlers |
|
||||
| `feeds/` | `rss.py` (feedgen), `atom.py`, `json_feed.py`, `opml.py`, `negotiation.py` (Accept header), `cache.py` (LRU + TTL feed cache with ETags) |
|
||||
| `feed.py` | Backward-compatibility re-export of `feeds.rss` |
|
||||
| `monitoring/` | Metrics buffer, HTTP middleware, database timing wrapper, memory monitor, business metrics |
|
||||
| `database/` | `schema.py` (`INITIAL_SCHEMA_SQL`), `init.py` (`init_db`), `pool.py` (connection pool) |
|
||||
| `migrations.py` | Migration runner for `migrations/NNN_*.sql` |
|
||||
|
||||
@@ -196,7 +191,7 @@ Everything works without JavaScript.
|
||||
| `/admin/webmentions`, `/admin/webmentions/<id>`, `…/action`, `…/bulk-action` | Webmention moderation |
|
||||
| `/admin/tokens`, `/admin/tokens/<id>/revoke` | Issued IndieAuth tokens |
|
||||
| `/admin/syndication/<id>/retry` | Retry a failed crosspost |
|
||||
| `/admin/metrics-dashboard`, `/admin/metrics`, `/admin/health` | Monitoring (HTML dashboard, JSON metrics, full diagnostics) |
|
||||
| `/admin/health` | Full diagnostics (JSON): database, pool statistics, filesystem, disk |
|
||||
| `/health` | Public liveness check (`{"status": "ok", "version": …}`); `?detailed=true` requires login |
|
||||
|
||||
## Background workers
|
||||
@@ -210,7 +205,6 @@ coordinated through the data volume:
|
||||
| Webmention worker (`webmention_worker.py`) | `WEBMENTION_WORKER_ENABLED` and not testing | Non-blocking `fcntl.flock` on `webmention-worker.lock` next to the database. Only the holder works the queues; the others try again each poll interval. The OS releases the lock if the holder dies, and the new holder resets rows stuck in `sending`. | Validates received webmentions; discovers endpoints and sends queued outgoing webmentions, with retries |
|
||||
| WebSub worker (`websub_worker.py`) | `WEBSUB_ENABLED` and not testing | Same pattern with `websub-worker.lock` | Verifies subscription intents, delivers topic content (signed with `X-Hub-Signature` when the subscriber gave a secret), retries, expires leases; pings an external hub instead if `WEBSUB_HUB_URL` is set |
|
||||
| Syndication worker (`syndication.py`) | At least one crosspost target configured, and not testing | No file lock. Rows in `syndications` are claimed with a 5-minute `claimed_until` lease by an atomic `UPDATE`, so any process may work a row but only one at a time; a `version` column keeps edits made during a send. Threads token refreshes are serialised with a lock file next to `threads_token.json`. | Creates, updates or deletes the remote post for each (note, target) pair; up to 8 attempts |
|
||||
| Memory monitor (`monitoring/memory.py`) | `METRICS_ENABLED` and not testing | None (per-process metrics) | Samples process memory every `METRICS_MEMORY_INTERVAL` seconds |
|
||||
|
||||
All workers run inside an app context, are daemon threads (they end with the
|
||||
process) and sleep for their poll interval when there is nothing to do. Under
|
||||
@@ -326,14 +320,11 @@ their credentials are set. The full list with defaults is in
|
||||
|
||||
- Logs go to stdout and `logs/starpunk.log` (10 MB × 10 files); each line
|
||||
carries the request's correlation ID.
|
||||
- Metrics (`monitoring/`): HTTP request timings, database query timings
|
||||
(with a slow-query threshold), memory, pool statistics and business
|
||||
counters, in an in-memory buffer per process, shown at
|
||||
`/admin/metrics-dashboard` and `/admin/metrics`.
|
||||
- `/health` reports status, version and webmention-worker statistics;
|
||||
`/health?detailed=true` checks database, filesystem and disk space;
|
||||
`/admin/health` adds metrics, pool statistics and system information.
|
||||
`/admin/health` adds pool statistics and filesystem details. (The metrics
|
||||
dashboard was removed in v2.12.0, see ADR-072.)
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2026-11-03 (v2.10.1)
|
||||
**Last Updated**: 2026-11-03 (v2.12.0)
|
||||
@@ -47,7 +47,6 @@ vulnerabilities (`pip-audit`); check again before each release.
|
||||
| python-dotenv | `1.2.*` | Loading `.env` |
|
||||
| Pillow | `13.0.*` | Image validation, resizing and variants |
|
||||
| pillow-heif | `1.8.*` | HEIC/HEIF uploads (iPhone photos) |
|
||||
| psutil | `7.2.*` | Memory monitor and system metrics |
|
||||
|
||||
`markupsafe` comes with Flask/Jinja2.
|
||||
|
||||
|
||||
Reference in new issue
Block a user