mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
format
This commit is contained in:
parent
210b7991c9
commit
806545f2ba
2 changed files with 22 additions and 15 deletions
|
|
@ -78,7 +78,8 @@ let run env proc iterations () : unit =
|
||||||
sum ~name:"num-sleep" ~is_monotonic:true
|
sum ~name:"num-sleep" ~is_monotonic:true
|
||||||
[ int ~now (Atomic.get num_sleep) ];
|
[ int ~now (Atomic.get num_sleep) ];
|
||||||
]);
|
]);
|
||||||
OT.Meter.add_to_main_exporter ~min_interval:Mtime.Span.(10 * ms)
|
OT.Meter.add_to_main_exporter
|
||||||
|
~min_interval:Mtime.Span.(10 * ms)
|
||||||
OT.Meter.default;
|
OT.Meter.default;
|
||||||
|
|
||||||
let n_jobs = max 1 !n_jobs in
|
let n_jobs = max 1 !n_jobs in
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ let dummy_clock : Clock.t = { Clock.now = (fun () -> 0L) }
|
||||||
|
|
||||||
let emit h = h.Instrument.emit ~clock:dummy_clock ()
|
let emit h = h.Instrument.emit ~clock:dummy_clock ()
|
||||||
|
|
||||||
let pp_metrics metrics =
|
let pp_metrics metrics = List.iter (Format.printf "%a@." Metrics.pp) metrics
|
||||||
List.iter (Format.printf "%a@." Metrics.pp) metrics
|
|
||||||
|
|
||||||
(* ------------------------------------------------------------------ *)
|
(* ------------------------------------------------------------------ *)
|
||||||
(* Test 1: one value per bucket, plus one in the overflow bucket *)
|
(* Test 1: one value per bucket, plus one in the overflow bucket *)
|
||||||
|
|
@ -16,23 +15,27 @@ let () =
|
||||||
Instrument.Histogram.create ~name:"test.latency"
|
Instrument.Histogram.create ~name:"test.latency"
|
||||||
~description:"test histogram" ~bounds:[ 1.; 2.; 5. ] ()
|
~description:"test histogram" ~bounds:[ 1.; 2.; 5. ] ()
|
||||||
in
|
in
|
||||||
Instrument.Histogram.record h 0.5; (* bucket 0: ≤1 *)
|
Instrument.Histogram.record h 0.5;
|
||||||
Instrument.Histogram.record h 1.5; (* bucket 1: ≤2 *)
|
(* bucket 0: ≤1 *)
|
||||||
Instrument.Histogram.record h 3.0; (* bucket 2: ≤5 *)
|
Instrument.Histogram.record h 1.5;
|
||||||
Instrument.Histogram.record h 10.; (* bucket 3: >5 *)
|
(* bucket 1: ≤2 *)
|
||||||
|
Instrument.Histogram.record h 3.0;
|
||||||
|
(* bucket 2: ≤5 *)
|
||||||
|
Instrument.Histogram.record h 10.;
|
||||||
|
(* bucket 3: >5 *)
|
||||||
(* count=4 sum=15.0 bucket_counts=[1;1;1;1] *)
|
(* count=4 sum=15.0 bucket_counts=[1;1;1;1] *)
|
||||||
pp_metrics (emit h)
|
pp_metrics (emit h)
|
||||||
|
|
||||||
(* ------------------------------------------------------------------ *)
|
(* ------------------------------------------------------------------ *)
|
||||||
(* Test 2: multiple values pile into the same bucket *)
|
(* Test 2: multiple values pile into the same bucket *)
|
||||||
let () =
|
let () =
|
||||||
let h =
|
let h = Instrument.Histogram.create ~name:"test.size" ~bounds:[ 1.; 5. ] () in
|
||||||
Instrument.Histogram.create ~name:"test.size" ~bounds:[ 1.; 5. ] ()
|
|
||||||
in
|
|
||||||
Instrument.Histogram.record h 0.1;
|
Instrument.Histogram.record h 0.1;
|
||||||
Instrument.Histogram.record h 0.2;
|
Instrument.Histogram.record h 0.2;
|
||||||
Instrument.Histogram.record h 0.3; (* 3 values in bucket 0 *)
|
Instrument.Histogram.record h 0.3;
|
||||||
Instrument.Histogram.record h 2.0; (* 1 value in bucket 1 *)
|
(* 3 values in bucket 0 *)
|
||||||
|
Instrument.Histogram.record h 2.0;
|
||||||
|
(* 1 value in bucket 1 *)
|
||||||
(* count=4 sum=2.6 bucket_counts=[3;1;0] *)
|
(* count=4 sum=2.6 bucket_counts=[3;1;0] *)
|
||||||
pp_metrics (emit h)
|
pp_metrics (emit h)
|
||||||
|
|
||||||
|
|
@ -51,8 +54,11 @@ let () =
|
||||||
let h =
|
let h =
|
||||||
Instrument.Histogram.create ~name:"test.boundary" ~bounds:[ 1.; 2.; 5. ] ()
|
Instrument.Histogram.create ~name:"test.boundary" ~bounds:[ 1.; 2.; 5. ] ()
|
||||||
in
|
in
|
||||||
Instrument.Histogram.record h 1.0; (* exactly on bound → bucket 0 *)
|
Instrument.Histogram.record h 1.0;
|
||||||
Instrument.Histogram.record h 2.0; (* exactly on bound → bucket 1 *)
|
(* exactly on bound → bucket 0 *)
|
||||||
Instrument.Histogram.record h 5.0; (* exactly on bound → bucket 2 *)
|
Instrument.Histogram.record h 2.0;
|
||||||
|
(* exactly on bound → bucket 1 *)
|
||||||
|
Instrument.Histogram.record h 5.0;
|
||||||
|
(* exactly on bound → bucket 2 *)
|
||||||
(* count=3 sum=8.0 bucket_counts=[1;1;1;0] *)
|
(* count=3 sum=8.0 bucket_counts=[1;1;1;0] *)
|
||||||
pp_metrics (emit h)
|
pp_metrics (emit h)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue