mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-08 03:47:57 -04:00
fix trace-tef: cleanup
This commit is contained in:
parent
c58810f4e8
commit
718cbf120f
1 changed files with 8 additions and 4 deletions
|
|
@ -182,8 +182,9 @@ let bg_thread ~out (events : event B_queue.t) : unit =
|
||||||
}
|
}
|
||||||
| E_exit_span { id; time_us = stop_us } ->
|
| E_exit_span { id; time_us = stop_us } ->
|
||||||
(match Span_tbl.find_opt spans id with
|
(match Span_tbl.find_opt spans id with
|
||||||
| None -> (* bug! *) ()
|
| None -> (* bug! TODO: emit warning *) ()
|
||||||
| Some { (* __FUNCTION__; __FILE__; __LINE__; *) tid; name; start_us } ->
|
| Some { (* __FUNCTION__; __FILE__; __LINE__; *) tid; name; start_us } ->
|
||||||
|
Span_tbl.remove spans id;
|
||||||
Writer.emit_duration_event ~tid ~name ~start:start_us ~end_:stop_us
|
Writer.emit_duration_event ~tid ~name ~start:start_us ~end_:stop_us
|
||||||
~args:[] writer)
|
~args:[] writer)
|
||||||
in
|
in
|
||||||
|
|
@ -193,7 +194,12 @@ let bg_thread ~out (events : event B_queue.t) : unit =
|
||||||
let ev = B_queue.pop events in
|
let ev = B_queue.pop events in
|
||||||
handle_ev ev
|
handle_ev ev
|
||||||
done
|
done
|
||||||
with B_queue.Closed -> ()
|
with B_queue.Closed ->
|
||||||
|
(* warn if app didn't close all spans *)
|
||||||
|
if Span_tbl.length spans > 0 then
|
||||||
|
Printf.eprintf "trace-tef: warning: %d spans were not closed\n%!"
|
||||||
|
(Span_tbl.length spans);
|
||||||
|
()
|
||||||
|
|
||||||
type output =
|
type output =
|
||||||
[ `Stdout
|
[ `Stdout
|
||||||
|
|
@ -218,9 +224,7 @@ let collector ~out () : collector =
|
||||||
|
|
||||||
let shutdown () =
|
let shutdown () =
|
||||||
if A.exchange active false then (
|
if A.exchange active false then (
|
||||||
Printf.eprintf "shutdown\n%!";
|
|
||||||
B_queue.close events;
|
B_queue.close events;
|
||||||
Printf.eprintf "wait\n%!";
|
|
||||||
Thread.join t_write
|
Thread.join t_write
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue