Skip to content

Commit

Permalink
Logging internal server error causes. (#5132)
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton authored Jun 17, 2024
1 parent 0555978 commit 74ac88e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions quickwit/quickwit-serve/src/elasticsearch_api/model/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use elasticsearch_dsl::search::ErrorCause;
use hyper::StatusCode;
use quickwit_common::{rate_limited_debug, rate_limited_error};
use quickwit_index_management::IndexServiceError;
use quickwit_ingest::IngestServiceError;
use quickwit_proto::ingest::IngestV2Error;
Expand All @@ -39,6 +40,11 @@ impl ElasticsearchError {
reason: String,
exception_opt: Option<ErrorCauseException>,
) -> Self {
if status.is_server_error() {
rate_limited_error!(limit_per_min=10, status=%status, "http request failed with internal server error: {}", reason);
} else if !status.is_success() {
rate_limited_debug!(limit_per_min=10, status=%status, "http request failed: {}", reason);
}
ElasticsearchError {
status,
error: ErrorCause {
Expand Down
16 changes: 11 additions & 5 deletions quickwit/quickwit-serve/src/rest_api_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,17 @@ impl Reply for RestApiResponse {
*response.status_mut() = self.status_code;
response
}
Err(()) => warp::reply::json(&RestApiError {
status_code: StatusCode::INTERNAL_SERVER_ERROR,
message: JSON_SERIALIZATION_ERROR.to_string(),
})
.into_response(),
Err(()) => {
quickwit_common::rate_limited_error!(
limit_per_min = 10,
"REST body json serialization error."
);
warp::reply::json(&RestApiError {
status_code: StatusCode::INTERNAL_SERVER_ERROR,
message: JSON_SERIALIZATION_ERROR.to_string(),
})
.into_response()
}
}
}
}

0 comments on commit 74ac88e

Please sign in to comment.