mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
batch: update n_dropped correctly; also self_debug in Emitter_batch
This commit is contained in:
parent
31190a3606
commit
c442f3b818
2 changed files with 11 additions and 7 deletions
|
|
@ -124,7 +124,8 @@ let push (self : _ t) elems : [ `Dropped | `Ok ] =
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
(match res with
|
(match res with
|
||||||
| `Dropped -> Atomic.incr self.n_dropped
|
| `Dropped ->
|
||||||
|
ignore (Atomic.fetch_and_add self.n_dropped (List.length elems) : int)
|
||||||
| `Ok -> ());
|
| `Ok -> ());
|
||||||
res
|
res
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,15 @@ let wrap_emitter_with_batch (self : _ Batch.t) (e : _ Emitter.t) : _ Emitter.t =
|
||||||
|
|
||||||
let emit l =
|
let emit l =
|
||||||
if l <> [] && not (Atomic.get closed_here) then (
|
if l <> [] && not (Atomic.get closed_here) then (
|
||||||
(* Printf.eprintf "otel.batch.add %d items\n%!" (List.length l); *)
|
let old_n_dropped = Batch.n_dropped self in
|
||||||
Batch.push' self l;
|
(match Batch.push self l with
|
||||||
|
| `Ok -> ()
|
||||||
(* we only check for size here, not for timeout. The [tick] function is
|
| `Dropped ->
|
||||||
enough for timeouts, whereas [emit] is in the hot path of every single
|
let n_dropped = Batch.n_dropped self in
|
||||||
span/metric/log *)
|
if n_dropped / 100_000 <> old_n_dropped / 100_000 then
|
||||||
|
Self_debug.log Debug (fun () ->
|
||||||
|
Printf.sprintf "otel: batch %s dropped %d items in total"
|
||||||
|
signal_name n_dropped));
|
||||||
maybe_emit_ self ~e ~mtime:Batch.Internal_.mtime_dummy_
|
maybe_emit_ self ~e ~mtime:Batch.Internal_.mtime_dummy_
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue