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
40c6bec30c
commit
86d44416ff
2 changed files with 16 additions and 13 deletions
|
|
@ -4,7 +4,7 @@
|
|||
(libraries
|
||||
unix
|
||||
opentelemetry
|
||||
opentelemetry.client
|
||||
opentelemetry-client
|
||||
opentelemetry-client-ocurl))
|
||||
|
||||
(executable
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
unix
|
||||
opentelemetry
|
||||
opentelemetry-lwt
|
||||
opentelemetry.client
|
||||
opentelemetry-client
|
||||
opentelemetry-client-cohttp-lwt
|
||||
lwt.unix))
|
||||
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
logs.fmt
|
||||
logs.threaded
|
||||
opentelemetry
|
||||
opentelemetry.client
|
||||
opentelemetry-client
|
||||
opentelemetry-client-cohttp-eio))
|
||||
|
||||
(executable
|
||||
|
|
|
|||
|
|
@ -23,9 +23,10 @@ let num_tr = Atomic.make 0
|
|||
let i = Atomic.make 0
|
||||
|
||||
let run_job clock _job_id iterations : unit =
|
||||
let tracer = OT.Tracer.get_main () in
|
||||
let@ scope =
|
||||
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) ]
|
||||
in
|
||||
|
||||
|
|
@ -37,7 +38,7 @@ let run_job clock _job_id iterations : unit =
|
|||
(* parent scope is found via thread local storage *)
|
||||
let@ scope =
|
||||
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 ]
|
||||
"loop.inner"
|
||||
in
|
||||
|
|
@ -45,11 +46,13 @@ let run_job clock _job_id iterations : unit =
|
|||
let () = Eio.Time.sleep clock !sleep_outer in
|
||||
Atomic.incr num_sleep;
|
||||
|
||||
OT.Logs.(
|
||||
emit
|
||||
OT.Logger.(
|
||||
let logger = OT.Logger.get_main () in
|
||||
OT.Emitter.emit logger
|
||||
[
|
||||
make_strf ~trace_id:scope.trace_id ~span_id:scope.span_id
|
||||
~severity:Severity_number_info "inner at %d" j;
|
||||
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;
|
||||
|
|
@ -57,7 +60,8 @@ let run_job clock _job_id iterations : unit =
|
|||
try
|
||||
Atomic.incr num_tr;
|
||||
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
|
||||
(* allocate some stuff *)
|
||||
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";
|
||||
|
||||
(* simulate a failure *)
|
||||
Opentelemetry.Scope.add_event scope (fun () ->
|
||||
OT.Event.make "done with alloc")
|
||||
OT.Span.add_event scope (OT.Event.make "done with alloc")
|
||||
with Failure _ -> ()
|
||||
done
|
||||
|
||||
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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue