mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-08 03:47:57 -04:00
wip: port fuchsia to subscriber infra
This commit is contained in:
parent
ef50b578f1
commit
7405e3ae1b
4 changed files with 32 additions and 0 deletions
|
|
@ -5,6 +5,19 @@ module Int_map = Map.Make (Int)
|
||||||
|
|
||||||
let pid = Unix.getpid ()
|
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 *)
|
(** Thread-local stack of span info *)
|
||||||
module Span_info_stack : sig
|
module Span_info_stack : sig
|
||||||
type t
|
type t
|
||||||
|
|
@ -408,3 +421,10 @@ let create ~out () : collector =
|
||||||
()
|
()
|
||||||
in
|
in
|
||||||
(module Coll)
|
(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
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
open Trace_core
|
open Trace_core
|
||||||
|
|
||||||
val create : out:Bg_thread.out -> unit -> collector
|
val create : out:Bg_thread.out -> unit -> collector
|
||||||
|
|
||||||
|
(**/**)
|
||||||
|
|
||||||
|
module Internal_ : sig
|
||||||
|
val mock_all_ : unit -> unit
|
||||||
|
end
|
||||||
|
|
||||||
|
(**/**)
|
||||||
|
|
|
||||||
|
|
@ -34,5 +34,6 @@ let with_setup ?out () f =
|
||||||
Fun.protect ~finally:Trace_core.shutdown f
|
Fun.protect ~finally:Trace_core.shutdown f
|
||||||
|
|
||||||
module Internal_ = struct
|
module Internal_ = struct
|
||||||
|
let mock_all_ = Fcollector.Internal_.mock_all_
|
||||||
let on_tracing_error = on_tracing_error
|
let on_tracing_error = on_tracing_error
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ val with_setup : ?out:[ output | `Env ] -> unit -> (unit -> 'a) -> 'a
|
||||||
|
|
||||||
module Internal_ : sig
|
module Internal_ : sig
|
||||||
val on_tracing_error : (string -> unit) ref
|
val on_tracing_error : (string -> unit) ref
|
||||||
|
|
||||||
|
val mock_all_ : unit -> unit
|
||||||
|
(** use fake, deterministic timestamps, TID, PID *)
|
||||||
end
|
end
|
||||||
|
|
||||||
(**/**)
|
(**/**)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue