Skip to content

Commit

Permalink
CP-48195: Add with_tracing helper function
Browse files Browse the repository at this point in the history
Adds `with_tracing` helper function to `forkhelpers.ml`.

This is to show that there are no more cycle dependecies between
`tracing` library and `forexecd` and it will be used in a follow-up PR
to instrument `forkhelpers` with tracing.

Signed-off-by: Gabriel Buica <[email protected]>
  • Loading branch information
GabrielBuica committed Apr 19, 2024
1 parent af2f199 commit d049d43
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions forkexec.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ depends: [
"xapi-log"
"xapi-stdext-pervasives"
"xapi-stdext-unix"
"xapi-tracing"
]
synopsis: "Sub-process control service for xapi"
description:
Expand Down
1 change: 1 addition & 0 deletions forkexec.opam.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ depends: [
"xapi-log"
"xapi-stdext-pervasives"
"xapi-stdext-unix"
"xapi-tracing"
]
synopsis: "Sub-process control service for xapi"
description:
Expand Down
1 change: 1 addition & 0 deletions ocaml/forkexecd/lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
xapi-log
xapi-stdext-pervasives
xapi-stdext-unix
xapi-tracing
)
(preprocess
(pps ppx_deriving_rpc)))
4 changes: 4 additions & 0 deletions ocaml/forkexecd/lib/forkhelpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ let test_path =

let runtime_path = Option.value ~default:"/var" test_path

let _with_tracing ?tracing ~name f =
let name = Printf.sprintf "forkhelpers.%s" name in
Tracing.with_tracing ?parent:tracing ~name f

let finally = Xapi_stdext_pervasives.Pervasiveext.finally

type pidty = Unix.file_descr * int
Expand Down
4 changes: 1 addition & 3 deletions ocaml/tests/test_observer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ module TracerProvider = struct
let find_provider_exn ~name =
let providers = get_tracer_providers () in
match
List.find_opt
(fun x -> TracerProvider.get_name_label x = name)
providers
List.find_opt (fun x -> TracerProvider.get_name_label x = name) providers
with
| Some provider ->
provider
Expand Down

0 comments on commit d049d43

Please sign in to comment.