mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
add ?enable to the ocurl client
This commit is contained in:
parent
000292cd17
commit
bcbb07027f
2 changed files with 15 additions and 8 deletions
|
|
@ -489,10 +489,14 @@ let setup_ ~(config:Config.t) () =
|
|||
Opentelemetry.Collector.backend := Some (module B);
|
||||
B.cleanup
|
||||
|
||||
let setup ?(config=Config.make()) () =
|
||||
let cleanup = setup_ ~config () in
|
||||
at_exit cleanup
|
||||
let setup ?(config=Config.make()) ?(enable=true) () =
|
||||
if enable then (
|
||||
let cleanup = setup_ ~config () in
|
||||
at_exit cleanup
|
||||
)
|
||||
|
||||
let with_setup ?(config=Config.make()) () f =
|
||||
let cleanup = setup_ ~config () in
|
||||
Fun.protect ~finally:cleanup f
|
||||
let with_setup ?(config=Config.make()) ?(enable=true) () f =
|
||||
if enable then (
|
||||
let cleanup = setup_ ~config () in
|
||||
Fun.protect ~finally:cleanup f
|
||||
) else f()
|
||||
|
|
|
|||
|
|
@ -60,10 +60,13 @@ module Config : sig
|
|||
val pp : Format.formatter -> t -> unit
|
||||
end
|
||||
|
||||
val setup : ?config:Config.t -> unit -> unit
|
||||
val setup : ?config:Config.t -> ?enable:bool -> unit -> unit
|
||||
(** Setup endpoint. This modifies {!Opentelemetry.Collector.backend}.
|
||||
@param enable actually setup the backend (default true). This can
|
||||
be used to enable/disable the setup depending on CLI arguments
|
||||
or environment.
|
||||
@param config configuration to use *)
|
||||
|
||||
val with_setup : ?config:Config.t -> unit -> (unit -> 'a) -> 'a
|
||||
val with_setup : ?config:Config.t -> ?enable:bool -> unit -> (unit -> 'a) -> 'a
|
||||
(** [with_setup () f] is like [setup(); f()] but takes care of cleaning up
|
||||
after [f()] returns. *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue