Task group 4 of federation-hardening.
4.1 — FEDERATION.md at the repo root: actor discovery (WebFinger, actor,
NodeInfo), object/activity types with real JSON examples (Note, Create,
Delete, the narrow follow-graph inbox), addressing, HTTP-Signature
expectations, the two-layer dedup contract, durable delivery/retry
policy, and blocklist moderation semantics — precise enough for another
implementation to interoperate. Linked from README and docs/architecture.
4.2 — three prom-client metrics + a journal dashboard row:
- `federation_delivery_total{outcome}` — incremented in deliver-activity
(delivered/skipped/failed).
- `federation_inbox_dropped_total{reason}` — incremented at every inbox
drop (duplicate | blocked); this is the counter deferred from task 3.2.
- `federation_queue_depth` — gauge sampled at scrape time in
/api/metrics from PgBossMessageQueue.getDepth(); the restart-loss
regression detector.
Grafana journal.json gains a Federation row (delivery rate, queue depth,
inbox drops); the logs panels shift down to make room.
Verified: dashboard JSON valid; journal typecheck + lint clean; unit
suite 357 passing (route-template guard unaffected).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
21 lines
828 B
TypeScript
21 lines
828 B
TypeScript
import { registry, federationQueueDepth } from "~/lib/metrics.server";
|
|
|
|
export async function loader() {
|
|
// Sample the durable Fedify queue depth at scrape time (the
|
|
// restart-loss regression detector). Best-effort: if federation is off
|
|
// or the boss isn't up yet, leave the last value rather than fail the
|
|
// scrape.
|
|
if (process.env.FEDERATION_ENABLED === "true") {
|
|
try {
|
|
const { PgBossMessageQueue } = await import("~/lib/federation-queue.server");
|
|
const depth = await new PgBossMessageQueue().getDepth();
|
|
federationQueueDepth.set(depth.queued);
|
|
} catch {
|
|
// boss not initialized / transient DB error — keep the prior gauge value
|
|
}
|
|
}
|
|
const metrics = await registry.metrics();
|
|
return new Response(metrics, {
|
|
headers: { "Content-Type": registry.contentType },
|
|
});
|
|
}
|