Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3512590
D13942.id45838.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D13942.id45838.diff
View Options
diff --git a/services/backup/src/constants.rs b/services/backup/src/constants.rs
--- a/services/backup/src/constants.rs
+++ b/services/backup/src/constants.rs
@@ -43,3 +43,12 @@
pub const ATTACHMENTS: &str = "attachments";
}
}
+
+// Error Types
+
+pub mod error_types {
+ pub const DDB_ERROR: &str = "DDB Error";
+ pub const AUTH_ERROR: &str = "Auth Error";
+ pub const BLOB_ERROR: &str = "Blob Error";
+ pub const WS_ERROR: &str = "WS Error";
+}
diff --git a/services/backup/src/database/mod.rs b/services/backup/src/database/mod.rs
--- a/services/backup/src/database/mod.rs
+++ b/services/backup/src/database/mod.rs
@@ -5,7 +5,9 @@
backup_item::{BackupItem, OrderedBackupItem},
log_item::LogItem,
};
-use crate::constants::{backup_table, log_table, LOG_DEFAULT_PAGE_SIZE};
+use crate::constants::{
+ backup_table, error_types, log_table, LOG_DEFAULT_PAGE_SIZE,
+};
use aws_sdk_dynamodb::{
operation::get_item::GetItemOutput,
types::{AttributeValue, DeleteRequest, ReturnValue, WriteRequest},
@@ -48,7 +50,10 @@
.send()
.await
.map_err(|e| {
- error!("DynamoDB client failed to put backup item");
+ error!(
+ errorType = error_types::DDB_ERROR,
+ "DynamoDB client failed to put backup item"
+ );
Error::AwsSdk(e.into())
})?;
@@ -70,7 +75,10 @@
.send()
.await
.map_err(|e| {
- error!("DynamoDB client failed to find backup item");
+ error!(
+ errorType = error_types::DDB_ERROR,
+ "DynamoDB client failed to find backup item"
+ );
Error::AwsSdk(e.into())
})?;
@@ -112,7 +120,10 @@
.send()
.await
.map_err(|e| {
- error!("DynamoDB client failed to remove backup item");
+ error!(
+ errorType = error_types::DDB_ERROR,
+ "DynamoDB client failed to remove backup item"
+ );
Error::AwsSdk(e.into())
})?;
@@ -191,7 +202,10 @@
.send()
.await
.map_err(|e| {
- error!("DynamoDB client failed to put log item");
+ error!(
+ errorType = error_types::DDB_ERROR,
+ "DynamoDB client failed to put log item"
+ );
Error::AwsSdk(e.into())
})?;
@@ -238,7 +252,10 @@
}
let response = query.send().await.map_err(|e| {
- error!("DynamoDB client failed to fetch logs");
+ error!(
+ errorType = error_types::DDB_ERROR,
+ "DynamoDB client failed to fetch logs"
+ );
Error::AwsSdk(e.into())
})?;
@@ -346,7 +363,10 @@
.send()
.await
.map_err(|e| {
- error!("DynamoDB client failed to fetch backups");
+ error!(
+ errorType = error_types::DDB_ERROR,
+ "DynamoDB client failed to fetch backups"
+ );
Error::AwsSdk(e.into())
})?;
diff --git a/services/backup/src/error.rs b/services/backup/src/error.rs
--- a/services/backup/src/error.rs
+++ b/services/backup/src/error.rs
@@ -12,6 +12,8 @@
use reqwest::StatusCode;
use tracing::{error, trace, warn};
+use crate::constants::error_types;
+
#[derive(
Debug, derive_more::Display, derive_more::From, derive_more::Error,
)]
@@ -49,11 +51,17 @@
BackupError::BlobError(
err @ (BlobServiceError::URLError(_) | BlobServiceError::NotFound),
) => {
- error!("Unexpected blob error: {err}");
+ error!(
+ errorType = error_types::BLOB_ERROR,
+ "Unexpected blob error: {err}"
+ );
ErrorInternalServerError("server error")
}
BackupError::AuthError(err) => {
- error!("Unexpected auth error: {err}");
+ error!(
+ errorType = error_types::AUTH_ERROR,
+ "Unexpected auth error: {err}"
+ );
ErrorInternalServerError("server error")
}
BackupError::DB(err) => match err {
@@ -66,7 +74,10 @@
ErrorServiceUnavailable("please retry")
}
unexpected => {
- error!("Received an unexpected DB error: {0:?} - {0}", unexpected);
+ error!(
+ errorType = error_types::DDB_ERROR,
+ "Received an unexpected DB error: {0:?} - {0}", unexpected
+ );
ErrorInternalServerError("server error")
}
},
diff --git a/services/backup/src/http/handlers/log.rs b/services/backup/src/http/handlers/log.rs
--- a/services/backup/src/http/handlers/log.rs
+++ b/services/backup/src/http/handlers/log.rs
@@ -1,4 +1,4 @@
-use crate::constants::WS_FRAME_SIZE;
+use crate::constants::{error_types, WS_FRAME_SIZE};
use crate::database::{log_item::LogItem, DatabaseClient};
use actix::fut::ready;
use actix::{Actor, ActorContext, ActorFutureExt, AsyncContext, StreamHandler};
@@ -109,7 +109,7 @@
);
}
Err(err) => {
- error!("Error: {err:?}");
+ error!(errorType = error_types::WS_ERROR, "Error: {err:?}");
Self::spawn_response_future(
ctx,
@@ -130,7 +130,7 @@
let responses = match responses {
Ok(responses) => responses,
Err(err) => {
- error!("Error: {err:?}");
+ error!(errorType = error_types::WS_ERROR, "Error: {err:?}");
vec![LogWSResponse::ServerError]
}
};
@@ -140,6 +140,7 @@
Ok(bytes) => ctx.binary(bytes),
Err(error) => {
error!(
+ errorType = error_types::WS_ERROR,
"Error serializing a response: {response:?}. Error: {error}"
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 8:28 PM (17 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692377
Default Alt Text
D13942.id45838.diff (5 KB)
Attached To
Mode
D13942: [backup] add errorType to error logs in backup
Attached
Detach File
Event Timeline
Log In to Comment