From f68c398d3ea3803bc8dc05088d1931a2e06090e9 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 9 Dec 2025 21:25:22 +0000 Subject: [PATCH 1/2] dev Signed-off-by: Rudi Grinberg From a877f0367f373983e704aaf2b3578edd0570903b Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 9 Dec 2025 22:35:06 +0000 Subject: [PATCH 2/2] feature: add more info to "config" event * argv * environment * dune version Signed-off-by: Rudi Grinberg --- bin/common.ml | 6 +++++- doc/changes/added/12908.md | 2 ++ src/dune_trace/dune_trace.ml | 15 ++++++++++++--- src/dune_trace/dune_trace.mli | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 doc/changes/added/12908.md diff --git a/bin/common.ml b/bin/common.ml index 6af8c8e1566..ce50537a488 100644 --- a/bin/common.ml +++ b/bin/common.ml @@ -1404,7 +1404,11 @@ let init_with_root ~(root : Workspace_root.t) (builder : Builder.t) = ]; Dune_console.separate_messages c.builder.separate_error_messages; Option.iter c.stats ~f:(fun stats -> - let event = Dune_trace.Event.config () in + let event = + Dune_trace.Event.config + ~version: + (Build_info.V1.version () |> Option.map ~f:Build_info.V1.Version.to_string) + in Dune_trace.emit stats event); (* Setup hook for printing GC stats to a file *) at_exit (fun () -> diff --git a/doc/changes/added/12908.md b/doc/changes/added/12908.md new file mode 100644 index 00000000000..e9c4b141223 --- /dev/null +++ b/doc/changes/added/12908.md @@ -0,0 +1,2 @@ +- Add `argv`, the process environment, and the dune version to the config event + in the trace (#12909, @rgrinberg) diff --git a/src/dune_trace/dune_trace.ml b/src/dune_trace/dune_trace.ml index 0576e1eae1c..43f4ef219e2 100644 --- a/src/dune_trace/dune_trace.ml +++ b/src/dune_trace/dune_trace.ml @@ -1,6 +1,5 @@ open Stdune module Timestamp = Chrome_trace.Event.Timestamp -module Json = Json module Mac = struct external open_fds : pid:int -> int = "dune_trace_open_fds" @@ -135,9 +134,19 @@ module Event = struct Event.counter common args ;; - let config () = + let config ~version = + let args = + let args = + [ "build_dir", `String (Path.Build.to_string Path.Build.root) + ; "argv", `List (Array.to_list Sys.argv |> List.map ~f:Json.string) + ; "env", `List (Unix.environment () |> Array.to_list |> List.map ~f:Json.string) + ] + in + match version with + | None -> args + | Some v -> ("version", Stdune.Json.string v) :: args + in let open Chrome_trace in - let args = [ "build_dir", `String (Path.Build.to_string Path.Build.root) ] in let ts = Event.Timestamp.of_float_seconds (Unix.gettimeofday ()) in let common = Event.common_fields ~cat:[ "config" ] ~name:"config" ~ts () in Event.instant ~args common diff --git a/src/dune_trace/dune_trace.mli b/src/dune_trace/dune_trace.mli index 729cac94b94..4172bfb49fa 100644 --- a/src/dune_trace/dune_trace.mli +++ b/src/dune_trace/dune_trace.mli @@ -68,7 +68,7 @@ module Event : sig val scan_source : name:string -> start:float -> stop:float -> dir:Path.Source.t -> t val scheduler_idle : unit -> t - val config : unit -> t + val config : version:string option -> t module Rpc : sig type stage =