Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3340408
D13394.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D13394.diff
View Options
diff --git a/services/blob/src/constants.rs b/services/blob/src/constants.rs
--- a/services/blob/src/constants.rs
+++ b/services/blob/src/constants.rs
@@ -42,3 +42,12 @@
pub const S3_MULTIPART_UPLOAD_MINIMUM_CHUNK_SIZE: u64 = 5 * 1024 * 1024;
pub const INVITE_LINK_BLOB_HASH_PREFIX: &str = "invite_";
+
+// Error Types
+
+pub mod error_types {
+ pub const S3_ERROR: &str = "S3 Error";
+ pub const DDB_ERROR: &str = "DDB Error";
+ pub const HTTP_ERROR: &str = "HTTP Error";
+ pub const OTHER_ERROR: &str = "Other Error";
+}
diff --git a/services/blob/src/database/client.rs b/services/blob/src/database/client.rs
--- a/services/blob/src/database/client.rs
+++ b/services/blob/src/database/client.rs
@@ -14,6 +14,7 @@
use tracing::{debug, error, trace};
use crate::constants::db::*;
+use crate::constants::error_types;
use super::errors::{BlobDBError, Error as DBError};
use super::types::*;
@@ -205,7 +206,10 @@
.send()
.await
.map_err(|err| {
- error!("DynamoDB client failed to query holders: {:?}", err);
+ error!(
+ errorType = error_types::DDB_ERROR,
+ "DynamoDB client failed to query holders: {:?}", err
+ );
DBError::AwsSdk(Box::new(err.into()))
})?;
@@ -274,7 +278,10 @@
.send()
.await
.map_err(|err| {
- error!("DynamoDB client failed to query unchecked items: {:?}", err);
+ error!(
+ errorType = error_types::DDB_ERROR,
+ "DynamoDB client failed to query unchecked items: {:?}", err
+ );
DBError::AwsSdk(Box::new(err.into()))
})?;
diff --git a/services/blob/src/http/errors.rs b/services/blob/src/http/errors.rs
--- a/services/blob/src/http/errors.rs
+++ b/services/blob/src/http/errors.rs
@@ -7,6 +7,7 @@
use http::StatusCode;
use tracing::{debug, error, trace, warn};
+use crate::constants::error_types;
use crate::database::errors::{BlobDBError, Error as DBError};
use crate::s3::Error as S3Error;
use crate::service::BlobServiceError;
@@ -28,7 +29,10 @@
ErrorServiceUnavailable("please retry")
}
unexpected => {
- error!("Received an unexpected AWS error: {0:?} - {0}", unexpected);
+ error!(
+ errorType = error_types::OTHER_ERROR,
+ "Received an unexpected AWS error: {0:?} - {0}", unexpected
+ );
ErrorInternalServerError("server error")
}
},
@@ -36,24 +40,36 @@
ErrorBadRequest("bad request")
}
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")
}
},
BlobServiceError::S3(s3_err) => match s3_err {
S3Error::AwsSdk(aws_err) => match aws_err.as_ref() {
aws_sdk_s3::Error::NotFound(_) | aws_sdk_s3::Error::NoSuchKey(_) => {
- error!("Data inconsistency! Blob is present in database but not present in S3!");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "Data inconsistency! Blob is present in database but not present in S3!"
+ );
ErrorInternalServerError("server error")
}
err => {
- error!("Received an unexpected AWS S3 error: {0:?} - {0}", err);
+ error!(
+ errorType = error_types::S3_ERROR,
+ "Received an unexpected AWS S3 error: {0:?} - {0}", err
+ );
ErrorInternalServerError("server error")
}
},
S3Error::EmptyUpload => ErrorBadRequest("empty upload"),
unexpected => {
- error!("Received an unexpected S3 error: {0:?} - {0}", unexpected);
+ error!(
+ errorType = error_types::S3_ERROR,
+ "Received an unexpected S3 error: {0:?} - {0}", unexpected
+ );
ErrorInternalServerError("server error")
}
},
@@ -66,7 +82,10 @@
ErrorBadRequest("bad request")
}
err => {
- error!("Received an unexpected error: {0:?} - {0}", err);
+ error!(
+ errorType = error_types::OTHER_ERROR,
+ "Received an unexpected error: {0:?} - {0}", err
+ );
ErrorInternalServerError("server error")
}
}
diff --git a/services/blob/src/s3.rs b/services/blob/src/s3.rs
--- a/services/blob/src/s3.rs
+++ b/services/blob/src/s3.rs
@@ -7,6 +7,8 @@
use std::ops::{Bound, RangeBounds};
use tracing::{debug, error, trace};
+use crate::constants::error_types;
+
#[derive(
Debug, derive_more::Display, derive_more::From, derive_more::Error,
)]
@@ -132,7 +134,10 @@
.send()
.await
.map_err(|e| {
- error!("S3 failed to get object metadata");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "S3 failed to get object metadata"
+ );
Error::AwsSdk(Box::new(e.into()))
})?;
@@ -171,11 +176,14 @@
}
let response = request.send().await.map_err(|e| {
- error!("S3 failed to get object");
+ error!(errorType = error_types::S3_ERROR, "S3 failed to get object");
Error::AwsSdk(Box::new(e.into()))
})?;
let data = response.body.collect().await.map_err(|e| {
- error!("S3 failed to stream object bytes");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "S3 failed to stream object bytes"
+ );
Error::ByteStream(e.into())
})?;
Ok(data.to_vec())
@@ -191,7 +199,10 @@
.send()
.await
.map_err(|e| {
- error!("S3 failed to delete object");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "S3 failed to delete object"
+ );
Error::AwsSdk(Box::new(e.into()))
})?;
@@ -228,7 +239,10 @@
.send()
.await
.map_err(|e| {
- error!("S3 failed to batch delete objects");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "S3 failed to batch delete objects"
+ );
Error::AwsSdk(Box::new(e.into()))
})?;
@@ -259,12 +273,18 @@
.send()
.await
.map_err(|e| {
- error!("S3 failed to start upload session");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "S3 failed to start upload session"
+ );
Error::AwsSdk(Box::new(e.into()))
})?;
let upload_id = multipart_upload_res.upload_id().ok_or_else(|| {
- error!("Upload ID expected to be present");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "Upload ID expected to be present"
+ );
Error::MissingUploadID
})?;
debug!("Started multipart upload session with ID: {}", upload_id);
@@ -293,7 +313,10 @@
.send()
.await
.map_err(|e| {
- error!("Failed to add upload part");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "Failed to add upload part"
+ );
Error::AwsSdk(Box::new(e.into()))
})?;
@@ -331,7 +354,10 @@
.send()
.await
.map_err(|e| {
- error!("Failed to finish upload session");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "Failed to finish upload session"
+ );
Error::AwsSdk(Box::new(e.into()))
})?;
diff --git a/services/blob/src/service.rs b/services/blob/src/service.rs
--- a/services/blob/src/service.rs
+++ b/services/blob/src/service.rs
@@ -24,7 +24,10 @@
use crate::database::DBError;
use crate::s3::{Error as S3Error, S3Client, S3Path};
use crate::tools::MemOps;
-use crate::{constants::BLOB_DOWNLOAD_CHUNK_SIZE, database::DatabaseClient};
+use crate::{
+ constants::error_types, constants::BLOB_DOWNLOAD_CHUNK_SIZE,
+ database::DatabaseClient,
+};
#[derive(
Debug, derive_more::Display, derive_more::From, derive_more::Error,
@@ -120,14 +123,20 @@
let blob_size = object_metadata
.content_length()
.ok_or_else(|| {
- error!("Failed to get S3 object content length");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "Failed to get S3 object content length"
+ );
BlobServiceError::InvalidState
})
.and_then(|len| {
if len >= 0 {
Ok(len as u64)
} else {
- error!("S3 object content length is negative");
+ error!(
+ errorType = error_types::S3_ERROR,
+ "S3 object content length is negative"
+ );
Err(BlobServiceError::InvalidState)
}
})?;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 9:45 PM (16 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2565364
Default Alt Text
D13394.diff (8 KB)
Attached To
Mode
D13394: [blob] add errorType to tracing error logs
Attached
Detach File
Event Timeline
Log In to Comment