Module insights

Module insights 

Source
Expand description

ML traffic insights (DW-092): EWMA-based capacity forecasting and seasonal-baseline anomaly detection over the live sketch window rotations.

The engine is hand-rolled (no ML crates — no hdrhistogram, no tdigest, no ML framework). It maintains two structures:

  • a recent ring buffer of completed sketch windows (BaselineWindow each), capped at baseline_windows entries, feeding an EWMA trend over the most recent observations; and
  • a minute-of-day seasonal pattern: a fixed 1440-entry ring (one per minute of the day) of running averages for requests, error rate, and latency, updated incrementally as windows rotate.

Forecasting combines the seasonal average for the NEXT minute with an EWMA trend adjustment derived from the recent ring. Anomaly detection compares the CURRENT window’s shape to the seasonal baseline for the same minute-of-day, flagging a window whose requests, error rate, or latency exceed the baseline by a configurable factor (default 2.0).

The engine lives inside crate::analytics::EmbeddedAnalytics and is fed by the live-sketch window rotation: when a sketch window expires, the completed window’s aggregates are handed to InsightsEngine::observe. Reads (forecast, anomaly) are admin-path only — never on the request hot path.

Structs§

AnomalyResult
The anomaly result returned by InsightsEngine::detect_anomaly.
BaselineWindow
One completed sketch window handed to the insights engine. A plain DTO — the live-sketch rotation constructs it from its per-route aggregates (summed across routes for the window-level shape).
ForecastResult
The forecast result returned by InsightsEngine::forecast.
InsightsEngine
The ML traffic insights engine (DW-092): in-process, hand-rolled EWMA forecasting and seasonal-baseline anomaly detection. Held inside crate::analytics::EmbeddedAnalytics behind an Arc and fed by the live-sketch window rotation.