Files
Scrobbler/src/scrobbler/federation/metrics.py
T
mattandClaude Opus 5.5 f312c4b577
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 14s
CI / test (push) Successful in 1m57s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
Inbox: intake and verified processing of follows (phase 2, step 4)
Intake (in the request, no network): size, content type and shape
checks, blocked domains refused (403), duplicates acknowledged once,
then stored and answered 202.

Processing (federation.inbox worker task):
- verify the HTTP signature with either scheme, as of when it arrived,
  using the cached key and refreshing the sender once on failure (key
  rotation); a deleted account's Delete still verifies from cache
- the signer must be the activity's actor and the activity id must be
  on the actor's host
- handlers: Follow (accept, or pending with manual approval; repeat
  follows re-accepted; blocked accounts rejected), Undo of a Follow
  (only by the same actor), Delete of an actor, Update of an actor;
  anything else recorded
- items being processed are marked, retried on transient failures,
  re-queued if a worker dies, and pruned after 30 days

Outgoing Accept/Reject/Block activities are stored with stable ids and
queued per inbox for the delivery task (next step). Public activities
are fetchable at /activities/<uuid>. Metrics for inbox activities and
signature checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 21:29:55 +01:00

32 lines
1.0 KiB
Python

"""Federation's own metrics (the core's HTTP metrics already cover rate/latency)."""
from prometheus_client import Counter
lookups_total = Counter(
"scrobbler_federation_lookups_total",
"Fediverse lookups answered: WebFinger, actor, NodeInfo, profile",
["kind", "result"],
)
sharing_changes_total = Counter(
"scrobbler_federation_sharing_changes_total",
"Users switching fediverse sharing on or off",
["change"],
)
inbox_requests_total = Counter(
"scrobbler_federation_inbox_requests_total",
"Deliveries received at an inbox (not yet processed: phase 2)",
["inbox"],
)
inbox_activities_total = Counter(
"scrobbler_federation_inbox_activities_total",
"Activities received: queued, duplicate, blocked or invalid at intake; then processed, "
"rejected or failed",
["type", "result"],
)
signatures_total = Counter(
"scrobbler_federation_signatures_total",
"HTTP signature checks (in) and signing (out), by scheme and result",
["direction", "scheme", "result"],
)