Add album art observability metrics, dashboard and alerts
CI / lint (push) Successful in 18s
CI / validate-monitoring (push) Successful in 13s
CI / federation-interop (push) Successful in 1m36s
CI / test (push) Successful in 3m37s
CI / assets (push) Successful in 8s
CI / python-package (push) Successful in 13s
CI / images (push) Successful in 1m37s
CI / trigger-deploy (push) Successful in 3s
CI / notify (push) Successful in 5s

Endpoint result counters, worker resolution/latency/image-size metrics,
per-upstream latency and error counters, cache-status and oldest-pending
gauges, an Album Art Grafana dashboard, and backlog/upstream-error alerts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
This commit is contained in:
mattandClaude Sonnet 5.5 committed 2026-10-06 21:56:18 +01:00
1 parent 6cd17d7586
commit 48fba1e0e2
9 files changed
+925 -3

No files matched your search

+7
View File
@@ -1,6 +1,7 @@
from flask import Response
from flask_smorest import Blueprint, abort
from scrobbler import metrics
from scrobbler.api.decorators import authenticated
from scrobbler.schemas import AlbumArtArgsSchema, ErrorSchema
from scrobbler.services import art
@@ -28,12 +29,18 @@ def album_art(args):
row = art.get_cached(args["artist"], args["album"])
if row is None:
art.want(args["artist"], args["album"])
metrics.art_requests_total.labels("queued").inc()
abort(404, code="no_album_art", message="Not resolved yet")
image = art.read_file(row.id) if row.status == "found" else None
if image is None:
if row.status == "found":
art.requeue(row) # resolved before, but the file is missing - ask again
result = "file_missing"
else:
result = "pending" if row.status == "pending" else "unavailable"
metrics.art_requests_total.labels(result).inc()
abort(404, code="no_album_art", message="No cover art found for this album")
metrics.art_requests_total.labels("served").inc()
response = Response(image, mimetype="image/jpeg")
response.headers["Cache-Control"] = "private, max-age=604800" # 7 days; art rarely changes
return response