mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
test: use Metrics_callbacks from emit1
This commit is contained in:
parent
6744123075
commit
5b3f49890b
1 changed files with 9 additions and 0 deletions
|
|
@ -5,11 +5,15 @@ let (let@) f x = f x
|
|||
|
||||
let sleep_inner = ref 0.1
|
||||
let sleep_outer = ref 2.0
|
||||
let num_sleep = ref 0
|
||||
|
||||
let run () =
|
||||
Printf.printf "collector is on %S\n%!" (Opentelemetry_client_ocurl.get_url());
|
||||
T.GC_metrics.basic_setup();
|
||||
|
||||
T.Metrics_callbacks.register (fun () ->
|
||||
T.Metrics.[ sum ~name:"num-sleep" ~is_monotonic:true [int !num_sleep] ]);
|
||||
|
||||
let i = ref 0 in
|
||||
while true do
|
||||
let@ scope =
|
||||
|
|
@ -22,7 +26,9 @@ let run () =
|
|||
let@ scope = T.Trace.with_ ~kind:T.Span.Span_kind_internal ~scope
|
||||
~attrs:["j", `Int j]
|
||||
"loop.inner" in
|
||||
|
||||
Unix.sleepf !sleep_outer;
|
||||
incr num_sleep;
|
||||
|
||||
incr i;
|
||||
|
||||
|
|
@ -33,7 +39,10 @@ let run () =
|
|||
(* allocate some stuff *)
|
||||
let _arr = Sys.opaque_identity @@ Array.make (25 * 25551) 42.0 in
|
||||
ignore _arr;
|
||||
|
||||
Unix.sleepf !sleep_inner;
|
||||
incr num_sleep;
|
||||
|
||||
if j=4 && !i mod 13 = 0 then failwith "oh no"; (* simulate a failure *)
|
||||
|
||||
T.Trace.add_event scope (fun()->T.Event.make "done with alloc");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue