Logging, runtime tracing, and the obs performance profiler for OCaml
0

Configure Feed

Select the types of activity you want to include in your feed.

observe: delete Observe_eio

Observe_eio.setup was Observe.setup composed with Probe_eio.install. Bolting a scheduler's span provider onto a logging library gave observe a dependency on eio for one function call, and gave every Eio program a second setup entry point to choose between.

A library exposing an Eio interface installs the provider for its users, which is what quic_eio, h2_eio, slirp_eio and iperf3_eio already do. The two programs that drove Eio themselves now do the same. Observe.setup is the single call for Eio and non-Eio programs alike.

+7 -58
+1 -1
bench/dune
··· 6 6 (executable 7 7 (name workload) 8 8 (modules workload) 9 - (libraries observe observe.eio probe eio eio_main cmdliner unix)) 9 + (libraries observe probe probe.eio eio eio_main cmdliner unix))
+6 -2
bench/workload.ml
··· 3 3 [Probe.span] / [Probe.with_span]; obs is expected to show them as operations 4 4 in the report. *) 5 5 6 + (* Span context must be fiber-local before any fiber opens a span, or the 7 + concurrent request fibers below nest under one another. *) 8 + let () = Probe_eio.install () 9 + 6 10 let request_span = 7 11 Probe.span "workload.request" ~doc:"one synthetic request" 8 12 Probe.Fields.(obj (fun id -> id) |> field "id" int ~enc:Fun.id |> seal) ··· 121 125 Term.( 122 126 const (fun () child phase requests fibers -> 123 127 if child then run_child () else run phase requests fibers) 124 - $ Observe_eio.setup "workload" 125 - $ child_arg $ phase_arg $ requests_arg $ fibers_arg) 128 + $ Observe.setup "workload" $ child_arg $ phase_arg $ requests_arg 129 + $ fibers_arg) 126 130 127 131 let () = exit (Cmd.eval cmd)
-4
lib/eio/dune
··· 1 - (library 2 - (name observe_eio) 3 - (public_name observe.eio) 4 - (libraries observe probe.eio cmdliner))
-4
lib/eio/observe_eio.ml
··· 1 - let setup ?json_reporter app = 2 - Cmdliner.Term.map 3 - (fun () -> Probe_eio.install ()) 4 - (Observe.setup ?json_reporter app)
-11
lib/eio/observe_eio.mli
··· 1 - (** Eio-aware {!Observe} setup. 2 - 3 - The single setup call for an Eio program: it configures logging exactly like 4 - {!Observe.setup} and also installs the ocaml-probe Eio provider 5 - ({!Probe_eio.install}), so {!Probe.with_span} span context is fiber-local 6 - without a separate call. *) 7 - 8 - val setup : 9 - ?json_reporter:Observe.json_reporter option -> string -> unit Cmdliner.Term.t 10 - (** [setup app] is {!Observe.setup} [app] composed with {!Probe_eio.install}, so 11 - an Eio program's probe spans nest per fiber with nothing else to wire. *)
-3
test/eio/dune
··· 1 - (test 2 - (name test) 3 - (libraries observe.eio probe eio eio_main cmdliner alcotest))
-1
test/eio/test.ml
··· 1 - let () = Alcotest.run "observe_eio" [ Test_observe_eio.suite ]
-28
test/eio/test_observe_eio.ml
··· 1 - let span = Probe.span "observe_eio.test" Probe.Fields.unit 2 - 3 - (* Observe_eio.setup must install the Probe Eio provider as a side effect of 4 - evaluating its term. With it installed, a span entered in one fiber is not 5 - observed by a concurrent sibling of the same domain; this test runs the setup 6 - term (rather than calling Probe_eio.install directly) and checks that 7 - isolation, so it fails if setup forgot to install. *) 8 - let test_setup_installs_provider () = 9 - let cmd = 10 - Cmdliner.Cmd.v (Cmdliner.Cmd.info "test") (Observe_eio.setup "test") 11 - in 12 - ignore (Cmdliner.Cmd.eval ~argv:[| "test" |] cmd); 13 - Probe.set_sampling_active true; 14 - Fun.protect ~finally:(fun () -> Probe.set_sampling_active false) @@ fun () -> 15 - Eio_main.run @@ fun _ -> 16 - let sibling = ref (Some (Probe.Span_id.of_int64 0L)) in 17 - Eio.Fiber.both 18 - (fun () -> Probe.with_span span () (fun () -> Eio.Fiber.yield ())) 19 - (fun () -> sibling := Probe.current ()); 20 - Alcotest.(check bool) 21 - "setup installed fiber-local span context" true (Option.is_none !sibling) 22 - 23 - let suite = 24 - ( "observe_eio", 25 - [ 26 - Alcotest.test_case "setup installs provider" `Quick 27 - test_setup_installs_provider; 28 - ] )
-4
test/eio/test_observe_eio.mli
··· 1 - (** Tests for {!Observe_eio}. *) 2 - 3 - val suite : string * unit Alcotest.test_case list 4 - (** Alcotest test suite. *)