do_memory_mcp/server/tools/
monitoring.rs1use anyhow::Result;
6
7impl crate::server::MemoryMCPServer {
8 pub async fn health_check(&self) -> Result<serde_json::Value> {
14 self.track_tool_usage("health_check").await;
15
16 let request_id = format!(
18 "health_check_{}",
19 std::time::SystemTime::now()
20 .duration_since(std::time::UNIX_EPOCH)
21 .unwrap_or_default()
22 .as_nanos()
23 );
24 self.monitoring
25 .start_request(request_id.clone(), "health_check".to_string())
26 .await;
27
28 let result = self.monitoring_endpoints.health_check().await?;
29
30 self.monitoring.end_request(&request_id, true, None).await;
32
33 Ok(result)
34 }
35
36 pub async fn get_metrics(&self, metric_type: Option<String>) -> Result<serde_json::Value> {
46 self.track_tool_usage("get_metrics").await;
47
48 let request_id = format!(
50 "get_metrics_{}",
51 std::time::SystemTime::now()
52 .duration_since(std::time::UNIX_EPOCH)
53 .unwrap_or_default()
54 .as_nanos()
55 );
56 self.monitoring
57 .start_request(request_id.clone(), "get_metrics".to_string())
58 .await;
59
60 let result = match metric_type.as_deref() {
61 Some("performance") => self.monitoring_endpoints.performance_metrics().await,
62 Some("episodes") => self.monitoring_endpoints.episode_metrics().await,
63 Some("system") => self.monitoring_endpoints.system_info().await,
64 _ => self.monitoring_endpoints.metrics().await,
65 };
66
67 self.monitoring
69 .end_request(&request_id, result.is_ok(), None)
70 .await;
71
72 result
73 }
74}