From 41e9962c088327061bc10866710bbb25b7f211fe Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 6 Jul 2022 19:55:06 -0400 Subject: [PATCH] fix: do not emit empty batches --- src/client/opentelemetry_client_ocurl.ml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/client/opentelemetry_client_ocurl.ml b/src/client/opentelemetry_client_ocurl.ml index 1ee1a918..d0f5f62e 100644 --- a/src/client/opentelemetry_client_ocurl.ml +++ b/src/client/opentelemetry_client_ocurl.ml @@ -240,13 +240,12 @@ end = struct let pop_if_ready ?(force = false) ~now (self : _ t) : _ list option = let@ () = with_mutex_ self.lock in - if - (force && not (is_empty_ self)) - || is_full_ self || timeout_expired_ ~now self + if self.size > 0 && (force || is_full_ self || timeout_expired_ ~now self) then ( let l = self.q in self.q <- []; self.size <- 0; + assert (l <> []); Some l ) else None