MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / effective_sample_rate

Function effective_sample_rate

src/adapter/src/statement_logging.rs:726–737  ·  view source on GitHub ↗

The effective rate at which statement execution should be sampled. This is the value of the session var `statement_logging_sample_rate`, constrained by the system var `statement_logging_max_sample_rate`.

(session: &Session, system_vars: &SystemVars)

Source from the content-addressed store, hash-verified

724/// This is the value of the session var `statement_logging_sample_rate`,
725/// constrained by the system var `statement_logging_max_sample_rate`.
726pub(crate) fn effective_sample_rate(session: &Session, system_vars: &SystemVars) -> f64 {
727 let system_max: f64 = system_vars
728 .statement_logging_max_sample_rate()
729 .try_into()
730 .expect("value constrained to be convertible to f64");
731 let user_rate: f64 = session
732 .vars()
733 .get_statement_logging_sample_rate()
734 .try_into()
735 .expect("value constrained to be convertible to f64");
736 f64::min(system_max, user_rate)
737}
738
739/// Helper function to decide whether to sample a statement execution.
740/// Returns `true` if the statement should be sampled based on the sample rate.

Callers 2

Calls 5

expectMethod · 0.80
try_intoMethod · 0.45
varsMethod · 0.45

Tested by

no test coverage detected