@@ -178,7 +178,12 @@ impl PythonActorMeshImpl {
178178 }
179179 }
180180
181- fn make_monitor < F > ( & self , instance : PyInstance , unhandled : F ) -> SupervisionMonitor
181+ fn make_monitor < F > (
182+ & self ,
183+ instance : PyInstance ,
184+ unhandled : F ,
185+ supervision_display_name : String ,
186+ ) -> SupervisionMonitor
182187 where
183188 F : Fn ( MeshFailure ) + Send + ' static ,
184189 {
@@ -190,6 +195,7 @@ impl PythonActorMeshImpl {
190195 inner. health_state . clone ( ) ,
191196 true ,
192197 unhandled,
198+ supervision_display_name,
193199 ) ,
194200 // Ref meshes send no message, they are only used to generate
195201 // the v0 style exception.
@@ -199,6 +205,7 @@ impl PythonActorMeshImpl {
199205 inner. health_state . clone ( ) ,
200206 false ,
201207 unhandled,
208+ supervision_display_name,
202209 ) ,
203210 }
204211 }
@@ -211,14 +218,19 @@ impl PythonActorMeshImpl {
211218 instance : & PyInstance ,
212219 monitor : & Arc < Mutex < Option < SupervisionMonitor > > > ,
213220 unhandled : F ,
221+ supervision_display_name : Option < String > ,
214222 ) -> watch:: Receiver < Option < PyErr > >
215223 where
216224 F : Fn ( MeshFailure ) + Send + ' static ,
217225 {
218226 let mut guard = monitor. lock ( ) . unwrap ( ) ;
219227 guard. get_or_insert_with ( move || {
220228 let instance = Python :: with_gil ( |_py| instance. clone ( ) ) ;
221- self . make_monitor ( instance, unhandled)
229+ self . make_monitor (
230+ instance,
231+ unhandled,
232+ supervision_display_name. unwrap_or_default ( ) ,
233+ )
222234 } ) ;
223235 let monitor = guard. as_ref ( ) . unwrap ( ) ;
224236 monitor. receiver . clone ( )
@@ -296,6 +308,7 @@ impl PythonActorMeshImpl {
296308 health_state : Arc < RootHealthState > ,
297309 is_owned : bool ,
298310 unhandled : F ,
311+ supervision_display_name : String ,
299312 ) -> SupervisionMonitor
300313 where
301314 F : Fn ( MeshFailure ) + Send + ' static ,
@@ -324,6 +337,7 @@ impl PythonActorMeshImpl {
324337 time_between_checks,
325338 sender,
326339 canceled,
340+ supervision_display_name. clone ( ) ,
327341 )
328342 . await ;
329343 }
@@ -345,6 +359,7 @@ impl PythonActorMeshImpl {
345359 time_between_checks,
346360 sender,
347361 canceled,
362+ supervision_display_name,
348363 )
349364 . await ;
350365 }
@@ -492,6 +507,7 @@ async fn actor_states_monitor<A, F>(
492507 time_between_checks : tokio:: time:: Duration ,
493508 sender : watch:: Sender < Option < PyErr > > ,
494509 canceled : CancellationToken ,
510+ supervision_display_name : String ,
495511) where
496512 A : Actor + RemotableActor + Referable ,
497513 A :: Params : RemoteMessage ,
@@ -554,24 +570,29 @@ async fn actor_states_monitor<A, F>(
554570 status
555571 ) ) ) ,
556572 } ;
557-
573+ let display_name = if !point. is_empty ( ) {
574+ let coords_display = point. format_as_dict ( ) ;
575+ if let Some ( pos) = supervision_display_name. rfind ( '>' ) {
576+ format ! (
577+ "{}{}{}" ,
578+ & supervision_display_name[ ..pos] ,
579+ coords_display,
580+ & supervision_display_name[ pos..]
581+ )
582+ } else {
583+ format ! ( "{}{}" , supervision_display_name, coords_display)
584+ }
585+ } else {
586+ supervision_display_name. clone ( )
587+ } ;
558588 send_state_change (
559589 point. rank ( ) ,
560590 ActorSupervisionEvent :: new (
561591 // Attribute this to the monitored actor, even if the underlying
562592 // cause is a proc_failure. We propagate the cause explicitly.
563593 mesh. get ( point. rank ( ) ) . unwrap ( ) . actor_id ( ) . clone ( ) ,
564- None ,
594+ Some ( format ! ( "{} was running on a process which" , display_name ) ) ,
565595 actor_status,
566- // ActorStatus::Failed(ActorErrorKind::Generic(format!(
567- // "process failure: {}",
568- // state
569- // .state
570- // .and_then(|state| state.proc_status)
571- // .unwrap_or_else(|| ProcStatus::Failed {
572- // reason: "unknown".to_string()
573- // })
574- // ))),
575596 None ,
576597 ) ,
577598 mesh. name ( ) ,
@@ -593,7 +614,7 @@ async fn actor_states_monitor<A, F>(
593614 0 ,
594615 ActorSupervisionEvent :: new (
595616 cx. instance ( ) . self_id ( ) . clone ( ) ,
596- None ,
617+ Some ( supervision_display_name . clone ( ) ) ,
597618 ActorStatus :: generic_failure ( format ! (
598619 "unable to query for actor states: {:?}" ,
599620 e
@@ -720,7 +741,7 @@ impl ActorMeshProtocol for PythonActorMeshImpl {
720741 // Make a clone so each endpoint can get the same supervision events.
721742 let unhandled = self . get_unhandled ( instance) ;
722743 let monitor = self . monitor ( ) . clone ( ) ;
723- let mut receiver = self . supervision_receiver ( instance, & monitor, unhandled) ;
744+ let mut receiver = self . supervision_receiver ( instance, & monitor, unhandled, None ) ;
724745 PyPythonTask :: new ( async move {
725746 receiver. changed ( ) . await . map_err ( |e| {
726747 PyValueError :: new_err ( format ! ( "Waiting for supervision event change: {}" , e) )
@@ -744,11 +765,20 @@ impl ActorMeshProtocol for PythonActorMeshImpl {
744765 . map ( Some )
745766 }
746767
747- fn start_supervision ( & self , instance : & PyInstance ) -> PyResult < ( ) > {
768+ fn start_supervision (
769+ & self ,
770+ instance : & PyInstance ,
771+ supervision_display_name : String ,
772+ ) -> PyResult < ( ) > {
748773 // Fetch the receiver once, this will initialize the monitor task.
749774 let unhandled = self . get_unhandled ( instance) ;
750775 let monitor = self . monitor ( ) . clone ( ) ;
751- self . supervision_receiver ( instance, & monitor, unhandled) ;
776+ self . supervision_receiver (
777+ instance,
778+ & monitor,
779+ unhandled,
780+ Some ( supervision_display_name) ,
781+ ) ;
752782 Ok ( ( ) )
753783 }
754784
@@ -827,7 +857,11 @@ impl ActorMeshProtocol for ActorMeshRef<PythonActor> {
827857 ) )
828858 }
829859
830- fn start_supervision ( & self , _instance : & PyInstance ) -> PyResult < ( ) > {
860+ fn start_supervision (
861+ & self ,
862+ _instance : & PyInstance ,
863+ _supervision_display_name : String ,
864+ ) -> PyResult < ( ) > {
831865 Err ( PyErr :: new :: < PyNotImplementedError , _ > (
832866 "This should never be called on ActorMeshRef directly" ,
833867 ) )
0 commit comments