Skip to content

Commit 4fb95a3

Browse files
authored
Add object storage metrics for gcs (#5889)
1 parent 344a19c commit 4fb95a3

File tree

1 file changed

+21
-1
lines changed
  • quickwit/quickwit-storage/src/opendal_storage

1 file changed

+21
-1
lines changed

quickwit/quickwit-storage/src/opendal_storage/base.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ impl Storage for OpendalStorage {
7979
}
8080

8181
async fn put(&self, path: &Path, payload: Box<dyn PutPayload>) -> StorageResult<()> {
82+
crate::STORAGE_METRICS.object_storage_put_total.inc();
8283
let path = path.as_os_str().to_string_lossy();
8384
let mut payload_reader = payload.byte_stream().await?.into_async_read();
8485

@@ -91,6 +92,9 @@ impl Storage for OpendalStorage {
9192
.compat_write();
9293
tokio::io::copy(&mut payload_reader, &mut storage_writer).await?;
9394
storage_writer.get_mut().close().await?;
95+
crate::STORAGE_METRICS
96+
.object_storage_upload_num_bytes
97+
.inc_by(payload.len());
9498
Ok(())
9599
}
96100

@@ -103,7 +107,10 @@ impl Storage for OpendalStorage {
103107
.into_futures_async_read(..)
104108
.await?
105109
.compat();
106-
tokio::io::copy(&mut storage_reader, output).await?;
110+
let num_bytes_copied = tokio::io::copy(&mut storage_reader, output).await?;
111+
crate::STORAGE_METRICS
112+
.object_storage_download_num_bytes
113+
.inc_by(num_bytes_copied);
107114
output.flush().await?;
108115
Ok(())
109116
}
@@ -115,6 +122,7 @@ impl Storage for OpendalStorage {
115122
// Unlike other object store implementations, in flight requests are
116123
// recorded before issuing the query to the object store.
117124
let _inflight_guards = object_storage_get_slice_in_flight_guards(size);
125+
crate::STORAGE_METRICS.object_storage_get_total.inc();
118126
let storage_content = self.op.read_with(&path).range(range).await?.to_vec();
119127
Ok(OwnedBytes::new(storage_content))
120128
}
@@ -144,6 +152,12 @@ impl Storage for OpendalStorage {
144152

145153
async fn delete(&self, path: &Path) -> StorageResult<()> {
146154
let path = path.as_os_str().to_string_lossy();
155+
crate::STORAGE_METRICS
156+
.object_storage_delete_requests_total
157+
.inc();
158+
let _timer = crate::STORAGE_METRICS
159+
.object_storage_delete_request_duration
160+
.start_timer();
147161
self.op.delete(&path).await?;
148162
Ok(())
149163
}
@@ -159,6 +173,12 @@ impl Storage for OpendalStorage {
159173
{
160174
let mut bulk_error = BulkDeleteError::default();
161175
for (index, path) in paths.iter().enumerate() {
176+
crate::STORAGE_METRICS
177+
.object_storage_bulk_delete_requests_total
178+
.inc();
179+
let _timer = crate::STORAGE_METRICS
180+
.object_storage_bulk_delete_request_duration
181+
.start_timer();
162182
let result = self.op.delete(&path.as_os_str().to_string_lossy()).await;
163183
if let Err(err) = result {
164184
let storage_error_kind = err.kind();

0 commit comments

Comments
 (0)