// pub struct ContextMetrics {
//     total_runs: AtomicU64,
//     successful_runs: AtomicU64,
//     failed_runs: AtomicU64,
//     total_duration_ms: AtomicU64,
// }
//
// impl ContextMetrics {
//     /// Returns the total number of runs attempted.
//     pub fn total_runs(&self) -> u64 {
//         self.total_runs.load(Ordering::Relaxed)
//     }
//
//     /// Returns the number of successful runs.
//     pub fn successful_runs(&self) -> u64 {
//         self.successful_runs.load(Ordering::Relaxed)
//     }
//
//     /// Returns the number of failed runs.
//     pub fn failed_runs(&self) -> u64 {
//         self.failed_runs.load(Ordering::Relaxed)
//     }
//
//     /// Returns the average duration of all runs in milliseconds.
//     pub fn avg_duration_ms(&self) -> f64 {
//         let total = self.total_runs.load(Ordering::Relaxed);
//         if total == 0 {
//             return 0.0;
//         }
//         let duration = self.total_duration_ms.load(Ordering::Relaxed);
//         duration as f64 / total as f64
//     }
//
//     fn record_run(&self, duration: Duration, success: bool) {
//         self.total_runs.fetch_add(1, Ordering::Relaxed);
//         if success {
//             self.successful_runs.fetch_add(1, Ordering::Relaxed);
//         } else {
//             self.failed_runs.fetch_add(1, Ordering::Relaxed);
//         }
//         self.total_duration_ms
//             .fetch_add(duration.as_millis() as u64, Ordering::Relaxed);
//     }
// }
//
// /// Result of a contextold execution.
// ///
// /// Contains metadata about the execution for observability.
// #[derive(Debug, Clone)]
// pub struct ExecutionResult {
//     /// Total duration of the execution.
//     pub duration: Duration,
//     // // Number of items processed during execution.
//     // pub processed_items: usize, // TODO: not sure if this is required.
// }
// #[instrument(skip(self))]
// pub async fn shutdown(self) -> Result<()> {
//     // info!("Shutting down contextold");
//     //
//     // // Try to get exclusive access to mcp_clients for shutdown
//     // match Arc::try_unwrap(self.mcp_clients) {
//     //     Ok(clients) => {
//     //         clients
//     //             .close_all()
//     //             .await
//     //             .map_err(|e| ContextError::ShutdownFailed(e.to_string()))?;
//     //         info!("All MCP connections closed successfully");
//     //     }
//     //     Err(arc) => {
//     //         warn!(
//     //             "Cannot shutdown - {} other references to MCP clients exist",
//     //             Arc::strong_count(&arc) - 1
//     //         );
//     //         return Err(ContextError::ShutdownFailed(
//     //             "Cannot shutdown while other references exist".to_string(),
//     //         ));
//     //     }
//     // }
//
//     Ok(())
// }
