Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
794a816
CP-311150: add Client.call to xen-api-client
edwintorok Jan 13, 2026
7ab1f5d
CP-48507: log traceparent Context when available
edwintorok Jan 18, 2026
07cbe76
CP-311150: Introduce a new internal library for tracing quicktests
edwintorok Jan 18, 2026
3481b5f
CP-311150: introduce a Bounded container
edwintorok Jan 18, 2026
2435d54
CP-311150: introduce a simple disk backend
edwintorok Jan 18, 2026
453115c
CP-311150: add span_status
edwintorok Jan 18, 2026
2cea380
CP-311150: add Scope wrapper
edwintorok Jan 18, 2026
54f661b
CP-311150: introduce a Sampler
edwintorok Jan 18, 2026
2b618dc
CP-311150: introduce a SpanProcessor
edwintorok Jan 18, 2026
49f2e98
CP-311150: introduce a Trace module
edwintorok Jan 18, 2026
e5402c3
CP-311150: a backend that prints a simplified trace to the console
edwintorok Jan 18, 2026
59f816d
CP-311150: add opentelemetry wrappers for XAPI client RPC calls
edwintorok Jan 22, 2026
86798af
CP-311150: introduce functor to combine backends
edwintorok Jan 18, 2026
b9a0cd2
CP-311150: test code for new library
edwintorok Jan 18, 2026
08d7d9c
CP-311150: introduce wait_for_all_with_progress
edwintorok Jan 19, 2026
e1fdb7d
CP-311150: show ms in progress bar summary
edwintorok Jan 28, 2026
3999de6
CP-311150: forward Opentelemetry W3C TraceContext headers for RPC cal…
edwintorok Jan 18, 2026
5d34dfa
CP-311150: wrappers for XAPI objects that print the object on failure
edwintorok Jan 18, 2026
4ec06d5
CP-311148: quicktest helper functions for filling memory with VMs
edwintorok Jan 22, 2026
146f2c3
CP-311148: calibrate VM memory overhead measurements
edwintorok Jan 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ocaml/idl/ocaml_backend/gen_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ let gen_module api : O.Module.t =
; " | Rpc.Enum ((Rpc.String code) :: args) -> return (server_failure \
code (List.map Rpc.string_of_rpc args))"
; " | rpc -> failwith (\"Client.rpc: \" ^ Rpc.to_string rpc)"
; "type client = {rpc: Rpc.call -> Rpc.response; session_id: ref_session}"
; "type 'a api = rpc:(Rpc.call -> Rpc.response) -> session_id:ref_session \
-> 'a"
; ""
; "let call {rpc; session_id} f = f ~rpc ~session_id"
; ""
]
in
let postamble =
Expand Down
16 changes: 14 additions & 2 deletions ocaml/libs/log/debug.ml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ let gettimestring () =
allocate a new string only when necessary *)
let escape = Astring.String.Ascii.escape

let remote_context = Ambient_context_thread_local.Thread_local.create ()

let set_remote_context = function
| None ->
Ambient_context_thread_local.Thread_local.remove remote_context
| Some context ->
Ambient_context_thread_local.Thread_local.set remote_context context

let format include_time brand priority message =
let id = get_thread_id () in
let task, name =
Expand All @@ -102,13 +110,17 @@ let format include_time brand priority message =
| Some {desc; client= Some client} ->
(desc, Printf.sprintf "%s->%s" client name)
in
Printf.sprintf "[%s%5s||%d %s|%s|%s] %s"
let remote_context =
Ambient_context_thread_local.Thread_local.get remote_context
|> Option.value ~default:""
in
Printf.sprintf "[%s%5s|%s|%d %s|%s|%s] %s"
( if include_time then
gettimestring ()
else
""
)
priority id name task brand message
priority remote_context id name task brand message

let print_debug = ref false

