change signature of with_setup

This commit is contained in:
Simon Cruanes 2022-03-22 11:18:35 -04:00
parent a768c55eac
commit b03ff26ba6
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
3 changed files with 5 additions and 3 deletions

View file

@ -471,6 +471,6 @@ let setup ?(config=Config.make()) () =
let cleanup = setup_ ~config () in
at_exit cleanup
let with_setup ?(config=Config.make()) f =
let with_setup ?(config=Config.make()) () f =
let cleanup = setup_ ~config () in
Fun.protect ~finally:cleanup f

View file

@ -64,4 +64,6 @@ val setup : ?config:Config.t -> unit -> unit
(** Setup endpoint. This modifies {!Opentelemetry.Collector.backend}.
@param config configuration to use *)
val with_setup : ?config:Config.t -> (unit -> 'a) -> 'a
val with_setup : ?config:Config.t -> unit -> (unit -> 'a) -> 'a
(** [with_setup () f] is like [setup(); f()] but takes care of cleaning up
after [f()] returns. *)

View file

@ -82,4 +82,4 @@ let () =
Format.printf "@[<2>sleep outer: %.3fs,@ sleep inner: %.3fs,@ config: %a@]@."
!sleep_outer !sleep_inner Opentelemetry_client_ocurl.Config.pp config;
Opentelemetry_client_ocurl.with_setup ~config run
Opentelemetry_client_ocurl.with_setup ~config () run