mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 20:07:55 -04: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);
|
Opentelemetry.Collector.backend := Some (module B);
|
||||||
B.cleanup
|
B.cleanup
|
||||||
|
|
||||||
let setup ?(config=Config.make()) () =
|
let setup ?(config=Config.make()) ?(enable=true) () =
|
||||||
let cleanup = setup_ ~config () in
|
if enable then (
|
||||||
at_exit cleanup
|
let cleanup = setup_ ~config () in
|
||||||
|
at_exit cleanup
|
||||||
|
)
|
||||||
|
|
||||||
let with_setup ?(config=Config.make()) () f =
|
let with_setup ?(config=Config.make()) ?(enable=true) () f =
|
||||||
let cleanup = setup_ ~config () in
|
if enable then (
|
||||||
Fun.protect ~finally:cleanup f
|
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
|
val pp : Format.formatter -> t -> unit
|
||||||
end
|
end
|
||||||
|
|
||||||
val setup : ?config:Config.t -> unit -> unit
|
val setup : ?config:Config.t -> ?enable:bool -> unit -> unit
|
||||||
(** Setup endpoint. This modifies {!Opentelemetry.Collector.backend}.
|
(** 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 *)
|
@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
|
(** [with_setup () f] is like [setup(); f()] but takes care of cleaning up
|
||||||
after [f()] returns. *)
|
after [f()] returns. *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue