Skip to content

Commit a7f12de

Browse files
committed
Make in-flight storage get requests a memory metric
1 parent 922a15d commit a7f12de

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

quickwit/quickwit-common/src/metrics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ pub struct InFlightDataGauges {
342342
pub doc_processor_mailbox: IntGauge,
343343
pub indexer_mailbox: IntGauge,
344344
pub index_writer: IntGauge,
345+
pub get_object: IntGauge,
345346
in_flight_gauge_vec: IntGaugeVec<1>,
346347
}
347348

@@ -365,6 +366,7 @@ impl Default for InFlightDataGauges {
365366
doc_processor_mailbox: in_flight_gauge_vec.with_label_values(["doc_processor_mailbox"]),
366367
indexer_mailbox: in_flight_gauge_vec.with_label_values(["indexer_mailbox"]),
367368
index_writer: in_flight_gauge_vec.with_label_values(["index_writer"]),
369+
get_object: in_flight_gauge_vec.with_label_values(["get_object"]),
368370
in_flight_gauge_vec: in_flight_gauge_vec.clone(),
369371
}
370372
}

quickwit/quickwit-storage/src/metrics.rs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
use once_cell::sync::Lazy;
1818
use quickwit_common::metrics::{
19-
GaugeGuard, HistogramVec, IntCounter, IntCounterVec, IntGauge, new_counter, new_counter_vec,
20-
new_gauge, new_histogram_vec,
19+
GaugeGuard, HistogramVec, IntCounter, IntCounterVec, IntGauge, MEMORY_METRICS, new_counter,
20+
new_counter_vec, new_gauge, new_histogram_vec,
2121
};
2222

2323
/// Counters associated to storage operations.
@@ -32,8 +32,6 @@ pub struct StorageMetrics {
3232
pub get_slice_timeout_all_timeouts: IntCounter,
3333
pub object_storage_requests_total: IntCounterVec<2>,
3434
pub object_storage_request_duration: HistogramVec<2>,
35-
pub object_storage_get_slice_in_flight_count: IntGauge,
36-
pub object_storage_get_slice_in_flight_num_bytes: IntGauge,
3735
pub object_storage_download_num_bytes: IntCounterVec<1>,
3836
pub object_storage_download_errors: IntCounterVec<1>,
3937
pub object_storage_upload_num_bytes: IntCounterVec<1>,
@@ -84,19 +82,6 @@ impl Default for StorageMetrics {
8482
["action", "status"],
8583
vec![0.1, 0.5, 1.0, 5.0, 10.0, 30.0, 60.0],
8684
),
87-
object_storage_get_slice_in_flight_count: new_gauge(
88-
"object_storage_get_slice_in_flight_count",
89-
"Number of get_object for which the memory was allocated but the download is \
90-
still in progress.",
91-
"storage",
92-
&[],
93-
),
94-
object_storage_get_slice_in_flight_num_bytes: new_gauge(
95-
"object_storage_get_slice_in_flight_num_bytes",
96-
"Memory allocated for get_object requests that are still in progress.",
97-
"storage",
98-
&[],
99-
),
10085
object_storage_download_num_bytes: new_counter_vec(
10186
"object_storage_download_num_bytes",
10287
"Amount of data downloaded from object storage.",
@@ -199,15 +184,11 @@ pub static STORAGE_METRICS: Lazy<StorageMetrics> = Lazy::new(StorageMetrics::def
199184
pub static CACHE_METRICS_FOR_TESTS: Lazy<CacheMetrics> =
200185
Lazy::new(|| CacheMetrics::for_component("fortest"));
201186

202-
pub fn object_storage_get_slice_in_flight_guards(
203-
get_request_size: usize,
204-
) -> (GaugeGuard<'static>, GaugeGuard<'static>) {
205-
let mut bytes_guard = GaugeGuard::from_gauge(
206-
&crate::STORAGE_METRICS.object_storage_get_slice_in_flight_num_bytes,
207-
);
187+
/// Helps tracking pre-allocated memory for downloads that are still in progress.
188+
///
189+
/// This is actually recorded as a memory metric and not a storage metric.
190+
pub fn object_storage_get_slice_in_flight_guards(get_request_size: usize) -> GaugeGuard<'static> {
191+
let mut bytes_guard = GaugeGuard::from_gauge(&MEMORY_METRICS.in_flight.get_object);
208192
bytes_guard.add(get_request_size as i64);
209-
let mut count_guard =
210-
GaugeGuard::from_gauge(&crate::STORAGE_METRICS.object_storage_get_slice_in_flight_count);
211-
count_guard.add(1);
212-
(bytes_guard, count_guard)
193+
bytes_guard
213194
}

0 commit comments

Comments
 (0)