async fn check_metrics(monitor: &Monitor, app_state: &AppState) -> Result<AlertResult> {
	let current_training_value =
		find_current_training_metric(monitor.threshold.metric, monitor.model_id, app_state).await?;
	let mut txn = app_state.begin_transaction().await?;
	let current_production_value =
		get_production_metric(monitor.threshold.metric, monitor.model_id, txn.borrow_mut()).await?;
	if current_production_value.is_none() {
		return Err(anyhow!("Unable to find production metric value"));
	}
	let current_production_value = current_production_value.unwrap();
	let observed_difference = match monitor.threshold.mode {
		MonitorThresholdMode::Absolute => current_production_value - current_training_value,
		MonitorThresholdMode::Percentage => {
			((current_production_value - current_training_value) / current_training_value) * 100.0
		}
	};
	let result = AlertResult {
		metric: monitor.threshold.metric,
		production_value: current_production_value,
		training_value: current_training_value,
		difference: observed_difference,
	};
	// Update monitor last-checked time
	monitor
		.update_timestamp(txn.borrow_mut(), &app_state.clock)
		.await?;
	app_state.commit_transaction(txn).await?;
	Ok(result)
}
/// Return the current observed values for each heuristic
Return the current observed values for each heuristic
Return the current observed values for each heuristic
async fn check_metrics(monitor: &Monitor, app_state: &AppState) -> Result<AlertResult> {
	let current_training_value =
		find_current_training_metric(monitor.threshold.metric, monitor.model_id, app_state).await?;
	let mut txn = app_state.begin_transaction().await?;
	let current_production_value =
		get_production_metric(monitor.threshold.metric, monitor.model_id, txn.borrow_mut()).await?;
	if current_production_value.is_none() {
		return Err(anyhow!("Unable to find production metric value"));
	}
	let current_production_value = current_production_value.unwrap();
	let observed_difference = match monitor.threshold.mode {
		MonitorThresholdMode::Absolute => current_production_value - current_training_value,
		MonitorThresholdMode::Percentage => {
			((current_production_value - current_training_value) / current_training_value) * 100.0
		}
	};
	let result = AlertResult {
		metric: monitor.threshold.metric,
		production_value: current_production_value,
		training_value: current_training_value,
		difference: observed_difference,
	};
	// Update monitor last-checked time
	monitor
		.update_timestamp(txn.borrow_mut(), &app_state.clock)
		.await?;
	app_state.commit_transaction(txn).await?;
	Ok(result)
}
async fn check_metrics ( monitor : & Monitor , app_state : & AppState ) -> Result < AlertResult > { let current_training_value = find_current_training_metric ( monitor . threshold . metric , monitor . model_id , app_state ) . await ? ; let mut txn = app_state . begin_transaction ( ) . await ? ; let current_production_value = get_production_metric ( monitor . threshold . metric , monitor . model_id , txn . borrow_mut ( ) ) . await ? ; if current_production_value . is_none ( ) { return Err ( anyhow ! ( " " ) ) ; } let current_production_value = current_production_value . unwrap ( ) ; let observed_difference = match monitor . threshold . mode { MonitorThresholdMode :: Absolute => current_production_value - current_training_value , MonitorThresholdMode :: Percentage => { ( ( current_production_value - current_training_value ) / current_training_value ) * 100.0 } } ; let result = AlertResult { metric : monitor . threshold . metric , production_value : current_production_value , training_value : current_training_value , difference : observed_difference , } ; // Update monitor last-checked time monitor . update_timestamp ( txn . borrow_mut ( ) , & app_state . clock ) . await ? ; app_state . commit_transaction ( txn ) . await ? ; Ok ( result ) }
Return the current observed values for each heuristic
Return the current observed values for each heuristic
monitor
&Monitor
app_state
&AppState