github ↗
docs menu

Module Munin.Provenance

How and where a run started.

Provenance records what is known to change a run's results and what a person needs to run it again: the command, the code, the toolchain, the machine and the seeds. A run's start records it, and so does each resume, since a resumed run may run other code (The log). detect reads it from the current process; the seeds are the one part that only the program knows, and it names them.

#type git = {
  1. #commit : string;
    (*

    The commit checked out, in full hexadecimal.

    *)
  2. #dirty : bool;
    (*

    true iff a tracked file differs from commit. Untracked files do not count.

    *)
}

The type for the state of a git work tree.

#type t = {
  1. #command : string list;
    (*

    The command line, Sys.argv.

    *)
  2. #cwd : string;
    (*

    The working directory.

    *)
  3. #hostname : string option;
    (*

    The machine's host name, if it has one.

    *)
  4. #pid : int;
    (*

    The process's id, as the system names it.

    *)
  5. #ocaml : string;
    (*

    The OCaml compiler's version, Sys.ocaml_version.

    *)
  6. #raven : string;
    (*

    The version of raven that built the program.

    *)
  7. #os : string;
    (*

    The system's name and release, such as "Linux 6.12.1" or "Darwin 25.3.0".

    *)
  8. #arch : string;
    (*

    The processor architecture, such as "x86_64".

    *)
  9. #cpu : string option;
    (*

    The processor model, if the system names it.

    *)
  10. #git : git option;
    (*

    The work tree of cwd, if cwd is in one.

    *)
  11. #seeds : (string * int) list;
    (*

    The seeds of the program's random number generators, by name.

    *)
  12. #env : (string * string) list;
    (*

    The environment variables the program asked to record.

    *)
}

The type for provenance.

#val detect : ?seeds:(string * int) list -> ?capture_env:string list -> ?cwd:string -> unit -> t

detect () is the current process's provenance. It runs git status --porcelain=v2 --branch --untracked-files=no once in cwd, without a shell; git is None when that fails, as outside a work tree or without git.

  • seeds defaults to [].
  • capture_env names the environment variables to record. Unset ones are skipped. Defaults to [].
  • cwd defaults to Sys.getcwd ().

Raises Invalid_argument if a seed's name is not a text (Names) or repeats, or if two names of capture_env are equal once escaped as UTF-8 (Numbers and values).

#val pp : Stdlib.Format.formatter -> t -> unit

pp ppf p prints p as one field: value line per field.