Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement (aws_s3 source): Logs processed S3 objects #22083

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/21128_log_aws_s3_objects_consumed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
`aws_s3` source now logs s3 objects fetched (and completed if acks are enabled on the sink)

authors: fdamstra
39 changes: 37 additions & 2 deletions src/sources/aws_s3/sqs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ impl IngestorProcess {
message_id: &message_id
});
if self.state.delete_message {
trace!(
message = "Queued SQS message for deletion",
id = message_id,
receipt_handle = receipt_handle,
);
delete_entries.push(
DeleteMessageBatchRequestEntry::builder()
.id(message_id)
Expand Down Expand Up @@ -517,6 +522,12 @@ impl IngestorProcess {

let object = object_result?;

info!(
message = "Got S3 object from SQS notification.",
bucket = s3_event.s3.bucket.name,
key = s3_event.s3.object.key
);

let metadata = object.metadata;

let timestamp = object.last_modified.map(|ts| {
Expand Down Expand Up @@ -641,12 +652,36 @@ impl IngestorProcess {
Some(receiver) => {
let result = receiver.await;
match result {
BatchStatus::Delivered => Ok(()),
BatchStatus::Errored => Err(ProcessingError::ErrorAcknowledgement),
BatchStatus::Delivered => {
info!(
message = "S3 object from SQS notification delivered.",
bucket = s3_event.s3.bucket.name,
key = s3_event.s3.object.key,
);
Ok(())
}
BatchStatus::Errored => {
warn!(
message = "S3 object from SQS notification had an error.",
bucket = s3_event.s3.bucket.name,
key = s3_event.s3.object.key,
);
Err(ProcessingError::ErrorAcknowledgement)
},
BatchStatus::Rejected => {
if self.state.delete_failed_message {
warn!(
message = "S3 object from SQS notification was rejected. Deleting failed message.",
bucket = s3_event.s3.bucket.name,
key = s3_event.s3.object.key,
);
Ok(())
} else {
error!(
message = "S3 object from SQS notification was rejected.",
bucket = s3_event.s3.bucket.name,
key = s3_event.s3.object.key,
);
Err(ProcessingError::ErrorAcknowledgement)
}
}
Expand Down