mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-11 04:58:39 -04:00
otel-cohttp-lwt: simplify cleanup
This commit is contained in:
parent
c9f5a27b22
commit
46960e2021
1 changed files with 1 additions and 9 deletions
|
|
@ -135,16 +135,8 @@ let remove_backend = remove_exporter
|
||||||
|
|
||||||
let with_setup ?(config = Config.make ()) ?(enable = true) () f : _ Lwt.t =
|
let with_setup ?(config = Config.make ()) ?(enable = true) () f : _ Lwt.t =
|
||||||
if enable then (
|
if enable then (
|
||||||
let open Lwt.Syntax in
|
|
||||||
setup_ ~config ();
|
setup_ ~config ();
|
||||||
|
|
||||||
Lwt.catch
|
Lwt.finalize f remove_exporter
|
||||||
(fun () ->
|
|
||||||
let* res = f () in
|
|
||||||
let+ () = remove_exporter () in
|
|
||||||
res)
|
|
||||||
(fun exn ->
|
|
||||||
let* () = remove_exporter () in
|
|
||||||
Lwt.reraise exn)
|
|
||||||
) else
|
) else
|
||||||
f ()
|
f ()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue