- Remove ERRORS_BY_CLASS, ERRORS_BY_USER, REQUESTS_BY_USER (overengineered) - Add simple named counters per error type per endpoint: memory_error_auth_failure_ingest_total memory_error_forbidden_ingest_total memory_error_rate_limited_ingest_total memory_error_bad_request_ingest_total memory_error_db_error_ingest_total memory_error_auth_failure_query_total memory_error_forbidden_query_total memory_error_bad_request_query_total memory_error_embedding_failure_query_total memory_error_search_failure_query_total memory_error_auth_failure_context_total memory_error_forbidden_context_total memory_error_lookup_failure_context_total - LAST_ERROR_TIMESTAMP gauge for most recent error - 515 tests passing
This commit is contained in:
@@ -491,19 +491,17 @@ pub async fn ingest_handler(
|
||||
Err(e) => {
|
||||
INGEST_AUTH_FAILURES.inc();
|
||||
INGEST_ERRORS_TOTAL.inc();
|
||||
ERRORS_BY_USER.inc(&["unknown", "/memory/ingest", "auth_failure"]);
|
||||
ERROR_AUTH_FAILURE_INGEST.inc();
|
||||
INGEST_IN_FLIGHT.dec();
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
let user_id = &claims.sub;
|
||||
REQUESTS_BY_USER.inc(&[user_id, "/memory/ingest"]);
|
||||
|
||||
if !has_capability(&claims, "memory:write") {
|
||||
INGEST_AUTH_FAILURES.inc();
|
||||
INGEST_ERRORS_TOTAL.inc();
|
||||
ERRORS_BY_USER.inc(&[user_id, "/memory/ingest", "forbidden"]);
|
||||
ERROR_FORBIDDEN_INGEST.inc();
|
||||
INGEST_IN_FLIGHT.dec();
|
||||
return HttpResponse::Forbidden().json(json!({
|
||||
"error": "forbidden",
|
||||
@@ -512,7 +510,7 @@ pub async fn ingest_handler(
|
||||
}
|
||||
if let Err(e) = check_rate_limit(&claims, &state, "/memory/ingest") {
|
||||
INGEST_RATE_LIMITED.inc();
|
||||
ERRORS_BY_USER.inc(&[user_id, "/memory/ingest", "rate_limited"]);
|
||||
ERROR_RATE_LIMITED_INGEST.inc();
|
||||
INGEST_IN_FLIGHT.dec();
|
||||
return e;
|
||||
}
|
||||
@@ -1051,17 +1049,15 @@ pub async fn context_handler(
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
CONTEXT_ERRORS_TOTAL.inc();
|
||||
ERRORS_BY_USER.inc(&["unknown", "/memory/context", "auth_failure"]);
|
||||
ERROR_AUTH_FAILURE_CONTEXT.inc();
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
let user_id = &claims.sub;
|
||||
REQUESTS_BY_USER.inc(&[user_id, "/memory/context"]);
|
||||
|
||||
if !has_capability(&claims, "memory:read") {
|
||||
CONTEXT_ERRORS_TOTAL.inc();
|
||||
ERRORS_BY_USER.inc(&[user_id, "/memory/context", "forbidden"]);
|
||||
ERROR_FORBIDDEN_CONTEXT.inc();
|
||||
return HttpResponse::Forbidden().json(json!({
|
||||
"error": "forbidden",
|
||||
"reason": "missing capability: memory:read"
|
||||
@@ -1093,6 +1089,7 @@ pub async fn context_handler(
|
||||
}
|
||||
Err(e) => {
|
||||
CONTEXT_ERRORS_TOTAL.inc();
|
||||
ERROR_LOOKUP_FAILURE_CONTEXT.inc();
|
||||
tracing::error!("context lookup error: {}", e);
|
||||
HttpResponse::BadRequest().json(json!({
|
||||
"error": "lookup_failed",
|
||||
|
||||
Reference in New Issue
Block a user