mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
Merge pull request #55 from imandra-ai/simon/fix-gc-metrics-2024-07-22
fix: emit GC metrics even in the absence of custom metrics
This commit is contained in:
commit
f346491925
3 changed files with 16 additions and 4 deletions
|
|
@ -289,8 +289,8 @@ end = struct
|
||||||
|
|
||||||
let batch_max_size_ = 200
|
let batch_max_size_ = 200
|
||||||
|
|
||||||
let should_send_batch_ ~config ~now (b : _ Batch.t) : bool =
|
let should_send_batch_ ?(side = []) ~config ~now (b : _ Batch.t) : bool =
|
||||||
Batch.len b > 0
|
(Batch.len b > 0 || side != [])
|
||||||
&& (Batch.len b >= batch_max_size_
|
&& (Batch.len b >= batch_max_size_
|
||||||
||
|
||
|
||||||
let timeout = Mtime.Span.(config.Config.batch_timeout_ms * ms) in
|
let timeout = Mtime.Span.(config.Config.batch_timeout_ms * ms) in
|
||||||
|
|
@ -348,12 +348,17 @@ end = struct
|
||||||
Queue.clear local_q;
|
Queue.clear local_q;
|
||||||
|
|
||||||
if !must_flush_all then (
|
if !must_flush_all then (
|
||||||
if Batch.len batches.metrics > 0 then send_metrics ();
|
if Batch.len batches.metrics > 0 || not (AList.is_empty gc_metrics)
|
||||||
|
then
|
||||||
|
send_metrics ();
|
||||||
if Batch.len batches.logs > 0 then send_logs ();
|
if Batch.len batches.logs > 0 then send_logs ();
|
||||||
if Batch.len batches.traces > 0 then send_traces ()
|
if Batch.len batches.traces > 0 then send_traces ()
|
||||||
) else (
|
) else (
|
||||||
let now = Mtime_clock.now () in
|
let now = Mtime_clock.now () in
|
||||||
if should_send_batch_ ~config ~now batches.metrics then
|
if
|
||||||
|
should_send_batch_ ~config ~now batches.metrics
|
||||||
|
~side:(AList.get gc_metrics)
|
||||||
|
then
|
||||||
send_metrics ();
|
send_metrics ();
|
||||||
|
|
||||||
if should_send_batch_ ~config ~now batches.traces then send_traces ();
|
if should_send_batch_ ~config ~now batches.traces then send_traces ();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@ type 'a t = 'a list Atomic.t
|
||||||
|
|
||||||
let make () = Atomic.make []
|
let make () = Atomic.make []
|
||||||
|
|
||||||
|
let[@inline] is_empty self : bool =
|
||||||
|
match Atomic.get self with
|
||||||
|
| [] -> true
|
||||||
|
| _ :: _ -> false
|
||||||
|
|
||||||
let get = Atomic.get
|
let get = Atomic.get
|
||||||
|
|
||||||
let add self x =
|
let add self x =
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ type 'a t
|
||||||
val get : 'a t -> 'a list
|
val get : 'a t -> 'a list
|
||||||
(** Snapshot *)
|
(** Snapshot *)
|
||||||
|
|
||||||
|
val is_empty : _ t -> bool
|
||||||
|
|
||||||
val make : unit -> 'a t
|
val make : unit -> 'a t
|
||||||
|
|
||||||
val add : 'a t -> 'a -> unit
|
val add : 'a t -> 'a -> unit
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue