Closed c-cube closed 1 month ago
Would something like below be reasonable ?
let[@inline] record_exception (scope : t) (exn : unit -> exn) : unit =
if Collector.has_backend () then (
let ev =
Event.make "exception"
~attrs:
[
"message", `String (Printexc.to_string (exn ()));
"type", `String (Printexc.exn_slot_name (exn ()));
"stacktrace", `String (Printexc.get_backtrace ());
]
in
scope.events <- ev :: scope.events
)
I think this should rather look like:
let record_exception (scope:t) (exn:exn) (bt:Printexc.raw_backtrace) : unit =
if …
reason is, the exception is never going to be lazy; and afaik bt
has to be collected first thing when the exception occurs, or else the stack frame might be clobbered by intermediate computations.
https://opentelemetry.io/docs/specs/semconv/exceptions/exceptions-spans/