feat(api): add api_uptime_seconds metric, replace web-gateway panels in cockpit
- Add api_uptime_seconds gauge to API service (5s update interval), matching the pattern used by trading/backtesting/ml-training services - Remove obsolete Web Gateway Uptime and Active WebSocket Connections panels from cockpit (web-gateway is not deployed) - Add API Gateway Uptime (api_uptime_seconds) and API Auth Rate (api_auth_requests_total) panels in their place Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -543,6 +543,22 @@ async fn main() -> Result<()> {
|
||||
.map_err(|e| anyhow::anyhow!("Failed to register service info: {}", e))?;
|
||||
service_info.set(1.0);
|
||||
|
||||
// Add uptime gauge (matches pattern of other services)
|
||||
let uptime_gauge = register_gauge_with_registry!(
|
||||
Opts::new("api_uptime_seconds", "API service uptime in seconds"),
|
||||
gateway_metrics.registry().as_ref()
|
||||
)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to register uptime gauge: {}", e))?;
|
||||
let start_instant = std::time::Instant::now();
|
||||
let uptime_clone = uptime_gauge.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut tick = tokio::time::interval(Duration::from_secs(5));
|
||||
loop {
|
||||
tick.tick().await;
|
||||
uptime_clone.set(start_instant.elapsed().as_secs_f64());
|
||||
}
|
||||
});
|
||||
|
||||
let metrics_registry = gateway_metrics.registry();
|
||||
|
||||
tokio::spawn(async move {
|
||||
|
||||
Reference in New Issue
Block a user