add Trace.with_setup_collector

This commit is contained in:
Simon Cruanes 2026-01-17 20:53:12 -05:00
parent dd432c4586
commit 67b3deb191
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 9 additions and 0 deletions

View file

@ -145,6 +145,10 @@ let shutdown () =
| C_none -> () | C_none -> ()
| C_some (st, cbs) -> cbs.shutdown st | C_some (st, cbs) -> cbs.shutdown st
let with_setup_collector c f =
setup_collector c;
Fun.protect ~finally:shutdown f
type extension_event = Types.extension_event = .. type extension_event = Types.extension_event = ..
let[@inline] extension_event ev : unit = let[@inline] extension_event ev : unit =

View file

@ -188,6 +188,11 @@ val shutdown : unit -> unit
(** [shutdown ()] shutdowns the current collector, if one was installed, and (** [shutdown ()] shutdowns the current collector, if one was installed, and
waits for it to terminate before returning. *) waits for it to terminate before returning. *)
val with_setup_collector : Collector.t -> (unit -> 'a) -> 'a
(** [with_setup_collector c f] installs [c], calls [f()], and shutdowns [c] once
[f()] is done.
@since NEXT_RELEASE *)
(** {2 Extensions} *) (** {2 Extensions} *)
type extension_event = Types.extension_event = .. type extension_event = Types.extension_event = ..