wip: port fuchsia to subscriber infra

This commit is contained in:
Simon Cruanes 2025-05-02 08:56:48 -04:00
parent ef50b578f1
commit 7405e3ae1b
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
4 changed files with 32 additions and 0 deletions

View file

@ -5,6 +5,19 @@ module Int_map = Map.Make (Int)
let pid = Unix.getpid ()
module Mock_ = struct
let enabled = ref false
let now = ref 0
(* used to mock timing *)
let get_now_ns () : float =
let x = !now in
incr now;
float_of_int x *. 1000.
let get_tid_ () : int = 3
end
(** Thread-local stack of span info *)
module Span_info_stack : sig
type t
@ -408,3 +421,10 @@ let create ~out () : collector =
()
in
(module Coll)
module Internal_ = struct
let mock_all_ () =
Mock_.enabled := true;
Sub.Private_.get_now_ns_ := Some Mock_.get_now_ns;
Sub.Private_.get_tid_ := Some Mock_.get_tid_
end

View file

@ -1,3 +1,11 @@
open Trace_core
val create : out:Bg_thread.out -> unit -> collector
(**/**)
module Internal_ : sig
val mock_all_ : unit -> unit
end
(**/**)

View file

@ -34,5 +34,6 @@ let with_setup ?out () f =
Fun.protect ~finally:Trace_core.shutdown f
module Internal_ = struct
let mock_all_ = Fcollector.Internal_.mock_all_
let on_tracing_error = on_tracing_error
end

View file

@ -45,6 +45,9 @@ val with_setup : ?out:[ output | `Env ] -> unit -> (unit -> 'a) -> 'a
module Internal_ : sig
val on_tracing_error : (string -> unit) ref
val mock_all_ : unit -> unit
(** use fake, deterministic timestamps, TID, PID *)
end
(**/**)