@@ -360,6 +360,13 @@ pub trait DistributedExt: Sized {
360360 & mut self ,
361361 factor : f64 ,
362362 ) -> Result < ( ) , DataFusionError > ;
363+
364+ /// Enables metrics collection across network boundaries so that all the metrics gather in
365+ /// each node are accessible from the head stage that started running the query.
366+ fn with_distributed_metrics_collection ( self , enabled : bool ) -> Result < Self , DataFusionError > ;
367+
368+ /// Same as [DistributedExt::with_distributed_metrics_collection] but with an in-place mutation.
369+ fn set_distributed_metrics_collection ( & mut self , enabled : bool ) -> Result < ( ) , DataFusionError > ;
363370}
364371
365372impl DistributedExt for SessionConfig {
@@ -374,7 +381,8 @@ impl DistributedExt for SessionConfig {
374381 & mut self ,
375382 headers : & HeaderMap ,
376383 ) -> Result < ( ) , DataFusionError > {
377- set_distributed_option_extension_from_headers :: < T > ( self , headers)
384+ set_distributed_option_extension_from_headers :: < T > ( self , headers) ?;
385+ Ok ( ( ) )
378386 }
379387
380388 fn set_distributed_user_codec < T : PhysicalExtensionCodec + ' static > ( & mut self , codec : T ) {
@@ -417,6 +425,12 @@ impl DistributedExt for SessionConfig {
417425 Ok ( ( ) )
418426 }
419427
428+ fn set_distributed_metrics_collection ( & mut self , enabled : bool ) -> Result < ( ) , DataFusionError > {
429+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
430+ d_cfg. collect_metrics = enabled;
431+ Ok ( ( ) )
432+ }
433+
420434 delegate ! {
421435 to self {
422436 #[ call( set_distributed_option_extension) ]
@@ -450,6 +464,10 @@ impl DistributedExt for SessionConfig {
450464 #[ call( set_distributed_cardinality_effect_task_scale_factor) ]
451465 #[ expr( $?; Ok ( self ) ) ]
452466 fn with_distributed_cardinality_effect_task_scale_factor( mut self , factor: f64 ) -> Result <Self , DataFusionError >;
467+
468+ #[ call( set_distributed_metrics_collection) ]
469+ #[ expr( $?; Ok ( self ) ) ]
470+ fn with_distributed_metrics_collection( mut self , enabled: bool ) -> Result <Self , DataFusionError >;
453471 }
454472 }
455473}
@@ -496,6 +514,11 @@ impl DistributedExt for SessionStateBuilder {
496514 #[ call( set_distributed_cardinality_effect_task_scale_factor) ]
497515 #[ expr( $?; Ok ( self ) ) ]
498516 fn with_distributed_cardinality_effect_task_scale_factor( mut self , factor: f64 ) -> Result <Self , DataFusionError >;
517+
518+ fn set_distributed_metrics_collection( & mut self , enabled: bool ) -> Result <( ) , DataFusionError >;
519+ #[ call( set_distributed_metrics_collection) ]
520+ #[ expr( $?; Ok ( self ) ) ]
521+ fn with_distributed_metrics_collection( mut self , enabled: bool ) -> Result <Self , DataFusionError >;
499522 }
500523 }
501524}
@@ -542,6 +565,11 @@ impl DistributedExt for SessionState {
542565 #[ call( set_distributed_cardinality_effect_task_scale_factor) ]
543566 #[ expr( $?; Ok ( self ) ) ]
544567 fn with_distributed_cardinality_effect_task_scale_factor( mut self , factor: f64 ) -> Result <Self , DataFusionError >;
568+
569+ fn set_distributed_metrics_collection( & mut self , enabled: bool ) -> Result <( ) , DataFusionError >;
570+ #[ call( set_distributed_metrics_collection) ]
571+ #[ expr( $?; Ok ( self ) ) ]
572+ fn with_distributed_metrics_collection( mut self , enabled: bool ) -> Result <Self , DataFusionError >;
545573 }
546574 }
547575}
@@ -588,6 +616,11 @@ impl DistributedExt for SessionContext {
588616 #[ call( set_distributed_cardinality_effect_task_scale_factor) ]
589617 #[ expr( $?; Ok ( self ) ) ]
590618 fn with_distributed_cardinality_effect_task_scale_factor( self , factor: f64 ) -> Result <Self , DataFusionError >;
619+
620+ fn set_distributed_metrics_collection( & mut self , enabled: bool ) -> Result <( ) , DataFusionError >;
621+ #[ call( set_distributed_metrics_collection) ]
622+ #[ expr( $?; Ok ( self ) ) ]
623+ fn with_distributed_metrics_collection( self , enabled: bool ) -> Result <Self , DataFusionError >;
591624 }
592625 }
593626}
0 commit comments