Skip to content

Commit e126639

Browse files
rrwang7Convex, Inc.
authored andcommitted
a couple more places in export worker to differentiate between backups and snapshots (#30868)
GitOrigin-RevId: d5ce67cd564f79d3b214c0e5d976881c8baf9ba8
1 parent b167a23 commit e126639

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

crates/application/src/export_worker.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,14 @@ impl<RT: Runtime> ExportWorker<RT> {
483483
.transpose()?;
484484
usage.track_storage_call(
485485
component_path.clone(),
486-
"snapshot_export",
486+
requestor.usage_tag(),
487487
file_storage_entry.storage_id.clone(),
488488
content_type,
489489
file_storage_entry.sha256.clone(),
490490
);
491491
self.usage_tracking.track_independent_storage_egress_size(
492492
component_path.clone(),
493-
requestor.usage_tag(),
493+
requestor.usage_tag().to_string(),
494494
file_stream.content_length as u64,
495495
);
496496
zip_snapshot_upload
@@ -624,17 +624,22 @@ impl<RT: Runtime> ExportWorker<RT> {
624624
.await?
625625
.context("error getting export object attributes from S3")?;
626626

627+
let tag = export.requestor().usage_tag().to_string();
628+
let call_type = match export.requestor() {
629+
ExportRequestor::SnapshotExport => CallType::Export,
630+
ExportRequestor::CloudBackup => CallType::CloudBackup,
631+
};
627632
// Charge file bandwidth for the upload of the snapshot to exports storage
628633
self.usage_tracking.track_independent_storage_ingress_size(
629634
ComponentPath::root(),
630-
export.requestor().usage_tag(),
635+
tag.clone(),
631636
object_attributes.size,
632637
);
633638
// Charge database bandwidth accumulated during the export
634639
self.usage_tracking.track_call(
635-
UdfIdentifier::Cli("export".to_string()),
640+
UdfIdentifier::Cli(tag),
636641
ExecutionId::new(),
637-
CallType::Export,
642+
call_type,
638643
usage.gather_user_stats(),
639644
);
640645
Ok(())

crates/model/src/exports/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ pub enum ExportRequestor {
293293
}
294294

295295
impl ExportRequestor {
296-
pub fn usage_tag(&self) -> String {
296+
pub fn usage_tag(&self) -> &'static str {
297297
match self {
298-
Self::SnapshotExport => "snapshot_export".to_string(),
299-
Self::CloudBackup => "cloud_backup".to_string(),
298+
Self::SnapshotExport => "snapshot_export",
299+
Self::CloudBackup => "cloud_backup",
300300
}
301301
}
302302
}

crates/usage_tracking/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub enum CallType {
9595
UncachedQuery,
9696
Mutation,
9797
Import,
98+
CloudBackup,
9899
}
99100

100101
impl CallType {
@@ -107,6 +108,7 @@ impl CallType {
107108
Self::Mutation => "mutation",
108109
Self::HttpAction { .. } => "http_action",
109110
Self::Import => "import",
111+
Self::CloudBackup => "cloud_backup",
110112
}
111113
}
112114

0 commit comments

Comments
 (0)