mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-10 04:35:46 -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/0035-opentelemetry-protocol.md
|
||||||
https://github.com/open-telemetry/oteps/blob/main/text/0099-otlp-http.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? *)
|
ensure it runs in the Eio thread? *)
|
||||||
Eio.Condition.broadcast self.cond
|
Eio.Condition.broadcast self.cond
|
||||||
|
|
||||||
let delete = ignore
|
let delete self =
|
||||||
|
trigger self;
|
||||||
|
()
|
||||||
|
|
||||||
let wait self =
|
let wait self =
|
||||||
Eio.Mutex.lock self.mutex;
|
Eio.Mutex.lock self.mutex;
|
||||||
|
|
@ -193,12 +193,10 @@ let remove_exporter () =
|
||||||
|
|
||||||
let remove_backend = remove_exporter
|
let remove_backend = remove_exporter
|
||||||
|
|
||||||
let with_setup ?config ?(enable = true) f env =
|
let with_setup ?config ?(enable = true) env f =
|
||||||
if enable then
|
if enable then (
|
||||||
Eio.Switch.run @@ fun sw ->
|
Eio.Switch.run @@ fun sw ->
|
||||||
snd
|
setup_ ~sw ?config env;
|
||||||
@@ Fiber.pair
|
Fun.protect f ~finally:remove_exporter
|
||||||
(fun () -> setup_ ~sw ?config env)
|
) else
|
||||||
(fun () -> Fun.protect ~finally:(fun () -> remove_backend ()) f)
|
|
||||||
else
|
|
||||||
f ()
|
f ()
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,15 @@ val setup :
|
||||||
an atomic boolean. When it becomes true, background threads will all stop
|
an atomic boolean. When it becomes true, background threads will all stop
|
||||||
after a little while. *)
|
after a little while. *)
|
||||||
|
|
||||||
val remove_backend : unit -> unit
|
val remove_exporter : unit -> unit
|
||||||
(** Shutdown current backend
|
(** Shutdown current exporter
|
||||||
@since 0.12 *)
|
@since 0.12 *)
|
||||||
|
|
||||||
|
val remove_backend : unit -> unit
|
||||||
|
[@@deprecated "use remove_exporter"]
|
||||||
|
(** @since 0.12 *)
|
||||||
|
|
||||||
val with_setup :
|
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
|
(** [with_setup () f] is like [setup(); f()] but takes care of cleaning up after
|
||||||
[f()] returns See {!setup} for more details. *)
|
[f()] returns See {!setup} for more details. *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue