Skip to content

Commit

Permalink
remove sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Jun 18, 2024
1 parent 3c8b9f0 commit 4128773
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions include/cinatra/ylt/metric/summary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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});

Expand Down

0 comments on commit 4128773

Please sign in to comment.