File tree Expand file tree Collapse file tree 4 files changed +52
-1
lines changed
monarch_perfetto_trace/src Expand file tree Collapse file tree 4 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -492,6 +492,18 @@ impl ProcessAlloc {
492492 ) ;
493493 cmd. env ( bootstrap:: BOOTSTRAP_INDEX_ENV , index. to_string ( ) ) ;
494494
495+ cmd. env (
496+ "HYPERACTOR_PROCESS_NAME" ,
497+ format ! (
498+ "host rank:{} @{}" ,
499+ index,
500+ hostname:: get( )
501+ . unwrap_or_else( |_| "unknown_host" . into( ) )
502+ . into_string( )
503+ . unwrap_or( "unknown_host" . to_string( ) )
504+ ) ,
505+ ) ;
506+
495507 tracing:: debug!( "spawning process {:?}" , cmd) ;
496508 match cmd. spawn ( ) {
497509 Err ( err) => {
Original file line number Diff line number Diff line change @@ -1878,6 +1878,20 @@ impl ProcManager for BootstrapProcManager {
18781878 mode. to_env_safe_string ( )
18791879 . map_err ( |e| HostError :: ProcessConfigurationFailure ( proc_id. clone ( ) , e. into ( ) ) ) ?,
18801880 ) ;
1881+ cmd. env (
1882+ "HYPERACTOR_PROCESS_NAME" ,
1883+ format ! (
1884+ "proc {} @ {}" ,
1885+ match & proc_id {
1886+ ProcId :: Direct ( _, name) => name. clone( ) ,
1887+ ProcId :: Ranked ( world_id, rank) => format!( "{world_id}[{rank}]" ) ,
1888+ } ,
1889+ hostname:: get( )
1890+ . unwrap_or_else( |_| "unknown_host" . into( ) )
1891+ . into_string( )
1892+ . unwrap_or( "unknown_host" . to_string( ) )
1893+ ) ,
1894+ ) ;
18811895
18821896 if need_stdio {
18831897 cmd. stdout ( Stdio :: piped ( ) ) . stderr ( Stdio :: piped ( ) ) ;
Original file line number Diff line number Diff line change @@ -631,6 +631,9 @@ pub fn initialize_logging_with_log_prefix(
631631 tracing:: debug!( "logging already initialized for this process: {}" , err) ;
632632 }
633633 let exec_id = env:: execution_id ( ) ;
634+ let process_name =
635+ std:: env:: var ( "HYPERACTOR_PROCESS_NAME" ) . unwrap_or_else ( |_| "client" . to_string ( ) ) ;
636+
634637 // setting target to "execution" will prevent the monarch_tracing scuba client from logging this
635638 tracing:: info!(
636639 target: "execution" ,
@@ -645,7 +648,8 @@ pub fn initialize_logging_with_log_prefix(
645648 package_release = build_info:: BuildInfo :: get_package_release( ) ,
646649 upstream_revision = build_info:: BuildInfo :: get_upstream_revision( ) ,
647650 revision = build_info:: BuildInfo :: get_revision( ) ,
648- "logging_initialized"
651+ process_name = process_name,
652+ "logging_initialized" ,
649653 ) ;
650654 // here we have the monarch_executions scuba client log
651655 meta:: log_execution_event (
@@ -660,6 +664,7 @@ pub fn initialize_logging_with_log_prefix(
660664 build_info:: BuildInfo :: get_package_release ( ) ,
661665 build_info:: BuildInfo :: get_upstream_revision ( ) ,
662666 build_info:: BuildInfo :: get_revision ( ) ,
667+ & process_name,
663668 ) ;
664669
665670 if hyperactor_config:: global:: get ( ENABLE_OTEL_METRICS ) {
Original file line number Diff line number Diff line change @@ -531,6 +531,26 @@ impl<T: Sink> Ctx<T> {
531531 id
532532 }
533533
534+ pub fn new_process_with_name ( & mut self , pid : i32 , process_name : String ) -> u64 {
535+ let id = self . next_uuid ( ) ;
536+ let pd = ProcessDescriptor {
537+ pid : Some ( pid) ,
538+ process_name : Some ( process_name) ,
539+ ..Default :: default ( )
540+ } ;
541+ let td = TrackDescriptor {
542+ uuid : Some ( id) ,
543+ process : Some ( pd) ,
544+ ..Default :: default ( )
545+ } ;
546+ let tp = TracePacket {
547+ data : Some ( Data :: TrackDescriptor ( td) ) ,
548+ ..Default :: default ( )
549+ } ;
550+ self . sink . consume ( tp) ;
551+ id
552+ }
553+
534554 pub fn new_thread ( & mut self , pid : i32 , tid : i32 , name : String ) -> u64 {
535555 let id = self . next_uuid ( ) ;
536556 let thd = ThreadDescriptor {
You can’t perform that action at this time.
0 commit comments