gavinchou commented on code in PR #55544:
URL: https://github.com/apache/doris/pull/55544#discussion_r2329525682


##########
cloud/src/common/bvars.h:
##########
@@ -179,6 +184,180 @@ class mBvarWrapper {
     bvar::MultiDimension<BvarType> counter_;
 };
 
+template <int N = 60>
+class BvarLatencyRecorderWithStatus {
+private:
+    bvar::LatencyRecorder recorder_;
+    bvar::PassiveStatus<int64_t> max_status_;
+    bvar::PassiveStatus<int64_t> avg_status_;
+
+    static int64_t get_max_latency(void* arg) {
+        auto* self = static_cast<BvarLatencyRecorderWithStatus*>(arg);
+        int64_t value = self->recorder_.max_latency();
+        return value >= 0 ? value : 0;
+    }
+
+    static int64_t get_avg_latency(void* arg) {
+        auto* self = static_cast<BvarLatencyRecorderWithStatus*>(arg);
+        int64_t value = self->recorder_.latency();
+        return value >= 0 ? value : 0;
+    }
+
+public:
+    BvarLatencyRecorderWithStatus(const std::string& prefix, const 
std::string& metric_name)
+            : recorder_(N),
+              max_status_(metric_name + "_max", get_max_latency, this),
+              avg_status_(metric_name + "_avg", get_avg_latency, this) {
+        recorder_.hide();
+    }
+
+    BvarLatencyRecorderWithStatus(const std::string& metric_name)
+            : recorder_(N),
+              max_status_(metric_name + "_max", get_max_latency, this),
+              avg_status_(metric_name + "_avg", get_avg_latency, this) {
+        recorder_.hide();
+    }
+
+    void put(int64_t value) { recorder_ << value; }
+
+    void operator<<(int64_t value) { recorder_ << value; }
+};
+
+class DeferredTimer {

Review Comment:
   add comment, what is for



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to