mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -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 stop = Atomic.make false
|
||||
|
||||
let num_tr = Atomic.make 0
|
||||
|
||||
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 i = 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 =
|
||||
Atomic.incr num_tr;
|
||||
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 *)
|
||||
let@ scope =
|
||||
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 ]
|
||||
"loop.inner"
|
||||
in
|
||||
|
|
@ -96,7 +94,7 @@ let run () =
|
|||
]));
|
||||
|
||||
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 =
|
||||
Array.init n_jobs (fun _ ->
|
||||
|
|
@ -162,4 +160,4 @@ let () =
|
|||
Printf.printf "\ndone. %d spans in %.4fs (%.4f/s)\n%!"
|
||||
(Atomic.get num_tr) elapsed n_per_sec)
|
||||
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 stop = Atomic.make false
|
||||
|
||||
let num_tr = Atomic.make 0
|
||||
|
||||
(* Counter used to mark simulated failures *)
|
||||
let i = ref 0
|
||||
|
||||
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@ scope =
|
||||
Atomic.incr num_tr;
|
||||
|
|
@ -37,7 +36,7 @@ let run_job job_id : unit Lwt.t =
|
|||
for%lwt j = 0 to !iterations do
|
||||
if j >= !iterations then
|
||||
(* Terminate program, having reached our max iterations *)
|
||||
Lwt.return @@ Atomic.set stop true
|
||||
T.Main_exporter.remove ()
|
||||
else
|
||||
(* parent scope is found via thread local storage *)
|
||||
let@ span =
|
||||
|
|
@ -165,5 +164,4 @@ let () =
|
|||
Printf.printf "\ndone. %d spans in %.4fs (%.4f/s)\n%!"
|
||||
(Atomic.get num_tr) elapsed n_per_sec)
|
||||
in
|
||||
Opentelemetry_client_cohttp_lwt.with_setup ~stop ~config () run
|
||||
|> Lwt_main.run
|
||||
Opentelemetry_client_cohttp_lwt.with_setup ~config () run |> Lwt_main.run
|
||||
|
|
|
|||
|
|
@ -46,14 +46,13 @@ let run_job clock _job_id iterations : unit =
|
|||
let () = Eio.Time.sleep clock !sleep_outer in
|
||||
Atomic.incr num_sleep;
|
||||
|
||||
OT.Logger.(
|
||||
let logger = OT.Logger.get_main () in
|
||||
OT.Emitter.emit logger
|
||||
[
|
||||
OT.Log_record.make_strf ~trace_id:(OT.Span.trace_id scope)
|
||||
~span_id:(OT.Span.id scope) ~severity:Severity_number_info
|
||||
"inner at %d" j;
|
||||
]);
|
||||
(let logger = OT.Logger.get_main () in
|
||||
OT.Emitter.emit logger
|
||||
[
|
||||
OT.Log_record.make_strf ~trace_id:(OT.Span.trace_id scope)
|
||||
~span_id:(OT.Span.id scope) ~severity:Severity_number_info
|
||||
"inner at %d" j;
|
||||
]);
|
||||
|
||||
Atomic.incr i;
|
||||
|
||||
|
|
@ -163,15 +162,15 @@ let () =
|
|||
in
|
||||
Eio_main.run @@ fun env ->
|
||||
(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
|
||||
else
|
||||
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
|
||||
Eio.Switch.run (fun sw ->
|
||||
for proc = 1 to !n_procs do
|
||||
Eio.Fiber.fork ~sw @@ fun () ->
|
||||
Eio.Domain_manager.run dm (run env proc !n_iterations)
|
||||
done));
|
||||
Opentelemetry.Main_exporter.remove () ~on_done:ignore
|
||||
OT.Main_exporter.remove () ~on_done:ignore
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue