feat: unexpected error counter + user_id in error logs
CI / CI (pull_request) Successful in 12m31s

- ERROR_UNEXPECTED_TOTAL: global unexpected error counter
- ERROR_UNEXPECTED_INGEST/QUERY/CONTEXT: per-endpoint unexpected errors
- All 500 error paths now increment unexpected counter
- Error logs include user_id for customer association:
  tracing::error!(user_id = claims.sub, "Unexpected error: ...")
- Covers: DB errors, search failures, temporal query failures
- 515 tests passing
This commit is contained in:
2026-09-13 22:17:06 +09:00
parent f5c6bf5e5d
commit 57c61b522b
3 changed files with 29 additions and 5 deletions
+6 -2
View File
@@ -581,7 +581,9 @@ async fn execute_ingest(
HttpResponse::Accepted().json(response)
}
Err(e) => {
tracing::error!("DB error: {}", e);
crate::metrics::ERROR_UNEXPECTED_INGEST.inc();
crate::metrics::ERROR_UNEXPECTED_TOTAL.inc();
tracing::error!(user_id = body.project.as_str(), "Unexpected DB error during ingest: {}", e);
HttpResponse::InternalServerError().json(json!({"error": "database_error"}))
}
}
@@ -905,7 +907,9 @@ pub async fn query_handler(
match query_temporal_graph(&state, &params).await {
Ok(response) => HttpResponse::Ok().json(response),
Err(e) => {
tracing::error!("Temporal graph query failed: {}", e);
crate::metrics::ERROR_UNEXPECTED_QUERY.inc();
crate::metrics::ERROR_UNEXPECTED_TOTAL.inc();
tracing::error!(user_id = claims.sub.as_str(), "Unexpected error: temporal graph query failed: {}", e);
HttpResponse::InternalServerError().json(json!({"error": "query_failed", "reason": e.to_string()}))
}
}