mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -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 =
|
||||
if enable then (
|
||||
let open Lwt.Syntax in
|
||||
setup_ ~config ();
|
||||
|
||||
Lwt.catch
|
||||
(fun () ->
|
||||
let* res = f () in
|
||||
let+ () = remove_exporter () in
|
||||
res)
|
||||
(fun exn ->
|
||||
let* () = remove_exporter () in
|
||||
Lwt.reraise exn)
|
||||
Lwt.finalize f remove_exporter
|
||||
) else
|
||||
f ()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue