Skip to content

Commit 6f0c689

Browse files
fix: incorrect metric collection of PUT_MULTIPART
remove at the async writer add only when put_part() is called and is successful
1 parent 5364dc3 commit 6f0c689

File tree

3 files changed

+9
-31
lines changed

3 files changed

+9
-31
lines changed

src/storage/azure_blob.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,7 @@ impl BlobStore {
378378
let mut file = OpenOptions::new().read(true).open(path).await?;
379379
let location = &to_object_store_path(key);
380380

381-
// Track multipart initiation
382381
let async_writer = self.client.put_multipart(location).await;
383-
increment_object_store_calls_by_date(
384-
"azure_blob",
385-
"PUT_MULTIPART",
386-
&Utc::now().date_naive().to_string(),
387-
);
388382
let mut async_writer = match async_writer {
389383
Ok(writer) => writer,
390384
Err(err) => {
@@ -445,16 +439,14 @@ impl BlobStore {
445439
let part_data = data[start_pos..end_pos].to_vec();
446440

447441
let result = async_writer.put_part(part_data.into()).await;
442+
if result.is_err() {
443+
return Err(result.err().unwrap().into());
444+
}
448445
increment_object_store_calls_by_date(
449446
"azure_blob",
450447
"PUT_MULTIPART",
451448
&Utc::now().date_naive().to_string(),
452449
);
453-
if result.is_err() {
454-
return Err(result.err().unwrap().into());
455-
}
456-
457-
// upload_parts.push(part_number as u64 + 1);
458450
}
459451

460452
// Track multipart completion

src/storage/gcs.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,7 @@ impl Gcs {
322322
let mut file = OpenOptions::new().read(true).open(path).await?;
323323
let location = &to_object_store_path(key);
324324

325-
// Track multipart initiation
326325
let async_writer = self.client.put_multipart(location).await;
327-
increment_object_store_calls_by_date(
328-
"gcs",
329-
"PUT_MULTIPART",
330-
&Utc::now().date_naive().to_string(),
331-
);
332326
let mut async_writer = match async_writer {
333327
Ok(writer) => writer,
334328
Err(err) => {
@@ -387,14 +381,14 @@ impl Gcs {
387381

388382
// Track individual part upload
389383
let result = async_writer.put_part(part_data.into()).await;
384+
if result.is_err() {
385+
return Err(result.err().unwrap().into());
386+
}
390387
increment_object_store_calls_by_date(
391388
"gcs",
392389
"PUT_MULTIPART",
393390
&Utc::now().date_naive().to_string(),
394391
);
395-
if result.is_err() {
396-
return Err(result.err().unwrap().into());
397-
}
398392
}
399393

400394
// Track multipart completion

src/storage/s3.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,7 @@ impl S3 {
486486
let mut file = OpenOptions::new().read(true).open(path).await?;
487487
let location = &to_object_store_path(key);
488488

489-
// Track multipart initiation
490489
let async_writer = self.client.put_multipart(location).await;
491-
increment_object_store_calls_by_date(
492-
"s3",
493-
"PUT_MULTIPART",
494-
&Utc::now().date_naive().to_string(),
495-
);
496490
let mut async_writer = match async_writer {
497491
Ok(writer) => writer,
498492
Err(err) => {
@@ -552,16 +546,14 @@ impl S3 {
552546

553547
// Track individual part upload
554548
let result = async_writer.put_part(part_data.into()).await;
549+
if result.is_err() {
550+
return Err(result.err().unwrap().into());
551+
}
555552
increment_object_store_calls_by_date(
556553
"s3",
557554
"PUT_MULTIPART",
558555
&Utc::now().date_naive().to_string(),
559556
);
560-
if result.is_err() {
561-
return Err(result.err().unwrap().into());
562-
}
563-
564-
// upload_parts.push(part_number as u64 + 1);
565557
}
566558

567559
// Track multipart completion

0 commit comments

Comments
 (0)