@@ -577,29 +577,22 @@ end = struct
577
577
fail ~loc ~annots paragraphs
578
578
end
579
579
580
- let report_process_start stats ~metadata ~id ~pid ~prog ~args ~now =
580
+ let report_process_finished stats ~metadata ~prog ~pid ~args ~started_at
581
+ (times : Proc.Times.t ) =
581
582
let common =
582
583
let name =
583
584
match metadata.name with
584
585
| Some n -> n
585
586
| None -> Filename. basename prog
586
587
in
587
- let ts = Timestamp. of_float_seconds now in
588
+ let ts = Timestamp. of_float_seconds started_at in
588
589
Event. common_fields ~cat: (" process" :: metadata.categories) ~name ~ts ()
589
590
in
590
591
let args =
591
592
[ (" process_args" , `List (List. map args ~f: (fun arg -> `String arg)))
592
593
; (" pid" , `Int (Pid. to_int pid))
593
594
]
594
595
in
595
- let event =
596
- Event. async (Chrome_trace.Id. create (`Int id)) ~args Start common
597
- in
598
- Dune_stats. emit stats event;
599
- (common, args)
600
-
601
- let report_process_end stats (common , args ) ~now (times : Proc.Times.t ) =
602
- let common = Event. set_ts common (Timestamp. of_float_seconds now) in
603
596
let dur = Event.Timestamp. of_float_seconds times.elapsed_time in
604
597
let event = Event. complete ~args ~dur common in
605
598
Dune_stats. emit stats event
@@ -692,7 +685,7 @@ let run_internal ?dir ?(stdout_to = Io.stdout) ?(stderr_to = Io.stderr)
692
685
(stdout, stderr)
693
686
| _ -> ((`No_capture , stdout_to), (`No_capture , stderr_to))
694
687
in
695
- let event_common, started_at, pid =
688
+ let started_at, pid =
696
689
(* Output.fd might create the file with Unix.openfile. We need to make
697
690
sure to call it before doing the chdir as the path might be
698
691
relative. *)
@@ -705,26 +698,21 @@ let run_internal ?dir ?(stdout_to = Io.stdout) ?(stderr_to = Io.stderr)
705
698
| false -> env
706
699
in
707
700
let env = Env. to_unix env |> Spawn.Env. of_list in
708
- let started_at, pid =
701
+ let started_at =
709
702
(* jeremiedimino: I think we should do this just before the [execve]
710
703
in the stub for [Spawn.spawn] to be as precise as possible *)
711
- let now = Unix. gettimeofday () in
712
- ( now
713
- , Spawn. spawn () ~prog: prog_str ~argv ~env ~stdout ~stderr ~stdin
714
- ~setpgid: Spawn.Pgid. new_process_group
715
- ~cwd:
716
- (match dir with
717
- | None -> Inherit
718
- | Some dir -> Path (Path. to_string dir))
719
- |> Pid. of_int )
704
+ Unix. gettimeofday ()
720
705
in
721
- let event_common =
722
- Option. map config.stats ~f: (fun stats ->
723
- ( stats
724
- , report_process_start stats ~metadata ~id ~pid ~prog: prog_str
725
- ~args ~now: started_at ))
706
+ let pid =
707
+ Spawn. spawn () ~prog: prog_str ~argv ~env ~stdout ~stderr ~stdin
708
+ ~setpgid: Spawn.Pgid. new_process_group
709
+ ~cwd:
710
+ (match dir with
711
+ | None -> Inherit
712
+ | Some dir -> Path (Path. to_string dir))
713
+ |> Pid. of_int
726
714
in
727
- (event_common, started_at, pid)
715
+ (started_at, pid)
728
716
in
729
717
Io. release stdout_to;
730
718
Io. release stderr_to;
@@ -736,8 +724,9 @@ let run_internal ?dir ?(stdout_to = Io.stdout) ?(stderr_to = Io.stderr)
736
724
; resource_usage = process_info.resource_usage
737
725
}
738
726
in
739
- Option. iter event_common ~f: (fun (stats , common ) ->
740
- report_process_end stats common ~now: process_info.end_time times);
727
+ Option. iter config.stats ~f: (fun stats ->
728
+ report_process_finished stats ~metadata ~prog: prog_str ~pid ~args
729
+ ~started_at times);
741
730
Option. iter response_file ~f: Path. unlink;
742
731
let actual_stdout =
743
732
match stdout_capture with
0 commit comments