16
16
17
17
use once_cell:: sync:: Lazy ;
18
18
use quickwit_common:: metrics:: {
19
- new_counter, new_counter_vec, new_gauge, new_histogram_vec, Histogram , IntCounter ,
19
+ new_counter, new_counter_vec, new_gauge, new_histogram_vec, GaugeGuard , Histogram , IntCounter ,
20
20
IntCounterVec , IntGauge ,
21
21
} ;
22
22
@@ -32,6 +32,8 @@ pub struct StorageMetrics {
32
32
pub get_slice_timeout_all_timeouts : IntCounter ,
33
33
pub object_storage_get_total : IntCounter ,
34
34
pub object_storage_get_errors_total : IntCounterVec < 1 > ,
35
+ pub object_storage_get_slice_in_flight_count : IntGauge ,
36
+ pub object_storage_get_slice_in_flight_num_bytes : IntGauge ,
35
37
pub object_storage_put_total : IntCounter ,
36
38
pub object_storage_put_parts : IntCounter ,
37
39
pub object_storage_download_num_bytes : IntCounter ,
@@ -97,7 +99,8 @@ impl Default for StorageMetrics {
97
99
get_slice_timeout_all_timeouts,
98
100
object_storage_get_total : new_counter (
99
101
"object_storage_gets_total" ,
100
- "Number of objects fetched." ,
102
+ "Number of objects fetched. Might be lower than get_slice_timeout_outcome if \
103
+ queries are debounced.",
101
104
"storage" ,
102
105
& [ ] ,
103
106
) ,
@@ -108,6 +111,19 @@ impl Default for StorageMetrics {
108
111
& [ ] ,
109
112
[ "code" ] ,
110
113
) ,
114
+ object_storage_get_slice_in_flight_count : new_gauge (
115
+ "object_storage_get_slice_in_flight_count" ,
116
+ "Number of GetObject for which the memory was allocated but the download is still \
117
+ in progress.",
118
+ "storage" ,
119
+ & [ ] ,
120
+ ) ,
121
+ object_storage_get_slice_in_flight_num_bytes : new_gauge (
122
+ "object_storage_get_slice_in_flight_num_bytes" ,
123
+ "Memory allocated for GetObject requests that are still in progress." ,
124
+ "storage" ,
125
+ & [ ] ,
126
+ ) ,
111
127
object_storage_put_total : new_counter (
112
128
"object_storage_puts_total" ,
113
129
"Number of objects uploaded. May differ from object_storage_requests_parts due to \
@@ -212,3 +228,16 @@ pub static STORAGE_METRICS: Lazy<StorageMetrics> = Lazy::new(StorageMetrics::def
212
228
#[ cfg( test) ]
213
229
pub static CACHE_METRICS_FOR_TESTS : Lazy < CacheMetrics > =
214
230
Lazy :: new ( || CacheMetrics :: for_component ( "fortest" ) ) ;
231
+
232
+ pub fn object_storage_get_slice_in_flight_guards (
233
+ get_request_size : usize ,
234
+ ) -> ( GaugeGuard < ' static > , GaugeGuard < ' static > ) {
235
+ let mut bytes_guard = GaugeGuard :: from_gauge (
236
+ & crate :: STORAGE_METRICS . object_storage_get_slice_in_flight_num_bytes ,
237
+ ) ;
238
+ bytes_guard. add ( get_request_size as i64 ) ;
239
+ let mut count_guard =
240
+ GaugeGuard :: from_gauge ( & crate :: STORAGE_METRICS . object_storage_get_slice_in_flight_count ) ;
241
+ count_guard. add ( 1 ) ;
242
+ ( bytes_guard, count_guard)
243
+ }
0 commit comments