From 41287730851e1467e2e40a39f8bd2950b0ba44b5 Mon Sep 17 00:00:00 2001 From: qicosmos Date: Tue, 18 Jun 2024 17:41:33 +0800 Subject: [PATCH] remove sleep --- include/cinatra/ylt/metric/summary.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/cinatra/ylt/metric/summary.hpp b/include/cinatra/ylt/metric/summary.hpp index b94ace28..58957bc7 100644 --- a/include/cinatra/ylt/metric/summary.hpp +++ b/include/cinatra/ylt/metric/summary.hpp @@ -108,8 +108,9 @@ class summary_t : public metric_t { if (!labels_name_.empty()) { throw std::invalid_argument("not a default label metric"); } - while (block_->sample_queue_.size_approx() >= 20000000) { - std::this_thread::sleep_for(std::chrono::milliseconds(5)); + if (block_->sample_queue_.size_approx() >= 20000000) { + // TODO: record failed count. + return; } block_->sample_queue_.enqueue(value); @@ -129,8 +130,9 @@ class summary_t : public metric_t { throw std::invalid_argument("not equal with static label"); } } - while (labels_block_->sample_queue_.size_approx() >= 20000000) { - std::this_thread::sleep_for(std::chrono::milliseconds(5)); + if (labels_block_->sample_queue_.size_approx() >= 20000000) { + // TODO: record failed count. + return; } labels_block_->sample_queue_.enqueue({std::move(labels_value), value});