diff --git a/src/common/monitor/Sample.h b/src/common/monitor/Sample.h index 810e8b52..bfd6a12b 100644 --- a/src/common/monitor/Sample.h +++ b/src/common/monitor/Sample.h @@ -39,6 +39,7 @@ class TagSet { std::map asMap() const { return {begin(), end()}; } size_t size() const { return tag_set_.size(); } + bool empty() const { return tag_set_.empty(); } Iterator begin() { return tag_set_.begin(); } Iterator end() { return tag_set_.end(); } diff --git a/src/common/monitor/ScopedMetricsWriter.h b/src/common/monitor/ScopedMetricsWriter.h index 3b769f14..89c1f1e0 100644 --- a/src/common/monitor/ScopedMetricsWriter.h +++ b/src/common/monitor/ScopedMetricsWriter.h @@ -15,7 +15,7 @@ class ScopedCounterWriter { value_(value), tagSet_(tagSet) { int64_t currentCounter = counter_.fetch_add(value_) + value_; - if (tagSet.size() > 0) + if (!tagSet.empty()) recorder_.addSample(currentCounter, tagSet_); else recorder_.addSample(currentCounter); @@ -32,7 +32,7 @@ class ScopedCounterWriter { ~ScopedCounterWriter() { int64_t currentCounter = counter_.fetch_add(-value_) - value_; - if (tagSet_.size() > 0) + if (!tagSet_.empty()) recorder_.addSample(currentCounter, tagSet_); else recorder_.addSample(currentCounter); @@ -56,7 +56,7 @@ class ScopedLatencyWriter { : ScopedLatencyWriter(recorder, instance.empty() ? monitor::TagSet() : monitor::instanceTagSet(instance)) {} ~ScopedLatencyWriter() { - if (tagSet_.size() > 0) + if (!tagSet_.empty()) recorder_.addSample(getElapsedTime(), tagSet_); else recorder_.addSample(getElapsedTime());