@@ -86,9 +86,15 @@ pub trait Handler: Send + Sync {
8686 ///
8787 /// Called periodically by spicebench when `--scrape-sut-metrics` is enabled.
8888 /// Returns a snapshot of resource utilization and ingestion progress.
89+ /// When `final_scrape` is true, the benchmark run has finished and the
90+ /// adapter may perform heavier queries (e.g. Query History aggregation).
8991 /// Default implementation returns empty metrics.
90- async fn metrics ( & mut self , run_id : Uuid ) -> std:: result:: Result < MetricsResponse , String > {
91- let _ = run_id;
92+ async fn metrics (
93+ & mut self ,
94+ run_id : Uuid ,
95+ final_scrape : bool ,
96+ ) -> std:: result:: Result < MetricsResponse , String > {
97+ let _ = ( run_id, final_scrape) ;
9298 Ok ( MetricsResponse :: default ( ) )
9399 }
94100
@@ -263,7 +269,7 @@ impl<H: Handler> Server<H> {
263269 Ok ( r) => r,
264270 Err ( e) => return e,
265271 } ;
266- Self :: handler_response ( self . handler . metrics ( req. run_id ) . await , id)
272+ Self :: handler_response ( self . handler . metrics ( req. run_id , req . final_scrape ) . await , id)
267273 }
268274
269275 async fn handle_rpc_methods ( & mut self , id : serde_json:: Value ) -> serde_json:: Value {
@@ -302,7 +308,11 @@ mod tests {
302308 Ok ( TeardownResponse { ok : true } )
303309 }
304310
305- async fn metrics ( & mut self , _run_id : Uuid ) -> std:: result:: Result < MetricsResponse , String > {
311+ async fn metrics (
312+ & mut self ,
313+ _run_id : Uuid ,
314+ _final_scrape : bool ,
315+ ) -> std:: result:: Result < MetricsResponse , String > {
306316 Ok ( MetricsResponse :: default ( ) )
307317 }
308318 }
0 commit comments