Merge pull request #7 from AestheticIntegration/dave-and-matt/sync-lwt-collection

Dave and matt/sync lwt collection
This commit is contained in:
Dave Aitken 2022-03-24 14:45:52 +00:00 committed by GitHub
commit 9e0cd0acc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,14 +12,6 @@ module Trace = struct
open Proto.Trace
include Trace
(** Emit asynchronously *)
let emit ?service_name ?attrs (spans:span list) : unit Lwt.t =
let fut, wake = Lwt.wait() in
let rs = make_resource_spans ?service_name ?attrs spans in
Collector.send_trace [rs]
~over:(fun () -> Lwt.wakeup_later wake ())
~ret:(fun () -> fut)
(** Sync span guard *)
let with_
?trace_state ?service_name ?(attrs=[])
@ -44,10 +36,10 @@ module Trace = struct
Lwt.catch
(fun () ->
let* x = f scope in
let+ () = finally (Ok ()) in
x)
let () = finally (Ok ()) in
Lwt.return x)
(fun e ->
let* () = finally (Error (Printexc.to_string e)) in
let () = finally (Error (Printexc.to_string e)) in
Lwt.fail e)
end