Expand Down
3 changes: 3 additions & 0 deletions ocaml/libs/log/debug.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ val with_thread_associated :
val with_thread_named : string -> ('a -> 'b) -> 'a -> 'b
(** Do an action with a name associated with the current thread *)

val set_remote_context : string option -> unit
(** [set_remote_context context] sets the remote context, will be logged as the 2nd field *)

module type BRAND = sig val name : string end

val gettimestring : unit -> string
Expand Down
1 change: 1 addition & 0 deletions ocaml/libs/log/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(language c)
(names syslog_stubs))
(libraries
ambient-context.thread_local
astring
fmt
mtime
Expand Down
12 changes: 12 additions & 0 deletions ocaml/libs/tracing/tracing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ module Span = struct

let get_trace_context t = t.context |> SpanContext.context_of_span_context

let[@inline always] set_trace_context trace_context =
trace_context |> TraceContext.traceparent_of |> Debug.set_remote_context

let start ?(attributes = Attributes.empty)
?(trace_context : TraceContext.t option) ~name ~parent ~span_kind () =
let trace_id, extra_context, depth =
Expand All @@ -348,6 +351,7 @@ module Span = struct
, TraceContext.baggage_depth_of span_parent.context.trace_context + 1
)
in
set_trace_context extra_context ;
let span_id = Span_id.make () in
let extra_context_with_depth =
TraceContext.(
Expand Down Expand Up @@ -405,7 +409,15 @@ module Span = struct
let get_attributes span =
Attributes.fold (fun k v tags -> (k, v) :: tags) span.attributes []

let[@inline always] traceparent_of_parent parent =
parent |> get_context |> SpanContext.to_traceparent

let finish ?(attributes = Attributes.empty) ~span () =
(* Unfold the stack: set parent's traceparent if any.
If at top level then remove the trace context.
This ensures we don't have a stale trace context set.
*)
span.parent |> Option.map traceparent_of_parent |> Debug.set_remote_context ;
let attributes =
Attributes.union (fun _k a _b -> Some a) attributes span.attributes
in
Expand Down
5 changes: 5 additions & 0 deletions ocaml/quicktest/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
ezxenstore
ezxenstore.watch
fmt
fmt.tty
forkexec
http_lib
mtime
mtime.clock.os
cli_progress_bar
quicktest_trace
quicktest_trace_api
quicktest_trace_rpc
pam
qcheck-alcotest
result
Expand Down
20 changes: 20 additions & 0 deletions ocaml/quicktest/quicktest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,24 @@ let qchecks =
|> List.map @@ fun (name, test) ->
(name, List.map QCheck_alcotest.(to_alcotest ~long:true) test)

let setup_tty () =
let style_renderer =
if !Quicktest_args.use_colour then
(* use default style, auto-detect color support *)
None
else
(* never use color *)
Some `None
in
Fmt_tty.setup_std_outputs ?style_renderer ()

let () =
Quicktest_args.parse () ;
setup_tty () ;
let open Quicktest_trace in
Opentelemetry.Globals.service_name := "quicktest" ;
TeeBackend.with_default_setup () @@ fun () ->
Sys.catch_break true ;
Qt_filter.wrap (fun () ->
let suite =
[
Expand All @@ -36,6 +52,10 @@ let () =
; ("Quicktest_async_calls", Quicktest_async_calls.tests ())
; ("Quicktest_vm_import_export", Quicktest_vm_import_export.tests ())
; ("Quicktest_vm_lifecycle", Quicktest_vm_lifecycle.tests ())
; ( "Quicktest_vm_calibrate_cleanup"
, Quicktest_vm_calibrate.tests_cleanup ()
)
; ("Quicktest_vm_calibrate", Quicktest_vm_calibrate.tests ())
; ("Quicktest_vm_snapshot", Quicktest_vm_snapshot.tests ())
; ( "Quicktest_vdi_ops_data_integrity"
, Quicktest_vdi_ops_data_integrity.tests ()
Expand Down
Loading
Loading