From 3467dba54c4739c32ff5f615845ff32883990c21 Mon Sep 17 00:00:00 2001 From: HaoranYi Date: Fri, 19 Apr 2024 16:10:27 -0500 Subject: [PATCH] metrics/check for empty points submission before calling writer.write (#842) check for empty points submission before calling writer.write Co-authored-by: HaoranYi --- metrics/src/metrics.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/metrics/src/metrics.rs b/metrics/src/metrics.rs index 20622974c79319..dc40696757ec89 100644 --- a/metrics/src/metrics.rs +++ b/metrics/src/metrics.rs @@ -271,14 +271,18 @@ impl MetricsAgent { let now = Instant::now(); let secs_since_last_write = now.duration_since(last_write_time).as_secs(); - writer.write(Self::combine_points( + let combined_points = Self::combine_points( max_points, max_points_per_sec, secs_since_last_write, points_buffered, points, counters, - )); + ); + + if !combined_points.is_empty() { + writer.write(combined_points); + } now }