mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 12:23:32 -04:00
fixes and cleanup in cohttp-eio client
This commit is contained in:
parent
05ad0421db
commit
3c08842e2d
2 changed files with 15 additions and 13 deletions
|
|
@ -1,5 +1,3 @@
|
|||
open Eio.Std
|
||||
|
||||
(*
|
||||
https://github.com/open-telemetry/oteps/blob/main/text/0035-opentelemetry-protocol.md
|
||||
https://github.com/open-telemetry/oteps/blob/main/text/0099-otlp-http.md
|
||||
|
|
@ -48,7 +46,9 @@ struct
|
|||
ensure it runs in the Eio thread? *)
|
||||
Eio.Condition.broadcast self.cond
|
||||
|
||||
let delete = ignore
|
||||
let delete self =
|
||||
trigger self;
|
||||
()
|
||||
|
||||
let wait self =
|
||||
Eio.Mutex.lock self.mutex;
|
||||
|
|
@ -193,12 +193,10 @@ let remove_exporter () =
|
|||
|
||||
let remove_backend = remove_exporter
|
||||
|
||||
let with_setup ?config ?(enable = true) f env =
|
||||
if enable then
|
||||
let with_setup ?config ?(enable = true) env f =
|
||||
if enable then (
|
||||
Eio.Switch.run @@ fun sw ->
|
||||
snd
|
||||
@@ Fiber.pair
|
||||
(fun () -> setup_ ~sw ?config env)
|
||||
(fun () -> Fun.protect ~finally:(fun () -> remove_backend ()) f)
|
||||
else
|
||||
setup_ ~sw ?config env;
|
||||
Fun.protect f ~finally:remove_exporter
|
||||
) else
|
||||
f ()
|
||||
|
|
|
|||
|
|
@ -49,11 +49,15 @@ val setup :
|
|||
an atomic boolean. When it becomes true, background threads will all stop
|
||||
after a little while. *)
|
||||
|
||||
val remove_backend : unit -> unit
|
||||
(** Shutdown current backend
|
||||
val remove_exporter : unit -> unit
|
||||
(** Shutdown current exporter
|
||||
@since 0.12 *)
|
||||
|
||||
val remove_backend : unit -> unit
|
||||
[@@deprecated "use remove_exporter"]
|
||||
(** @since 0.12 *)
|
||||
|
||||
val with_setup :
|
||||
?config:Config.t -> ?enable:bool -> (unit -> 'a) -> Eio_unix.Stdenv.base -> 'a
|
||||
?config:Config.t -> ?enable:bool -> Eio_unix.Stdenv.base -> (unit -> 'a) -> 'a
|
||||
(** [with_setup () f] is like [setup(); f()] but takes care of cleaning up after
|
||||
[f()] returns See {!setup} for more details. *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue