From 9e859e0ff48da0e285d987f96cc31008dcfb40b1 Mon Sep 17 00:00:00 2001 From: Steven Woods Date: Thu, 16 Nov 2023 10:52:11 +0000 Subject: [PATCH 1/2] CP-46004: Finish eventgen span to remove spans table clutter Signed-off-by: Steven Woods --- ocaml/xapi/eventgen.ml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ocaml/xapi/eventgen.ml b/ocaml/xapi/eventgen.ml index 92fe0598fbf..a3ef6e60608 100644 --- a/ocaml/xapi/eventgen.ml +++ b/ocaml/xapi/eventgen.ml @@ -95,8 +95,7 @@ let events_of_other_tbl_refs other_tbl_refs = open Db_cache_types open Db_action_helper -let database_callback event db = - let context = Context.make "eventgen" in +let database_callback_inner event db context = let other_tbl_refs tblname = follow_references tblname in let other_tbl_refs_for_this_field tblname fldname = List.filter (fun (_, fld) -> fld = fldname) (other_tbl_refs tblname) @@ -258,3 +257,9 @@ let database_callback event db = events_notify ~snapshot:s tbl "mod" ref ) other_tbl_events + +let database_callback event db = + let context = Context.make "eventgen" in + Xapi_stdext_pervasives.Pervasiveext.finally + (fun () -> database_callback_inner event db context) + (fun () -> Context.complete_tracing context) From f8bf6bbda399d8a4f71cc9552a24dee09544cbee Mon Sep 17 00:00:00 2001 From: Steven Woods Date: Thu, 16 Nov 2023 10:52:37 +0000 Subject: [PATCH 2/2] Add span table lengths to export span to help catch future issues. Signed-off-by: Steven Woods --- ocaml/libs/tracing/tracing.ml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ocaml/libs/tracing/tracing.ml b/ocaml/libs/tracing/tracing.ml index 4555d646d32..da6819bdae6 100644 --- a/ocaml/libs/tracing/tracing.ml +++ b/ocaml/libs/tracing/tracing.ml @@ -761,6 +761,12 @@ module Export = struct [ ("export.span.count", List.length all_spans |> string_of_int) ; ("export.endpoint", endpoint_to_string endpoint) + ; ( "xs.tracing.spans_table.count" + , Hashtbl.length Spans.spans |> string_of_int + ) + ; ( "xs.tracing.finished_spans_table.count" + , Hashtbl.length traces |> string_of_int + ) ] in let@ _ = with_tracing ~parent ~attributes ~name in