mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-08 03:47:57 -04:00
add ?parent to with_span_lwt
This commit is contained in:
parent
e6f01f57ac
commit
274496fe81
2 changed files with 14 additions and 8 deletions
|
|
@ -2,9 +2,14 @@ include Trace_core
|
||||||
|
|
||||||
let k_parent : explicit_span Lwt.key = Lwt.new_key ()
|
let k_parent : explicit_span Lwt.key = Lwt.new_key ()
|
||||||
|
|
||||||
let[@inline never] with_span_lwt_real_ ?(force_toplevel = false) ?__FUNCTION__
|
let[@inline never] with_span_lwt_real_ ?parent ?(force_toplevel = false)
|
||||||
~__FILE__ ~__LINE__ ?data name f =
|
?__FUNCTION__ ~__FILE__ ~__LINE__ ?data name f =
|
||||||
let parent = Lwt.get k_parent in
|
let parent =
|
||||||
|
match parent with
|
||||||
|
| Some _ as p -> p
|
||||||
|
| None -> Lwt.get k_parent
|
||||||
|
in
|
||||||
|
|
||||||
let espan =
|
let espan =
|
||||||
match parent, force_toplevel with
|
match parent, force_toplevel with
|
||||||
| _, true | None, _ ->
|
| _, true | None, _ ->
|
||||||
|
|
@ -21,10 +26,10 @@ let[@inline never] with_span_lwt_real_ ?(force_toplevel = false) ?__FUNCTION__
|
||||||
|
|
||||||
fut)
|
fut)
|
||||||
|
|
||||||
let[@inline] with_span_lwt ?force_toplevel ?__FUNCTION__ ~__FILE__ ~__LINE__
|
let[@inline] with_span_lwt ?parent ?force_toplevel ?__FUNCTION__ ~__FILE__
|
||||||
?data name f : _ Lwt.t =
|
~__LINE__ ?data name f : _ Lwt.t =
|
||||||
if enabled () then
|
if enabled () then
|
||||||
with_span_lwt_real_ ?force_toplevel ?__FUNCTION__ ~__FILE__ ~__LINE__ ?data
|
with_span_lwt_real_ ?parent ?force_toplevel ?__FUNCTION__ ~__FILE__
|
||||||
name f
|
~__LINE__ ?data name f
|
||||||
else
|
else
|
||||||
f 0L
|
f 0L
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
(** Wrapper for tracing with Lwt.
|
(** Wrapper for tracing with Lwt.
|
||||||
|
|
||||||
@since NEXT_RELEASE. *)
|
@since NEXT_RELEASE. *)
|
||||||
|
|
@ -6,6 +5,7 @@
|
||||||
include module type of Trace_core
|
include module type of Trace_core
|
||||||
|
|
||||||
val with_span_lwt :
|
val with_span_lwt :
|
||||||
|
?parent:explicit_span ->
|
||||||
?force_toplevel:bool ->
|
?force_toplevel:bool ->
|
||||||
?__FUNCTION__:string ->
|
?__FUNCTION__:string ->
|
||||||
__FILE__:string ->
|
__FILE__:string ->
|
||||||
|
|
@ -22,5 +22,6 @@ val with_span_lwt :
|
||||||
@param force_toplevel if true, this span will not have a parent even if
|
@param force_toplevel if true, this span will not have a parent even if
|
||||||
there is one in the implicit context; ie it create a new
|
there is one in the implicit context; ie it create a new
|
||||||
{!Trace_core.enter_manual_toplevel_span} in any case.
|
{!Trace_core.enter_manual_toplevel_span} in any case.
|
||||||
|
@param parent an explicit parent, which bypasses the implicit context.
|
||||||
|
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue