mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 20:07:55 -04:00
better test
This commit is contained in:
parent
3beacb1f18
commit
3006e293b0
1 changed files with 24 additions and 19 deletions
|
|
@ -1,33 +1,38 @@
|
||||||
|
|
||||||
module T = Opentelemetry
|
module T = Opentelemetry
|
||||||
|
let spf = Printf.sprintf
|
||||||
let (let@) f x = f x
|
let (let@) f x = f x
|
||||||
|
|
||||||
let run () =
|
let run () =
|
||||||
Printf.printf "collector is on %S\n%!" (Opentelemetry_client_ocurl.get_url());
|
Printf.printf "collector is on %S\n%!" (Opentelemetry_client_ocurl.get_url());
|
||||||
let i = ref 0 in
|
let i = ref 0 in
|
||||||
while true do
|
while true do
|
||||||
let@ (tr,sp) = T.Trace.with_ ~service_name:"t1" "loop" in
|
let@ (tr,sp) = T.Trace.with_ ~service_name:"t1" "outer.loop" ~attrs:["i", `Int !i] in
|
||||||
Unix.sleepf 2.;
|
|
||||||
|
|
||||||
let gc = Gc.stat() in
|
for j=0 to 4 do
|
||||||
T.Metrics.(
|
|
||||||
emit [
|
|
||||||
gauge ~name:"ocaml_opentracing.test.i" [int !i];
|
|
||||||
gauge ~name:"ocaml_opentracing.test.major_heap_words" [int gc.Gc.heap_words];
|
|
||||||
sum ~name:"ocaml_opentracing.test.minor_allocated" [float gc.Gc.minor_words];
|
|
||||||
]);
|
|
||||||
|
|
||||||
incr i;
|
let@ (tr,sp) = T.Trace.with_ ~service_name:"t1" ~attrs:["j", `Int j] "loop.inner" in
|
||||||
|
Unix.sleepf 2.;
|
||||||
|
|
||||||
begin
|
let gc = Gc.stat() in
|
||||||
let@ _ = T.Trace.with_ ~kind:T.Span.Span_kind_client
|
T.Metrics.(
|
||||||
~trace_id:tr ~parent:sp "alloc" in
|
emit [
|
||||||
(* allocate some stuff *)
|
gauge ~name:"ocaml_opentracing.test.i" [int !i];
|
||||||
let _arr = Sys.opaque_identity @@ Array.make (25 * 25551) 42.0 in
|
gauge ~name:"ocaml_opentracing.test.major_heap_words" [int gc.Gc.heap_words];
|
||||||
ignore _arr;
|
sum ~name:"ocaml_opentracing.test.minor_allocated" [float gc.Gc.minor_words];
|
||||||
Unix.sleepf 0.1;
|
]);
|
||||||
end;
|
|
||||||
|
incr i;
|
||||||
|
|
||||||
|
begin
|
||||||
|
let@ _ = T.Trace.with_ ~kind:T.Span.Span_kind_client
|
||||||
|
~trace_id:tr ~parent:sp "alloc" in
|
||||||
|
(* allocate some stuff *)
|
||||||
|
let _arr = Sys.opaque_identity @@ Array.make (25 * 25551) 42.0 in
|
||||||
|
ignore _arr;
|
||||||
|
Unix.sleepf 0.1;
|
||||||
|
end;
|
||||||
|
done;
|
||||||
done
|
done
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue