Skip to content

Commit

Permalink
Merge pull request #1698 from tursodatabase/bottomless-metrics-small-fix
Browse files Browse the repository at this point in the history
we need to measure upload time inside the handle because function will return almost immediately
  • Loading branch information
sivukhin authored Aug 25, 2024
2 parents 5be413d + 5ccef31 commit 7e0f3d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bottomless/src/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ impl Replicator {
let snapshot_notifier = self.snapshot_notifier.clone();
let compression = self.use_compression;
let db_path = PathBuf::from(self.db_path.clone());
let db_name = self.db_name.clone();
let handle = tokio::spawn(async move {
tracing::trace!("Start snapshotting generation {}", generation);
let start = Instant::now();
Expand Down Expand Up @@ -1125,14 +1126,14 @@ impl Replicator {
}
let _ = snapshot_notifier.send(Ok(Some(generation)));
let elapsed = Instant::now() - start;
tracing::debug!("Snapshot upload finished (took {:?})", elapsed);
tracing::info!("Snapshot upload finished (took {:?})", elapsed);
Self::record_snapshot_upload_time(&db_name, elapsed);
// cleanup gzip/zstd database snapshot if exists
for suffix in &["gz", "zstd"] {
let _ = tokio::fs::remove_file(Self::db_compressed_path(&db_path, suffix)).await;
}
});
let elapsed = Instant::now() - start_ts;
Self::record_snapshot_upload_time(&self.db_name, elapsed);
tracing::debug!("Scheduled DB snapshot {} (took {:?})", generation, elapsed);

Ok(Some(handle))
Expand Down

0 comments on commit 7e0f3d7

Please sign in to comment.