Skip to content

Commit a877f03

Browse files
committed
feature: add more info to "config" event
* argv * environment * dune version Signed-off-by: Rudi Grinberg <[email protected]>
1 parent f68c398 commit a877f03

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

bin/common.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,11 @@ let init_with_root ~(root : Workspace_root.t) (builder : Builder.t) =
14041404
];
14051405
Dune_console.separate_messages c.builder.separate_error_messages;
14061406
Option.iter c.stats ~f:(fun stats ->
1407-
let event = Dune_trace.Event.config () in
1407+
let event =
1408+
Dune_trace.Event.config
1409+
~version:
1410+
(Build_info.V1.version () |> Option.map ~f:Build_info.V1.Version.to_string)
1411+
in
14081412
Dune_trace.emit stats event);
14091413
(* Setup hook for printing GC stats to a file *)
14101414
at_exit (fun () ->

doc/changes/added/12908.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Add `argv`, the process environment, and the dune version to the config event
2+
in the trace (#12909, @rgrinberg)

src/dune_trace/dune_trace.ml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
open Stdune
22
module Timestamp = Chrome_trace.Event.Timestamp
3-
module Json = Json
43

54
module Mac = struct
65
external open_fds : pid:int -> int = "dune_trace_open_fds"
@@ -135,9 +134,19 @@ module Event = struct
135134
Event.counter common args
136135
;;
137136

138-
let config () =
137+
let config ~version =
138+
let args =
139+
let args =
140+
[ "build_dir", `String (Path.Build.to_string Path.Build.root)
141+
; "argv", `List (Array.to_list Sys.argv |> List.map ~f:Json.string)
142+
; "env", `List (Unix.environment () |> Array.to_list |> List.map ~f:Json.string)
143+
]
144+
in
145+
match version with
146+
| None -> args
147+
| Some v -> ("version", Stdune.Json.string v) :: args
148+
in
139149
let open Chrome_trace in
140-
let args = [ "build_dir", `String (Path.Build.to_string Path.Build.root) ] in
141150
let ts = Event.Timestamp.of_float_seconds (Unix.gettimeofday ()) in
142151
let common = Event.common_fields ~cat:[ "config" ] ~name:"config" ~ts () in
143152
Event.instant ~args common

src/dune_trace/dune_trace.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module Event : sig
6868

6969
val scan_source : name:string -> start:float -> stop:float -> dir:Path.Source.t -> t
7070
val scheduler_idle : unit -> t
71-
val config : unit -> t
71+
val config : version:string option -> t
7272

7373
module Rpc : sig
7474
type stage =

0 commit comments

Comments
 (0)