fix(health): 危急值告警查询添加 tracing 错误日志
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

This commit is contained in:
iven
2026-05-01 17:43:05 +08:00
parent 4cde4acddc
commit 797c4e9e20

View File

@@ -191,14 +191,22 @@ pub async fn list_pending_alerts(
let total = query
.clone()
.count(&state.db)
.await?;
.await
.map_err(|e| {
tracing::error!(error = %e, %tenant_id, "查询危急值告警总数失败");
e
})?;
let items = query
.order_by(critical_alert::Column::CreatedAt, sea_orm::Order::Desc)
.offset(offset)
.limit(limit)
.all(&state.db)
.await?;
.await
.map_err(|e| {
tracing::error!(error = %e, %tenant_id, "查询危急值告警列表失败");
e
})?;
Ok((items, total))
}
@@ -211,7 +219,11 @@ pub async fn get_alert(
) -> HealthResult<critical_alert::Model> {
let alert = critical_alert::Entity::find_by_id(alert_id)
.one(&state.db)
.await?
.await
.map_err(|e| {
tracing::error!(error = %e, %alert_id, %tenant_id, "查询危急值告警详情失败");
e
})?
.ok_or(HealthError::CriticalAlertNotFound)?;
if alert.tenant_id != tenant_id {