Skip to content

Commit 5b3fbc3

Browse files
committed
CA-285213 add error logging for Gpumon_interface
This adds logging for all errors passing through the Gpumon_interface. Signed-off-by: Christian Lindig <[email protected]>
1 parent 86f6a60 commit 5b3fbc3

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

gpumon/gpumon_interface.ml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
open Rpc
1616
open Idl
1717

18+
module D = Debug.Make(struct let name = "gpumon_interface" end)
19+
open D
20+
1821
let service_name = "gpumon"
1922
let queue_name = Xcp_service.common_prefix ^ service_name
2023
let xml_path = "/var/xapi/" ^ service_name
@@ -73,14 +76,32 @@ type gpu_errors =
7376

7477
exception Gpumon_error of gpu_errors
7578

79+
let () = (* register printer *)
80+
let sprintf = Printf.sprintf in
81+
let string_of_error e =
82+
Rpcmarshal.marshal gpu_errors.Rpc.Types.ty e |> Rpc.to_string in
83+
let printer = function
84+
| Gpumon_error e ->
85+
Some (sprintf "Gpumon_interface.Gpumon_error(%s)" (string_of_error e))
86+
| _ -> None in
87+
Printexc.register_printer printer
88+
7689
(** Error handler *)
77-
let gpu_err = Error.{
78-
def = gpu_errors;
79-
raiser = (fun e -> raise (Gpumon_error e));
80-
matcher = (function
81-
| Gpumon_error e -> Some e
82-
| e -> Some (Internal_error (Printexc.to_string e)))
83-
}
90+
let gpu_err = Error.
91+
{ def = gpu_errors
92+
; raiser = (fun e ->
93+
log_backtrace ();
94+
let exn = Gpumon_error e in
95+
error "%s (%s)" (Printexc.to_string exn) __LOC__;
96+
raise exn)
97+
; matcher = (function
98+
| Gpumon_error e as exn ->
99+
error "%s (%s)" (Printexc.to_string exn) __LOC__;
100+
Some e
101+
| exn ->
102+
error "%s (%s)" (Printexc.to_string exn) __LOC__;
103+
Some (Internal_error (Printexc.to_string exn)))
104+
}
84105

85106
(** Functor to autogenerate API calls *)
86107
module RPC_API(R : RPC) = struct

0 commit comments

Comments
 (0)