From 71f7a444398275923246e1bc8283938a63a8267a Mon Sep 17 00:00:00 2001 From: bndw Date: Sun, 15 Feb 2026 08:22:03 -0800 Subject: feat: add metrics for blocked events Track and display blocked event counts with per-kind breakdown. - Add events_blocked_total counter with kind label - Add RecordBlockedEvent method to metrics - Display blocked count in dashboard Storage section - Call metric when rejecting non-core protocol kinds Allows monitoring spam patterns and verifying kind filter effectiveness. Raw metrics show breakdown by kind (e.g., kind=20001, kind=30311). --- internal/handler/websocket/handler.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'internal/handler') diff --git a/internal/handler/websocket/handler.go b/internal/handler/websocket/handler.go index 8daa89f..35d0aea 100644 --- a/internal/handler/websocket/handler.go +++ b/internal/handler/websocket/handler.go @@ -33,6 +33,7 @@ type MetricsRecorder interface { DecrementSubscriptions() SetActiveSubscriptions(count int) RecordRequest(method, status string, duration float64) + RecordBlockedEvent(kind int32) } type RateLimiter interface { @@ -302,6 +303,9 @@ func (h *Handler) handleEvent(ctx context.Context, conn *websocket.Conn, raw []j // Reject non-core protocol kinds (spam, ephemeral, chat) if !isAllowedKind(pbEvent.Kind) { status = "ok" + if h.metrics != nil { + h.metrics.RecordBlockedEvent(pbEvent.Kind) + } h.sendOK(ctx, conn, event.ID, true, "rejected: kind not supported") return nil } -- cgit v1.2.3