mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-08 03:47:57 -04:00
ppx: make sure to reconstruct backtraces
This commit is contained in:
parent
78edd779d4
commit
bb520d90b5
3 changed files with 11 additions and 10 deletions
|
|
@ -100,11 +100,11 @@ let f x y z =
|
|||
do_sth y;
|
||||
begin
|
||||
let _trace_span = Trace_core.enter_span ~__FILE__ ~__LINE__ "sub-span" in
|
||||
try
|
||||
let _res = do_sth z in
|
||||
match do_sth z with
|
||||
| res ->
|
||||
Trace_core.exit_span _trace_span;
|
||||
_res
|
||||
with e ->
|
||||
res
|
||||
| exception e ->
|
||||
Trace_core.exit_span _trace_span
|
||||
raise e
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ tags: ["trace" "tracing" "observability" "profiling" "ppx"]
|
|||
homepage: "https://github.com/c-cube/ocaml-trace"
|
||||
bug-reports: "https://github.com/c-cube/ocaml-trace/issues"
|
||||
depends: [
|
||||
"ocaml" {>= "4.08"}
|
||||
"ocaml" {>= "4.12"}
|
||||
"ppxlib"
|
||||
"trace" {= version}
|
||||
"trace-tef" {= version & with-test}
|
||||
|
|
|
|||
|
|
@ -52,13 +52,14 @@ let expand_top_let ~ctxt rec_flag (vbs : _ list) =
|
|||
let _trace_span =
|
||||
Trace_core.enter_span ~__FILE__ ~__LINE__ __FUNCTION__
|
||||
in
|
||||
try
|
||||
let _trace_ppx_res = [%e e] in
|
||||
match [%e e] with
|
||||
| res ->
|
||||
Trace_core.exit_span _trace_span;
|
||||
__trace_ppx_res
|
||||
with exn ->
|
||||
res
|
||||
| exception exn ->
|
||||
let bt = Printexc.get_raw_backtrace () in
|
||||
Trace_core.exit_span _trace_span;
|
||||
raise exn]
|
||||
Printexc.raise_with_backtrace exn bt]
|
||||
in
|
||||
|
||||
let tr_vb (vb : value_binding) : value_binding =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue