mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 12:23:32 -04:00
update emitter tests
This commit is contained in:
parent
0bf561b586
commit
2a3295a9af
3 changed files with 19 additions and 24 deletions
|
|
@ -17,17 +17,15 @@ let num_sleep = Atomic.make 0
|
||||||
|
|
||||||
let stress_alloc_ = ref true
|
let stress_alloc_ = ref true
|
||||||
|
|
||||||
let stop = Atomic.make false
|
|
||||||
|
|
||||||
let num_tr = Atomic.make 0
|
let num_tr = Atomic.make 0
|
||||||
|
|
||||||
let run_job () =
|
let run_job () =
|
||||||
let@ () = Fun.protect ~finally:(fun () -> Atomic.set stop true) in
|
let active = OT.Main_exporter.active () in
|
||||||
let tracer = OT.Tracer.get_main () in
|
let tracer = OT.Tracer.get_main () in
|
||||||
let i = ref 0 in
|
let i = ref 0 in
|
||||||
let cnt = ref 0 in
|
let cnt = ref 0 in
|
||||||
|
|
||||||
while (not @@ Atomic.get stop) && !cnt < !n do
|
while OT.Aswitch.is_on active && !cnt < !n do
|
||||||
let@ _scope =
|
let@ _scope =
|
||||||
Atomic.incr num_tr;
|
Atomic.incr num_tr;
|
||||||
OT.Tracer.with_ tracer ~kind:OT.Span.Span_kind_producer "loop.outer"
|
OT.Tracer.with_ tracer ~kind:OT.Span.Span_kind_producer "loop.outer"
|
||||||
|
|
@ -41,7 +39,7 @@ let run_job () =
|
||||||
(* parent scope is found via thread local storage *)
|
(* parent scope is found via thread local storage *)
|
||||||
let@ scope =
|
let@ scope =
|
||||||
Atomic.incr num_tr;
|
Atomic.incr num_tr;
|
||||||
OT.Tracer.with_ tracer ~kind:OT.Span.Span_kind_internal
|
OT.Tracer.with_ tracer ~kind:OT.Span.Span_kind_internal ~parent:_scope
|
||||||
~attrs:[ "j", `Int j ]
|
~attrs:[ "j", `Int j ]
|
||||||
"loop.inner"
|
"loop.inner"
|
||||||
in
|
in
|
||||||
|
|
@ -96,7 +94,7 @@ let run () =
|
||||||
]));
|
]));
|
||||||
|
|
||||||
let n_jobs = max 1 !n_jobs in
|
let n_jobs = max 1 !n_jobs in
|
||||||
Printf.printf "run %d jobs\n%!" n_jobs;
|
Printf.printf "run %d job(s)\n%!" n_jobs;
|
||||||
|
|
||||||
let jobs =
|
let jobs =
|
||||||
Array.init n_jobs (fun _ ->
|
Array.init n_jobs (fun _ ->
|
||||||
|
|
@ -162,4 +160,4 @@ let () =
|
||||||
Printf.printf "\ndone. %d spans in %.4fs (%.4f/s)\n%!"
|
Printf.printf "\ndone. %d spans in %.4fs (%.4f/s)\n%!"
|
||||||
(Atomic.get num_tr) elapsed n_per_sec)
|
(Atomic.get num_tr) elapsed n_per_sec)
|
||||||
in
|
in
|
||||||
Opentelemetry_client_ocurl.with_setup ~stop ~config () run
|
Opentelemetry_client_ocurl.with_setup ~config () run
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,14 @@ let num_sleep = Atomic.make 0
|
||||||
|
|
||||||
let stress_alloc_ = ref true
|
let stress_alloc_ = ref true
|
||||||
|
|
||||||
let stop = Atomic.make false
|
|
||||||
|
|
||||||
let num_tr = Atomic.make 0
|
let num_tr = Atomic.make 0
|
||||||
|
|
||||||
(* Counter used to mark simulated failures *)
|
(* Counter used to mark simulated failures *)
|
||||||
let i = ref 0
|
let i = ref 0
|
||||||
|
|
||||||
let run_job job_id : unit Lwt.t =
|
let run_job job_id : unit Lwt.t =
|
||||||
while%lwt not @@ Atomic.get stop do
|
let switch = T.Main_exporter.active () in
|
||||||
|
while%lwt T.Aswitch.is_on switch do
|
||||||
let tracer = T.Tracer.get_main () in
|
let tracer = T.Tracer.get_main () in
|
||||||
let@ scope =
|
let@ scope =
|
||||||
Atomic.incr num_tr;
|
Atomic.incr num_tr;
|
||||||
|
|
@ -37,7 +36,7 @@ let run_job job_id : unit Lwt.t =
|
||||||
for%lwt j = 0 to !iterations do
|
for%lwt j = 0 to !iterations do
|
||||||
if j >= !iterations then
|
if j >= !iterations then
|
||||||
(* Terminate program, having reached our max iterations *)
|
(* Terminate program, having reached our max iterations *)
|
||||||
Lwt.return @@ Atomic.set stop true
|
T.Main_exporter.remove ()
|
||||||
else
|
else
|
||||||
(* parent scope is found via thread local storage *)
|
(* parent scope is found via thread local storage *)
|
||||||
let@ span =
|
let@ span =
|
||||||
|
|
@ -165,5 +164,4 @@ let () =
|
||||||
Printf.printf "\ndone. %d spans in %.4fs (%.4f/s)\n%!"
|
Printf.printf "\ndone. %d spans in %.4fs (%.4f/s)\n%!"
|
||||||
(Atomic.get num_tr) elapsed n_per_sec)
|
(Atomic.get num_tr) elapsed n_per_sec)
|
||||||
in
|
in
|
||||||
Opentelemetry_client_cohttp_lwt.with_setup ~stop ~config () run
|
Opentelemetry_client_cohttp_lwt.with_setup ~config () run |> Lwt_main.run
|
||||||
|> Lwt_main.run
|
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,7 @@ let run_job clock _job_id iterations : unit =
|
||||||
let () = Eio.Time.sleep clock !sleep_outer in
|
let () = Eio.Time.sleep clock !sleep_outer in
|
||||||
Atomic.incr num_sleep;
|
Atomic.incr num_sleep;
|
||||||
|
|
||||||
OT.Logger.(
|
(let logger = OT.Logger.get_main () in
|
||||||
let logger = OT.Logger.get_main () in
|
|
||||||
OT.Emitter.emit logger
|
OT.Emitter.emit logger
|
||||||
[
|
[
|
||||||
OT.Log_record.make_strf ~trace_id:(OT.Span.trace_id scope)
|
OT.Log_record.make_strf ~trace_id:(OT.Span.trace_id scope)
|
||||||
|
|
@ -163,15 +162,15 @@ let () =
|
||||||
in
|
in
|
||||||
Eio_main.run @@ fun env ->
|
Eio_main.run @@ fun env ->
|
||||||
(if !n_procs < 2 then
|
(if !n_procs < 2 then
|
||||||
Opentelemetry_client_cohttp_eio.with_setup ~stop ~config
|
Opentelemetry_client_cohttp_eio.with_setup ~config
|
||||||
(run env 0 !n_iterations) env
|
(run env 0 !n_iterations) env
|
||||||
else
|
else
|
||||||
Eio.Switch.run @@ fun sw ->
|
Eio.Switch.run @@ fun sw ->
|
||||||
Opentelemetry_client_cohttp_eio.setup ~stop ~config ~sw env;
|
Opentelemetry_client_cohttp_eio.setup ~config ~sw env;
|
||||||
let dm = Eio.Stdenv.domain_mgr env in
|
let dm = Eio.Stdenv.domain_mgr env in
|
||||||
Eio.Switch.run (fun sw ->
|
Eio.Switch.run (fun sw ->
|
||||||
for proc = 1 to !n_procs do
|
for proc = 1 to !n_procs do
|
||||||
Eio.Fiber.fork ~sw @@ fun () ->
|
Eio.Fiber.fork ~sw @@ fun () ->
|
||||||
Eio.Domain_manager.run dm (run env proc !n_iterations)
|
Eio.Domain_manager.run dm (run env proc !n_iterations)
|
||||||
done));
|
done));
|
||||||
Opentelemetry.Main_exporter.remove () ~on_done:ignore
|
OT.Main_exporter.remove () ~on_done:ignore
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue