Skip to content

Commit 7bede83

Browse files
committed
CP-50001: Add attributes to updates in events_watch
Signed-off-by: Gabriel Buica <[email protected]>
1 parent cb64cd6 commit 7bede83

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

ocaml/xapi/context.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,12 @@ let with_forwarded_task ?http_other_config ?session_id ?origin task_id f =
532532
in
533533
finally_destroy_context ~__context f
534534

535-
let with_tracing ?originator ~__context name f =
535+
let with_tracing ?(attributes = []) ?originator ~__context name f =
536536
let open Tracing in
537537
let parent = __context.tracing in
538538
let span_attributes =
539539
Attributes.attr_of_originator originator
540+
@ attributes
540541
@ make_attributes ~task_id:__context.task_id
541542
?session_id:__context.session_id ()
542543
in

ocaml/xapi/context.mli

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ val with_forwarded_task :
185185
then ensure [__context] is destroyed.*)
186186

187187
val with_tracing :
188-
?originator:string -> __context:t -> string -> (t -> 'a) -> 'a
188+
?attributes:(string * string) list
189+
-> ?originator:string
190+
-> __context:t
191+
-> string
192+
-> (t -> 'a)
193+
-> 'a
189194

190195
val set_client_span : t -> Tracing.Span.t option

ocaml/xapi/xapi_xenops.ml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,11 @@ let update_vm_internal ~__context ~id ~self ~previous ~info ~localhost =
24612461
)
24622462

24632463
let update_vm ~__context id =
2464-
let@ __context = Context.with_tracing ~__context __FUNCTION__ in
2464+
let@ __context =
2465+
Context.with_tracing
2466+
~attributes:[("xapi.event.on.vm", id)]
2467+
~__context __FUNCTION__
2468+
in
24652469
try
24662470
if Events_from_xenopsd.are_suppressed id then
24672471
debug "xenopsd event: ignoring event for VM (VM %s migrating away)" id
@@ -2484,7 +2488,11 @@ let update_vm ~__context id =
24842488
(string_of_exn e)
24852489

24862490
let update_vbd ~__context (id : string * string) =
2487-
let@ __context = Context.with_tracing ~__context __FUNCTION__ in
2491+
let@ __context =
2492+
Context.with_tracing
2493+
~attributes:[("xapi.event.on.vm", fst id); ("xapi.event.on.vbd", snd id)]
2494+
~__context __FUNCTION__
2495+
in
24882496
try
24892497
if Events_from_xenopsd.are_suppressed (fst id) then
24902498
debug "xenopsd event: ignoring event for VBD (VM %s migrating away)"
@@ -2587,7 +2595,11 @@ let update_vbd ~__context (id : string * string) =
25872595
error "xenopsd event: Caught %s while updating VBD" (string_of_exn e)
25882596

25892597
let update_vif ~__context id =
2590-
let@ __context = Context.with_tracing ~__context __FUNCTION__ in
2598+
let@ __context =
2599+
Context.with_tracing
2600+
~attributes:[("xapi.event.on.vm", fst id); ("xapi.event.on.vif", snd id)]
2601+
~__context __FUNCTION__
2602+
in
25912603
try
25922604
if Events_from_xenopsd.are_suppressed (fst id) then
25932605
debug "xenopsd event: ignoring event for VIF (VM %s migrating away)"
@@ -2696,7 +2708,11 @@ let update_vif ~__context id =
26962708
error "xenopsd event: Caught %s while updating VIF" (string_of_exn e)
26972709

26982710
let update_pci ~__context id =
2699-
let@ __context = Context.with_tracing ~__context __FUNCTION__ in
2711+
let@ __context =
2712+
Context.with_tracing
2713+
~attributes:[("xapi.event.on.vm", fst id); ("xapi.event.on.pci", snd id)]
2714+
~__context __FUNCTION__
2715+
in
27002716
try
27012717
if Events_from_xenopsd.are_suppressed (fst id) then
27022718
debug "xenopsd event: ignoring event for PCI (VM %s migrating away)"
@@ -2765,7 +2781,11 @@ let update_pci ~__context id =
27652781
error "xenopsd event: Caught %s while updating PCI" (string_of_exn e)
27662782

27672783
let update_vgpu ~__context id =
2768-
let@ __context = Context.with_tracing ~__context __FUNCTION__ in
2784+
let@ __context =
2785+
Context.with_tracing
2786+
~attributes:[("xapi.event.on.vm", fst id); ("xapi.event.on.vgpu", snd id)]
2787+
~__context __FUNCTION__
2788+
in
27692789
try
27702790
if Events_from_xenopsd.are_suppressed (fst id) then
27712791
debug "xenopsd event: ignoring event for VGPU (VM %s migrating away)"
@@ -2830,7 +2850,11 @@ let update_vgpu ~__context id =
28302850
error "xenopsd event: Caught %s while updating VGPU" (string_of_exn e)
28312851

28322852
let update_vusb ~__context (id : string * string) =
2833-
let@ __context = Context.with_tracing ~__context __FUNCTION__ in
2853+
let@ __context =
2854+
Context.with_tracing
2855+
~attributes:[("xapi.event.on.vm", fst id); ("xapi.event.on.vusb", snd id)]
2856+
~__context __FUNCTION__
2857+
in
28342858
try
28352859
if Events_from_xenopsd.are_suppressed (fst id) then
28362860
debug "xenopsd event: ignoring event for VUSB (VM %s migrating away)"
@@ -2896,7 +2920,11 @@ let unregister_task __context queue_name id =
28962920
id
28972921

28982922
let update_task ~__context queue_name id =
2899-
let@ __context = Context.with_tracing ~__context __FUNCTION__ in
2923+
let@ __context =
2924+
Context.with_tracing
2925+
~attributes:[("xapi.event.on.task", id)]
2926+
~__context __FUNCTION__
2927+
in
29002928
try
29012929
let self = TaskHelper.id_to_task_exn (TaskHelper.Xenops (queue_name, id)) in
29022930
(* throws Not_found *)

0 commit comments

Comments
 (0)