mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
add basic test that emits fake data
This commit is contained in:
parent
b05d64a025
commit
a6b0a2134b
3 changed files with 32 additions and 0 deletions
2
emit1.sh
Executable file
2
emit1.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
exec dune exec --profile=release tests/emit1.exe -- $@
|
||||
4
tests/dune
Normal file
4
tests/dune
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
(executable
|
||||
(name emit1)
|
||||
(libraries unix opentelemetry opentelemetry-client-ocurl))
|
||||
26
tests/emit1.ml
Normal file
26
tests/emit1.ml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
module T = Opentelemetry
|
||||
|
||||
let run () =
|
||||
Printf.printf "collector is on %S\n%!" (Opentelemetry_client_ocurl.get_url());
|
||||
let i = ref 0 in
|
||||
while true do
|
||||
Unix.sleepf 2.;
|
||||
|
||||
let gc = Gc.stat() in
|
||||
T.Metrics.(
|
||||
emit [
|
||||
gauge ~name:"i" [int !i];
|
||||
gauge ~name:"major-heap-words" [int gc.Gc.heap_words];
|
||||
sum ~name:"minor-allocated" [float gc.Gc.minor_words];
|
||||
]);
|
||||
|
||||
incr i;
|
||||
|
||||
(* allocate some stuff *)
|
||||
let _arr = Sys.opaque_identity @@ Array.make (25 * 25551) 42.0 in
|
||||
ignore _arr;
|
||||
done
|
||||
|
||||
let () =
|
||||
Opentelemetry_client_ocurl.with_setup run
|
||||
Loading…
Add table
Reference in a new issue