mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-07 18:37:56 -05:00
small test for span tracking
This commit is contained in:
parent
f88cd7651c
commit
bb78e9babb
3 changed files with 28 additions and 0 deletions
|
|
@ -11,3 +11,8 @@
|
||||||
(preprocess
|
(preprocess
|
||||||
(pps ppx_trace))
|
(pps ppx_trace))
|
||||||
(libraries trace-tef))
|
(libraries trace-tef))
|
||||||
|
|
||||||
|
(test
|
||||||
|
(name t_debug)
|
||||||
|
(modules t_debug)
|
||||||
|
(libraries trace trace.debug trace-tef))
|
||||||
|
|
|
||||||
4
test/t_debug.expected
Normal file
4
test/t_debug.expected
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[{"pid":2,"cat":"","tid": 3,"dur": 4.00,"ts": 0.00,"name":"main","ph":"X"}trace: warning: 3 spans were not closed
|
||||||
|
span "sp1" was not closed (2 occurrences)
|
||||||
|
span "sp2" was not closed (1 occurrences)
|
||||||
|
]
|
||||||
19
test/t_debug.ml
Normal file
19
test/t_debug.ml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
let ( let@ ) = ( @@ )
|
||||||
|
|
||||||
|
let main () =
|
||||||
|
let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "main" in
|
||||||
|
|
||||||
|
let _sp1 = Trace.enter_span ~__FILE__ ~__LINE__ "sp1" in
|
||||||
|
let _sp2 = Trace.enter_span ~__FILE__ ~__LINE__ "sp2" in
|
||||||
|
let _sp1' = Trace.enter_span ~__FILE__ ~__LINE__ "sp1" in
|
||||||
|
|
||||||
|
()
|
||||||
|
|
||||||
|
let () =
|
||||||
|
Trace_tef.Private_.mock_all_ ();
|
||||||
|
let@ () =
|
||||||
|
Trace.with_setup_collector
|
||||||
|
(Trace_tef.collector ~out:`Stdout ()
|
||||||
|
|> Trace_debug.Track_spans.track ~on_lingering_spans:(`Out stdout))
|
||||||
|
in
|
||||||
|
main ()
|
||||||
Loading…
Add table
Reference in a new issue