Skip to content

Commit cb64cd6

Browse files
committed
CP-50001: Instrument Xapi_xenops.events_watch
This function is called recursively and the context span is only closed on failure. This makes it hard to read the trace. Therefore, I am resetting the context tracing each recursion step and now each recursion step will have its own trace. Signed-off-by: Gabriel Buica <[email protected]>
1 parent d9a3268 commit cb64cd6

File tree

1 file changed

+58
-53
lines changed

1 file changed

+58
-53
lines changed

ocaml/xapi/xapi_xenops.ml

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,60 +2930,65 @@ let update_task ~__context queue_name id =
29302930
error "xenopsd event: Caught %s while updating task" (string_of_exn e)
29312931

29322932
let rec events_watch ~__context cancel queue_name from =
2933-
let@ __context = Context.with_tracing ~__context __FUNCTION__ in
2934-
let dbg = Context.string_of_task_and_tracing __context in
2935-
if Xapi_fist.delay_xenopsd_event_threads () then Thread.delay 30.0 ;
2936-
let module Client = (val make_client queue_name : XENOPS) in
2937-
let barriers, events, next = Client.UPDATES.get dbg from None in
2938-
if !cancel then
2939-
raise (Api_errors.Server_error (Api_errors.task_cancelled, [])) ;
2940-
let done_events = ref [] in
2941-
let already_done x = List.mem x !done_events in
2942-
let add_event x = done_events := x :: !done_events in
2943-
let do_updates l =
2944-
let open Dynamic in
2945-
List.iter
2946-
(fun ev ->
2947-
debug "Processing event: %s"
2948-
(ev |> Dynamic.rpc_of_id |> Jsonrpc.to_string) ;
2949-
if already_done ev then
2950-
debug "Skipping (already processed this round)"
2951-
else (
2952-
add_event ev ;
2953-
match ev with
2954-
| Vm id ->
2955-
debug "xenops event on VM %s" id ;
2956-
update_vm ~__context id
2957-
| Vbd id ->
2958-
debug "xenops event on VBD %s.%s" (fst id) (snd id) ;
2959-
update_vbd ~__context id
2960-
| Vif id ->
2961-
debug "xenops event on VIF %s.%s" (fst id) (snd id) ;
2962-
update_vif ~__context id
2963-
| Pci id ->
2964-
debug "xenops event on PCI %s.%s" (fst id) (snd id) ;
2965-
update_pci ~__context id
2966-
| Vgpu id ->
2967-
debug "xenops event on VGPU %s.%s" (fst id) (snd id) ;
2968-
update_vgpu ~__context id
2969-
| Vusb id ->
2970-
debug "xenops event on VUSB %s.%s" (fst id) (snd id) ;
2971-
update_vusb ~__context id
2972-
| Task id ->
2973-
debug "xenops event on Task %s" id ;
2974-
update_task ~__context queue_name id
2975-
)
2976-
)
2977-
l
2978-
in
2979-
List.iter
2980-
(fun (id, b_events) ->
2981-
debug "Processing barrier %d" id ;
2982-
do_updates b_events ;
2983-
Events_from_xenopsd.wakeup queue_name dbg id
2933+
Context.complete_tracing __context ;
2934+
let next =
2935+
Context.with_tracing ~__context __FUNCTION__ (fun __context ->
2936+
let dbg = Context.string_of_task_and_tracing __context in
2937+
if Xapi_fist.delay_xenopsd_event_threads () then Thread.delay 30.0 ;
2938+
let module Client = (val make_client queue_name : XENOPS) in
2939+
let barriers, events, next = Client.UPDATES.get dbg from None in
2940+
if !cancel then
2941+
raise (Api_errors.Server_error (Api_errors.task_cancelled, [])) ;
2942+
let done_events = ref [] in
2943+
let already_done x = List.mem x !done_events in
2944+
let add_event x = done_events := x :: !done_events in
2945+
let do_updates l =
2946+
let open Dynamic in
2947+
List.iter
2948+
(fun ev ->
2949+
debug "Processing event: %s"
2950+
(ev |> Dynamic.rpc_of_id |> Jsonrpc.to_string) ;
2951+
if already_done ev then
2952+
debug "Skipping (already processed this round)"
2953+
else (
2954+
add_event ev ;
2955+
match ev with
2956+
| Vm id ->
2957+
debug "xenops event on VM %s" id ;
2958+
update_vm ~__context id
2959+
| Vbd id ->
2960+
debug "xenops event on VBD %s.%s" (fst id) (snd id) ;
2961+
update_vbd ~__context id
2962+
| Vif id ->
2963+
debug "xenops event on VIF %s.%s" (fst id) (snd id) ;
2964+
update_vif ~__context id
2965+
| Pci id ->
2966+
debug "xenops event on PCI %s.%s" (fst id) (snd id) ;
2967+
update_pci ~__context id
2968+
| Vgpu id ->
2969+
debug "xenops event on VGPU %s.%s" (fst id) (snd id) ;
2970+
update_vgpu ~__context id
2971+
| Vusb id ->
2972+
debug "xenops event on VUSB %s.%s" (fst id) (snd id) ;
2973+
update_vusb ~__context id
2974+
| Task id ->
2975+
debug "xenops event on Task %s" id ;
2976+
update_task ~__context queue_name id
2977+
)
2978+
)
2979+
l
2980+
in
2981+
List.iter
2982+
(fun (id, b_events) ->
2983+
debug "Processing barrier %d" id ;
2984+
do_updates b_events ;
2985+
Events_from_xenopsd.wakeup queue_name dbg id
2986+
)
2987+
barriers ;
2988+
do_updates events ;
2989+
next
29842990
)
2985-
barriers ;
2986-
do_updates events ;
2991+
in
29872992
events_watch ~__context cancel queue_name (Some next)
29882993

29892994
let events_from_xenopsd queue_name =

0 commit comments

Comments
 (0)