mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
wip: fix tests
This commit is contained in:
parent
1ef992c264
commit
da6ac17049
2 changed files with 16 additions and 13 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
(libraries
|
(libraries
|
||||||
unix
|
unix
|
||||||
opentelemetry
|
opentelemetry
|
||||||
opentelemetry.client
|
opentelemetry-client
|
||||||
opentelemetry-client-ocurl))
|
opentelemetry-client-ocurl))
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
unix
|
unix
|
||||||
opentelemetry
|
opentelemetry
|
||||||
opentelemetry-lwt
|
opentelemetry-lwt
|
||||||
opentelemetry.client
|
opentelemetry-client
|
||||||
opentelemetry-client-cohttp-lwt
|
opentelemetry-client-cohttp-lwt
|
||||||
lwt.unix))
|
lwt.unix))
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
logs.fmt
|
logs.fmt
|
||||||
logs.threaded
|
logs.threaded
|
||||||
opentelemetry
|
opentelemetry
|
||||||
opentelemetry.client
|
opentelemetry-client
|
||||||
opentelemetry-client-cohttp-eio))
|
opentelemetry-client-cohttp-eio))
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,10 @@ let num_tr = Atomic.make 0
|
||||||
let i = Atomic.make 0
|
let i = Atomic.make 0
|
||||||
|
|
||||||
let run_job clock _job_id iterations : unit =
|
let run_job clock _job_id iterations : unit =
|
||||||
|
let tracer = OT.Tracer.get_main () in
|
||||||
let@ scope =
|
let@ scope =
|
||||||
Atomic.incr num_tr;
|
Atomic.incr num_tr;
|
||||||
OT.Trace.with_ ~kind:OT.Span.Span_kind_producer "loop.outer"
|
OT.Tracer.with_ tracer ~kind:OT.Span.Span_kind_producer "loop.outer"
|
||||||
~attrs:[ "i", `Int (Atomic.get i) ]
|
~attrs:[ "i", `Int (Atomic.get i) ]
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
@ -37,7 +38,7 @@ let run_job clock _job_id iterations : unit =
|
||||||
(* 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.Trace.with_ ~scope ~kind:OT.Span.Span_kind_internal
|
OT.Tracer.with_ tracer ~parent:scope ~kind:OT.Span.Span_kind_internal
|
||||||
~attrs:[ "j", `Int j ]
|
~attrs:[ "j", `Int j ]
|
||||||
"loop.inner"
|
"loop.inner"
|
||||||
in
|
in
|
||||||
|
|
@ -45,11 +46,13 @@ 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.Logs.(
|
OT.Logger.(
|
||||||
emit
|
let logger = OT.Logger.get_main () in
|
||||||
|
OT.Emitter.emit logger
|
||||||
[
|
[
|
||||||
make_strf ~trace_id:scope.trace_id ~span_id:scope.span_id
|
OT.Log_record.make_strf ~trace_id:(OT.Span.trace_id scope)
|
||||||
~severity:Severity_number_info "inner at %d" j;
|
~span_id:(OT.Span.id scope) ~severity:Severity_number_info
|
||||||
|
"inner at %d" j;
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Atomic.incr i;
|
Atomic.incr i;
|
||||||
|
|
@ -57,7 +60,8 @@ let run_job clock _job_id iterations : unit =
|
||||||
try
|
try
|
||||||
Atomic.incr num_tr;
|
Atomic.incr num_tr;
|
||||||
let@ scope =
|
let@ scope =
|
||||||
OT.Trace.with_ ~kind:OT.Span.Span_kind_internal ~scope "alloc"
|
OT.Tracer.with_ tracer ~kind:OT.Span.Span_kind_internal ~parent:scope
|
||||||
|
"alloc"
|
||||||
in
|
in
|
||||||
(* allocate some stuff *)
|
(* allocate some stuff *)
|
||||||
if !stress_alloc_ then (
|
if !stress_alloc_ then (
|
||||||
|
|
@ -71,13 +75,12 @@ let run_job clock _job_id iterations : unit =
|
||||||
if j = 4 && Atomic.get i mod 13 = 0 then failwith "oh no";
|
if j = 4 && Atomic.get i mod 13 = 0 then failwith "oh no";
|
||||||
|
|
||||||
(* simulate a failure *)
|
(* simulate a failure *)
|
||||||
Opentelemetry.Scope.add_event scope (fun () ->
|
OT.Span.add_event scope (OT.Event.make "done with alloc")
|
||||||
OT.Event.make "done with alloc")
|
|
||||||
with Failure _ -> ()
|
with Failure _ -> ()
|
||||||
done
|
done
|
||||||
|
|
||||||
let run env proc iterations () : unit =
|
let run env proc iterations () : unit =
|
||||||
OT.GC_metrics.basic_setup ();
|
OT.Gc_metrics.setup_on_main_exporter ();
|
||||||
|
|
||||||
OT.Metrics_callbacks.register (fun () ->
|
OT.Metrics_callbacks.register (fun () ->
|
||||||
OT.Metrics.
|
OT.Metrics.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue