pub struct AbExperiment {
pub name: String,
pub variants: Vec<ExperimentVariant>,
/* private fields */
}Expand description
An A/B experiment that routes traffic between template variants.
Fields§
§name: String§variants: Vec<ExperimentVariant>Implementations§
Source§impl AbExperiment
impl AbExperiment
Sourcepub fn pick_variant(&self, rand_0_1: f64) -> usize
pub fn pick_variant(&self, rand_0_1: f64) -> usize
Select a variant index using a [0.0, 1.0) uniform random draw.
Pass a caller-supplied random value so callers can use any PRNG.
Sourcepub fn record_request(&self, idx: usize)
pub fn record_request(&self, idx: usize)
Record that a request was routed to variant idx.
Sourcepub fn record_success(&self, idx: usize, latency_ms: u64, quality: f64)
pub fn record_success(&self, idx: usize, latency_ms: u64, quality: f64)
Record a successful response for variant idx.
Sourcepub fn metrics(&self) -> Vec<VariantMetrics>
pub fn metrics(&self) -> Vec<VariantMetrics>
Return a snapshot of all variant metrics.
Sourcepub fn leading_variant(&self) -> Option<usize>
pub fn leading_variant(&self) -> Option<usize>
Return the index of the leading variant by quality score.
Returns None if no successes have been recorded.
Sourcepub fn significance(&self, a: usize, b: usize) -> Option<f64>
pub fn significance(&self, a: usize, b: usize) -> Option<f64>
Two-proportion Z-test p-value between variants a and b (success rate).
Returns None if sample sizes are insufficient (< 30 per variant).
Sourcepub fn report(&self) -> ExperimentReport
pub fn report(&self) -> ExperimentReport
Summary report for logging / monitoring.
Auto Trait Implementations§
impl Freeze for AbExperiment
impl RefUnwindSafe for AbExperiment
impl Send for AbExperiment
impl Sync for AbExperiment
impl Unpin for AbExperiment
impl UnsafeUnpin for AbExperiment
impl UnwindSafe for AbExperiment
Blanket Implementations§
Source§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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request