Module Algostream_normalization.Feed_health

Per-feed (per-source) health tracker.

Wraps Time_utils.LatencyMonitor in a hashtable keyed by Event.t.source (e.g. "binance", "coinbase"). Tracks tick rate, last-tick-age, p99 ingest-to-handler latency, and gap counts. Hashtable is capped at 64 keys (LRU eviction) to bound DoS via spoofed source strings in third-party replay logs.

type t
val create : ?max_sources:int -> unit -> t
val observe : t -> source:string -> ts_ns:int64 -> latency_ns:int64 -> unit

Record a tick observation for source at event-time ts_ns; latency_ns is the publish-to-this-call delay in nanoseconds.

val record_gap : t -> source:string -> unit

Increment the gap counter for source.

type per_source_stats = {
  1. source : string;
  2. ticks : int64;
  3. gaps : int64;
  4. last_event_ts_ns : int64;
  5. avg_latency_ns : int64;
  6. max_latency_ns : int64;
}
val per_source : t -> source:string -> per_source_stats option
val all : t -> per_source_stats list
val active_count : t -> int