subscription: lag monitoring with configurable alert callback #146

Closed
opened 2026-03-01 11:45:06 +00:00 by ash · 0 comments
Owner

Problem

If projections fall behind (slow Evolve, high write throughput), there is no signal. Projection lag grows silently until users notice stale data.

Solution

Add lag monitoring to subscription:

subscription.Config{
    OnLagThreshold: func(lag uint64, consumer string) {
        slog.Warn("projection falling behind", "lag", lag, "consumer", consumer)
        metrics.Record("projection.lag", lag)
    },
    LagThreshold: 1000, // fire when lag exceeds this
    LagCheckInterval: 10 * time.Second,
}

The subscription already has Lag() — just need periodic checking and callback.

Requirements

  • Configurable threshold and check interval
  • Callback fires when lag exceeds threshold
  • Callback fires again when lag recovers (with recovered=true)
  • Test: simulate slow handler, verify callback fires
  • Zero overhead when not configured
## Problem If projections fall behind (slow Evolve, high write throughput), there is no signal. Projection lag grows silently until users notice stale data. ## Solution Add lag monitoring to subscription: ```go subscription.Config{ OnLagThreshold: func(lag uint64, consumer string) { slog.Warn("projection falling behind", "lag", lag, "consumer", consumer) metrics.Record("projection.lag", lag) }, LagThreshold: 1000, // fire when lag exceeds this LagCheckInterval: 10 * time.Second, } ``` The subscription already has `Lag()` — just need periodic checking and callback. ## Requirements - Configurable threshold and check interval - Callback fires when lag exceeds threshold - Callback fires again when lag recovers (with recovered=true) - Test: simulate slow handler, verify callback fires - Zero overhead when not configured
ash closed this issue 2026-03-01 16:17:29 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ash/eskit#146
No description provided.