pub struct AnalyticsConfig {
pub path: String,
pub flush_ms: Option<u64>,
pub retention: Option<AnalyticsRetention>,
pub dimensions: Vec<AnalyticsDimension>,
pub exports: Option<AnalyticsExports>,
pub live_sketches: Option<AnalyticsLiveSketches>,
pub insights: Option<AnalyticsInsights>,
pub replay_capture: Option<AnalyticsReplayCapture>,
pub sampled_degradation: Option<AnalyticsSampledDegradation>,
}Expand description
The embedded analytics store config (DW-043, gateway.analytics).
Fields§
§path: StringFilesystem path of the analytics SQLite database. The file is created (and migrated) on first open. A separate file from the state store on purpose: retention deletes and incremental vacuum churn must never compact the identity store.
flush_ms: Option<u64>Maximum batch latency of the background writer, in milliseconds (default 1000; validated to [100, 60 000]). Not a correctness knob — the rollup grace covers multiples of this.
retention: Option<AnalyticsRetention>Per-store retention, in milliseconds (defaults: raw 24 h, 1m 48 h, 5m 7 d, 1h 30 d, 1d 365 d). Validation enforces each floor (a granularity must outlive its own window comfortably) and monotonicity (no coarser table may expire before a finer one).
dimensions: Vec<AnalyticsDimension>Custom dimensions (DW-043): request-header-sourced tags that
become analytics dimensions — x-plan as dimension plan,
for consumer tier / plan / feature-flag style cuts the fixed
dimensions cannot express. Extracted at request completion
capture; analytics-only (never added to the access log). At
most 16 (cardinality guard); values are capped at 128 bytes
(longer values are skipped for that request).
exports: Option<AnalyticsExports>Scheduled usage-report exports (DW-120): durable CSV/JSON
dumps of the per-consumer usage statement, one file set per
closed UTC calendar window, written by a background worker
that reuses the analytics store’s scheduling machinery. Absent
(the default): no exports run and the admin export endpoints
answer that exports are not configured. See the
analytics::exports module docs for the schedule, the
statement’s reconciliation contract with the query API, and
the quota-column window-alignment rule.
live_sketches: Option<AnalyticsLiveSketches>Live in-process sketches (DW-092): sub-second-freshness
aggregation maintained synchronously on the request-completion
hot path (per-route rolling window with counts, errors, and
latency samples). Never blocks the dataplane — the sketch is
updated in place under atomics and a short mutex over a capped
sample vector. Absent (the default): no live sketches; the
GET /analytics/live endpoint answers
analytics_not_configured.
insights: Option<AnalyticsInsights>ML traffic insights (DW-092): EWMA-based capacity forecasting
and seasonal-baseline anomaly detection over the live sketch
window rotations. The insights engine is in-process and
hand-rolled (no ML crates): a minute-of-day ring buffer holds
the seasonal pattern, an EWMA over recent windows carries the
trend, and anomaly detection compares the current window’s
shape to the seasonal baseline. Absent (the default): no
forecasting or anomaly detection; the
GET /analytics/forecast and GET /analytics/anomalies
endpoints answer analytics_not_configured.
replay_capture: Option<AnalyticsReplayCapture>Replay time-travel debugging capture (DW-102): opt-in capture of
request detail (redacted headers, auth identity) into the raw
analytics table for offline replay against candidate configs.
Absent (the default): no replay capture; the raw table’s
request_headers_redacted and auth_identity columns stay
NULL. When present with enabled: true, the fire-and-forget
analytics writer records the redacted headers and auth identity
alongside the existing access fields, bounded by retain_hours.
See AnalyticsReplayCapture.
sampled_degradation: Option<AnalyticsSampledDegradation>REL-10 (#221): sampled degradation under channel pressure. When
the analytics channel’s fill ratio exceeds high_watermark,
the offer path probabilistically drops records (keeping 1 in
sample_rate) BEFORE the channel fills, so a sustained burst
degrades to sampled telemetry rather than a hard drop cliff.
Below low_watermark every record is kept. Defaults to off
(no sampling); when enabled, high_watermark must be >
low_watermark and both are in (0.0, 1.0].
Trait Implementations§
Source§impl Clone for AnalyticsConfig
impl Clone for AnalyticsConfig
Source§fn clone(&self) -> AnalyticsConfig
fn clone(&self) -> AnalyticsConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AnalyticsConfig
impl Debug for AnalyticsConfig
Source§impl<'de> Deserialize<'de> for AnalyticsConfig
impl<'de> Deserialize<'de> for AnalyticsConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for AnalyticsConfig
impl JsonSchema for AnalyticsConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for AnalyticsConfig
impl PartialEq for AnalyticsConfig
Source§impl Serialize for AnalyticsConfig
impl Serialize for AnalyticsConfig
impl StructuralPartialEq for AnalyticsConfig
Auto Trait Implementations§
impl Freeze for AnalyticsConfig
impl RefUnwindSafe for AnalyticsConfig
impl Send for AnalyticsConfig
impl Sync for AnalyticsConfig
impl Unpin for AnalyticsConfig
impl UnwindSafe for AnalyticsConfig
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more