mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
Merge pull request #5 from AestheticIntegration/dave/lwt-with-scope
tidy: return scope from lwt with_ (consistent with non-lwt version)
This commit is contained in:
commit
18ae3bc41b
1 changed files with 3 additions and 2 deletions
|
|
@ -24,9 +24,10 @@ module Trace = struct
|
|||
let with_
|
||||
?trace_state ?service_name ?attrs
|
||||
?kind ?(trace_id=Trace_id.create()) ?parent ?links
|
||||
name (f:Trace_id.t * Span_id.t -> 'a Lwt.t) : 'a Lwt.t =
|
||||
name (f:Trace.scope -> 'a Lwt.t) : 'a Lwt.t =
|
||||
let start_time = Timestamp_ns.now_unix_ns() in
|
||||
let span_id = Span_id.create() in
|
||||
let scope = {trace_id;span_id;events=[]} in
|
||||
let finally ok =
|
||||
let status = match ok with
|
||||
| Ok () -> default_status ~code:Status_code_ok ()
|
||||
|
|
@ -42,7 +43,7 @@ module Trace = struct
|
|||
in
|
||||
Lwt.catch
|
||||
(fun () ->
|
||||
let* x = f (trace_id,span_id) in
|
||||
let* x = f scope in
|
||||
let+ () = finally (Ok ()) in
|
||||
x)
|
||||
(fun e ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue