Generic background worker (phase 0, step 2)
scrobbler/worker.py runs tasks that modules register: queue tasks
(called while they report work) and periodic tasks. A failing task is
logged, counted, rolled back and doesn't stop the others. Imports are
now just a registered task plus a periodic stall check.
- `flask worker` replaces `flask imports worker` (kept as an alias);
compose uses the new command
- scrobbler_worker_tasks_total{task,outcome} and a Worker tasks panel
on the Usage dashboard
- WORKER_METRICS_PORT (IMPORT_WORKER_METRICS_PORT still honoured)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
59ff1bdfa0
commit
098eab025f
13 files changed
+292
-42
No files matched your search
@@ -572,7 +572,7 @@
|
||||
},
|
||||
{
|
||||
"type": "row",
|
||||
"title": "Imports",
|
||||
"title": "Background work",
|
||||
"id": 13,
|
||||
"collapsed": false,
|
||||
"gridPos": {
|
||||
@@ -878,6 +878,67 @@
|
||||
"h": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Worker tasks",
|
||||
"description": "Runs of each background task that did work, and failures. A task that keeps failing is logged by the worker.",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum by (task) (increase(scrobbler_worker_tasks_total{outcome=\"worked\"}[$__rate_interval]))",
|
||||
"legendFormat": "{{task}}",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum by (task) (increase(scrobbler_worker_tasks_total{outcome=\"error\"}[$__rate_interval]))",
|
||||
"legendFormat": "{{task}} errors",
|
||||
"refId": "B"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short",
|
||||
"custom": {
|
||||
"lineWidth": 1,
|
||||
"fillOpacity": 70,
|
||||
"showPoints": "never",
|
||||
"spanNulls": true,
|
||||
"drawStyle": "bars"
|
||||
},
|
||||
"min": 0
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "multi",
|
||||
"sort": "desc"
|
||||
}
|
||||
},
|
||||
"id": 19,
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 38,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Import duration (p95)",
|
||||
@@ -921,10 +982,10 @@
|
||||
"sort": "desc"
|
||||
}
|
||||
},
|
||||
"id": 19,
|
||||
"id": 20,
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 38,
|
||||
"x": 0,
|
||||
"y": 46,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user