Skip to content

Commit 2e52c7e

Browse files
nipunn1313Convex, Inc.
authored andcommitted
Improve classification of ResourceExhausted for usher (#41054)
We are seeing a high volume of this error on sentry. Reclassifying should allow us to sample (overloaded errors are sampled) and greatly reduce volume. GitOrigin-RevId: 53980fbb4600afb365c56778b7a541fc10846b97
1 parent a829eb2 commit 2e52c7e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/pb/src/error_metadata.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use anyhow::Context;
44
use errors::{
55
ErrorCode,
66
ErrorMetadata,
7+
INTERNAL_SERVER_ERROR,
8+
INTERNAL_SERVER_ERROR_MSG,
79
};
810
use prost::Message;
911

@@ -138,6 +140,7 @@ impl ErrorMetadataStatusExt for tonic::Status {
138140
}
139141

140142
fn into_anyhow(self) -> anyhow::Error {
143+
let code = self.code();
141144
let details = match StatusDetailsProto::decode(self.details()) {
142145
Ok(details) => details,
143146
Err(err) => {
@@ -153,6 +156,11 @@ impl ErrorMetadataStatusExt for tonic::Status {
153156
error = error.context(error_metadata)
154157
} else if error.downcast_ref::<tonic::transport::Error>().is_some() {
155158
error = error.context(ErrorMetadata::operational_internal_server_error());
159+
} else if code == tonic::Code::ResourceExhausted {
160+
error = error.context(ErrorMetadata::overloaded(
161+
INTERNAL_SERVER_ERROR,
162+
INTERNAL_SERVER_ERROR_MSG,
163+
));
156164
}
157165
error
158166
}

0 commit comments

Comments
 (0)