mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 04:17:56 -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_
|
let with_
|
||||||
?trace_state ?service_name ?attrs
|
?trace_state ?service_name ?attrs
|
||||||
?kind ?(trace_id=Trace_id.create()) ?parent ?links
|
?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 start_time = Timestamp_ns.now_unix_ns() in
|
||||||
let span_id = Span_id.create() in
|
let span_id = Span_id.create() in
|
||||||
|
let scope = {trace_id;span_id;events=[]} in
|
||||||
let finally ok =
|
let finally ok =
|
||||||
let status = match ok with
|
let status = match ok with
|
||||||
| Ok () -> default_status ~code:Status_code_ok ()
|
| Ok () -> default_status ~code:Status_code_ok ()
|
||||||
|
|
@ -42,7 +43,7 @@ module Trace = struct
|
||||||
in
|
in
|
||||||
Lwt.catch
|
Lwt.catch
|
||||||
(fun () ->
|
(fun () ->
|
||||||
let* x = f (trace_id,span_id) in
|
let* x = f scope in
|
||||||
let+ () = finally (Ok ()) in
|
let+ () = finally (Ok ()) in
|
||||||
x)
|
x)
|
||||||
(fun e ->
|
(fun e ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue