github-actions[bot] commented on code in PR #18115:
URL: https://github.com/apache/doris/pull/18115#discussion_r1148473612


##########
be/src/util/bvar_metrics.cpp:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "util/bvar_metrics.h"
+
+namespace doris {
+    template<typename T>
+    void BvarAdderMetric<T>::increment(T value) {
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    void BvarAdderMetric<T>::set_value(T value) {
+        adder_->reset();
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    std::string BvarAdderMetric<T>::to_prometheus(bool with_tablet_metrics) 
const {
+        return "";
+    }
+
+    void BvarMetricEntity::put(std::string name, BvarMetric metric) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            auto it = map_.find(name);

Review Comment:
   warning: use of undeclared identifier 'map_' [clang-diagnostic-error]
   ```cpp
               auto it = map_.find(name);
                         ^
   ```
   



##########
be/src/util/bvar_metrics.cpp:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "util/bvar_metrics.h"
+
+namespace doris {
+    template<typename T>
+    void BvarAdderMetric<T>::increment(T value) {
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    void BvarAdderMetric<T>::set_value(T value) {
+        adder_->reset();
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    std::string BvarAdderMetric<T>::to_prometheus(bool with_tablet_metrics) 
const {
+        return "";
+    }
+
+    void BvarMetricEntity::put(std::string name, BvarMetric metric) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            auto it = map_.find(name);
+            if(it==map_.end()){

Review Comment:
   warning: use of undeclared identifier 'map_' [clang-diagnostic-error]
   ```cpp
               if(it==map_.end()){
                      ^
   ```
   



##########
be/src/util/bvar_metrics.cpp:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "util/bvar_metrics.h"
+
+namespace doris {
+    template<typename T>
+    void BvarAdderMetric<T>::increment(T value) {
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    void BvarAdderMetric<T>::set_value(T value) {
+        adder_->reset();
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    std::string BvarAdderMetric<T>::to_prometheus(bool with_tablet_metrics) 
const {
+        return "";
+    }
+
+    void BvarMetricEntity::put(std::string name, BvarMetric metric) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            auto it = map_.find(name);
+            if(it==map_.end()){
+                map_[name]=std::make_shared<BvarMetric>(metric);

Review Comment:
   warning: use of undeclared identifier 'map_' [clang-diagnostic-error]
   ```cpp
                   map_[name]=std::make_shared<BvarMetric>(metric);
                   ^
   ```
   



##########
be/src/util/bvar_metrics.cpp:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "util/bvar_metrics.h"
+
+namespace doris {
+    template<typename T>
+    void BvarAdderMetric<T>::increment(T value) {
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    void BvarAdderMetric<T>::set_value(T value) {
+        adder_->reset();
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    std::string BvarAdderMetric<T>::to_prometheus(bool with_tablet_metrics) 
const {
+        return "";
+    }
+
+    void BvarMetricEntity::put(std::string name, BvarMetric metric) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            auto it = map_.find(name);
+            if(it==map_.end()){
+                map_[name]=std::make_shared<BvarMetric>(metric);
+            }
+        }
+    }
+
+    std::string BvarMetricEntity::to_prometheus() {
+        return "";
+    }
+
+
+    void BvarMetricRegistry::put(BvarMetricEntity entity) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            std::shared_ptr<BvarMetricEntity> entity_ptr(new 
BvarMetricEntity(entity));

Review Comment:
   warning: 'BvarMetricEntity' does not refer to a value 
[clang-diagnostic-error]
   ```cpp
               std::shared_ptr<BvarMetricEntity> entity_ptr(new 
BvarMetricEntity(entity));
                               ^
   ```
   **be/src/util/bvar_metrics.h:82:** declared here
   ```cpp
       class BvarMetricEntity{
             ^
   ```
   



##########
be/src/util/bvar_metrics.cpp:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "util/bvar_metrics.h"
+
+namespace doris {
+    template<typename T>
+    void BvarAdderMetric<T>::increment(T value) {
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    void BvarAdderMetric<T>::set_value(T value) {
+        adder_->reset();
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    std::string BvarAdderMetric<T>::to_prometheus(bool with_tablet_metrics) 
const {
+        return "";
+    }
+
+    void BvarMetricEntity::put(std::string name, BvarMetric metric) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            auto it = map_.find(name);
+            if(it==map_.end()){
+                map_[name]=std::make_shared<BvarMetric>(metric);
+            }
+        }
+    }
+
+    std::string BvarMetricEntity::to_prometheus() {
+        return "";
+    }
+
+
+    void BvarMetricRegistry::put(BvarMetricEntity entity) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            std::shared_ptr<BvarMetricEntity> entity_ptr(new 
BvarMetricEntity(entity));
+            if(std::find(vec_.begin(),vec_.end(),entity_ptr)==vec_.end()){

Review Comment:
   warning: use of undeclared identifier 'vec_' [clang-diagnostic-error]
   ```cpp
               if(std::find(vec_.begin(),vec_.end(),entity_ptr)==vec_.end()){
                            ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;

Review Comment:
   warning: no template named 'shared_ptr' in namespace 'std' 
[clang-diagnostic-error]
   ```cpp
           std::shared_ptr<bvar::Adder<T>> adder_;
                ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;
+    };
+
+    class BvarMetricEntity{
+    public:
+        BvarMetricEntity()=default;
+        BvarMetricEntity(std::string entity_name){
+            this->entity_name_=entity_name;
+        }
+        BvarMetricEntity(BvarMetricEntity& entity){
+            this->entity_name_=entity.entity_name_;
+            this->map_=entity.map_;

Review Comment:
   warning: no member named 'map_' in 'doris::BvarMetricEntity' 
[clang-diagnostic-error]
   ```cpp
               this->map_=entity.map_;
                                 ^
   ```
   



##########
be/src/util/bvar_metrics.cpp:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "util/bvar_metrics.h"
+
+namespace doris {
+    template<typename T>
+    void BvarAdderMetric<T>::increment(T value) {
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    void BvarAdderMetric<T>::set_value(T value) {
+        adder_->reset();
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    std::string BvarAdderMetric<T>::to_prometheus(bool with_tablet_metrics) 
const {
+        return "";
+    }
+
+    void BvarMetricEntity::put(std::string name, BvarMetric metric) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            auto it = map_.find(name);
+            if(it==map_.end()){
+                map_[name]=std::make_shared<BvarMetric>(metric);

Review Comment:
   warning: no template named 'make_shared' in namespace 'std'; did you mean 
'make_signed'? [clang-diagnostic-error]
   
   ```suggestion
                   map_[name]=std::make_signed<BvarMetric>(metric);
   ```
   **/usr/include/c++/11/type_traits:1965:** 'make_signed' declared here
   ```cpp
       struct make_signed
              ^
   ```
   



##########
be/src/util/bvar_metrics.cpp:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "util/bvar_metrics.h"
+
+namespace doris {
+    template<typename T>
+    void BvarAdderMetric<T>::increment(T value) {
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    void BvarAdderMetric<T>::set_value(T value) {
+        adder_->reset();
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    std::string BvarAdderMetric<T>::to_prometheus(bool with_tablet_metrics) 
const {
+        return "";
+    }
+
+    void BvarMetricEntity::put(std::string name, BvarMetric metric) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            auto it = map_.find(name);
+            if(it==map_.end()){
+                map_[name]=std::make_shared<BvarMetric>(metric);
+            }
+        }
+    }
+
+    std::string BvarMetricEntity::to_prometheus() {
+        return "";
+    }
+
+
+    void BvarMetricRegistry::put(BvarMetricEntity entity) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            std::shared_ptr<BvarMetricEntity> entity_ptr(new 
BvarMetricEntity(entity));

Review Comment:
   warning: no member named 'shared_ptr' in namespace 'std' 
[clang-diagnostic-error]
   ```cpp
               std::shared_ptr<BvarMetricEntity> entity_ptr(new 
BvarMetricEntity(entity));
                    ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;
+    };
+
+    class BvarMetricEntity{
+    public:
+        BvarMetricEntity()=default;
+        BvarMetricEntity(std::string entity_name){
+            this->entity_name_=entity_name;
+        }
+        BvarMetricEntity(BvarMetricEntity& entity){
+            this->entity_name_=entity.entity_name_;
+            this->map_=entity.map_;
+        }
+        void put(std::string name, BvarMetric metric);
+        std::string to_prometheus();
+    private:
+        std::string entity_name_;
+        std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;

Review Comment:
   warning: no member named 'shared_ptr' in namespace 'std' 
[clang-diagnostic-error]
   ```cpp
           std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;
                                                ^
   ```
   



##########
be/src/util/bvar_metrics.cpp:
##########
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "util/bvar_metrics.h"
+
+namespace doris {
+    template<typename T>
+    void BvarAdderMetric<T>::increment(T value) {
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    void BvarAdderMetric<T>::set_value(T value) {
+        adder_->reset();
+        (*adder_)<<value;
+    }
+
+    template<typename T>
+    std::string BvarAdderMetric<T>::to_prometheus(bool with_tablet_metrics) 
const {
+        return "";
+    }
+
+    void BvarMetricEntity::put(std::string name, BvarMetric metric) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            auto it = map_.find(name);
+            if(it==map_.end()){
+                map_[name]=std::make_shared<BvarMetric>(metric);
+            }
+        }
+    }
+
+    std::string BvarMetricEntity::to_prometheus() {
+        return "";
+    }
+
+
+    void BvarMetricRegistry::put(BvarMetricEntity entity) {
+        {
+            std::lock_guard<bthread::Mutex>l(mutex_);
+            std::shared_ptr<BvarMetricEntity> entity_ptr(new 
BvarMetricEntity(entity));

Review Comment:
   warning: use of undeclared identifier 'entity_ptr' [clang-diagnostic-error]
   ```cpp
               std::shared_ptr<BvarMetricEntity> entity_ptr(new 
BvarMetricEntity(entity));
                                                 ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);

Review Comment:
   warning: no template named 'make_shared' in namespace 'std'; did you mean 
'make_signed'? [clang-diagnostic-error]
   
   ```suggestion
               adder_ = 
std::make_signed<bvar::Adder<T>>(group_name,name+'_'+description);
   ```
   **/usr/include/c++/11/type_traits:1965:** 'make_signed' declared here
   ```cpp
       struct make_signed
              ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;

Review Comment:
   warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' 
[modernize-use-override]
   
   ```suggestion
           ~BvarAdderMetric() override =default;
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;
+    };
+
+    class BvarMetricEntity{
+    public:
+        BvarMetricEntity()=default;
+        BvarMetricEntity(std::string entity_name){
+            this->entity_name_=entity_name;
+        }
+        BvarMetricEntity(BvarMetricEntity& entity){
+            this->entity_name_=entity.entity_name_;
+            this->map_=entity.map_;

Review Comment:
   warning: no member named 'map_' in 'doris::BvarMetricEntity' 
[clang-diagnostic-error]
   ```cpp
               this->map_=entity.map_;
                     ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;
+    };
+
+    class BvarMetricEntity{
+    public:
+        BvarMetricEntity()=default;
+        BvarMetricEntity(std::string entity_name){
+            this->entity_name_=entity_name;
+        }
+        BvarMetricEntity(BvarMetricEntity& entity){
+            this->entity_name_=entity.entity_name_;
+            this->map_=entity.map_;
+        }
+        void put(std::string name, BvarMetric metric);
+        std::string to_prometheus();
+    private:
+        std::string entity_name_;
+        std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;

Review Comment:
   warning: expected member name or ';' after declaration specifiers 
[clang-diagnostic-error]
   ```cpp
           std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;
                                                                      ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;
+    };
+
+    class BvarMetricEntity{
+    public:
+        BvarMetricEntity()=default;
+        BvarMetricEntity(std::string entity_name){
+            this->entity_name_=entity_name;
+        }
+        BvarMetricEntity(BvarMetricEntity& entity){
+            this->entity_name_=entity.entity_name_;
+            this->map_=entity.map_;
+        }
+        void put(std::string name, BvarMetric metric);
+        std::string to_prometheus();
+    private:
+        std::string entity_name_;
+        std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;

Review Comment:
   warning: 'BvarMetric' does not refer to a value [clang-diagnostic-error]
   ```cpp
           std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;
                                                           ^
   ```
   **be/src/util/bvar_metrics.h:48:** declared here
   ```cpp
       class BvarMetric{
             ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;
+    };
+
+    class BvarMetricEntity{
+    public:
+        BvarMetricEntity()=default;
+        BvarMetricEntity(std::string entity_name){
+            this->entity_name_=entity_name;
+        }
+        BvarMetricEntity(BvarMetricEntity& entity){
+            this->entity_name_=entity.entity_name_;
+            this->map_=entity.map_;
+        }
+        void put(std::string name, BvarMetric metric);
+        std::string to_prometheus();
+    private:
+        std::string entity_name_;
+        std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;
+        bthread::Mutex mutex_;
+    };
+
+    class BvarMetricRegistry{
+    public:
+        static BvarMetricRegistry* instance(){
+            static BvarMetricRegistry registry;
+            return &registry;
+        }
+        void put(BvarMetricEntity entity);
+        std::string to_prometheus();
+    private:
+        BvarMetricRegistry()=default;
+        std::string registry_name_;
+        std::vector<std::shared_ptr<BvarMetricEntity>> vec_;

Review Comment:
   warning: expected member name or ';' after declaration specifiers 
[clang-diagnostic-error]
   ```cpp
           std::vector<std::shared_ptr<BvarMetricEntity>> vec_;
                                                        ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;
+    };
+
+    class BvarMetricEntity{
+    public:
+        BvarMetricEntity()=default;
+        BvarMetricEntity(std::string entity_name){
+            this->entity_name_=entity_name;
+        }
+        BvarMetricEntity(BvarMetricEntity& entity){
+            this->entity_name_=entity.entity_name_;
+            this->map_=entity.map_;
+        }
+        void put(std::string name, BvarMetric metric);
+        std::string to_prometheus();
+    private:
+        std::string entity_name_;
+        std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;
+        bthread::Mutex mutex_;
+    };
+
+    class BvarMetricRegistry{
+    public:
+        static BvarMetricRegistry* instance(){
+            static BvarMetricRegistry registry;
+            return &registry;
+        }
+        void put(BvarMetricEntity entity);
+        std::string to_prometheus();
+    private:
+        BvarMetricRegistry()=default;
+        std::string registry_name_;
+        std::vector<std::shared_ptr<BvarMetricEntity>> vec_;

Review Comment:
   warning: no member named 'shared_ptr' in namespace 'std' 
[clang-diagnostic-error]
   ```cpp
           std::vector<std::shared_ptr<BvarMetricEntity>> vec_;
                            ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;
+    };
+
+    class BvarMetricEntity{
+    public:
+        BvarMetricEntity()=default;
+        BvarMetricEntity(std::string entity_name){
+            this->entity_name_=entity_name;
+        }
+        BvarMetricEntity(BvarMetricEntity& entity){
+            this->entity_name_=entity.entity_name_;
+            this->map_=entity.map_;
+        }
+        void put(std::string name, BvarMetric metric);
+        std::string to_prometheus();
+    private:
+        std::string entity_name_;
+        std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;
+        bthread::Mutex mutex_;
+    };
+
+    class BvarMetricRegistry{
+    public:
+        static BvarMetricRegistry* instance(){
+            static BvarMetricRegistry registry;
+            return &registry;
+        }
+        void put(BvarMetricEntity entity);
+        std::string to_prometheus();
+    private:
+        BvarMetricRegistry()=default;
+        std::string registry_name_;
+        std::vector<std::shared_ptr<BvarMetricEntity>> vec_;

Review Comment:
   warning: 'BvarMetricEntity' does not refer to a value 
[clang-diagnostic-error]
   ```cpp
           std::vector<std::shared_ptr<BvarMetricEntity>> vec_;
                                       ^
   ```
   **be/src/util/bvar_metrics.h:82:** declared here
   ```cpp
       class BvarMetricEntity{
             ^
   ```
   



##########
be/src/util/bvar_metrics.h:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <bvar/reducer.h>
+#include <bvar/status.h>
+#include <bvar/latency_recorder.h>
+#include <bthread/mutex.h>
+
+namespace doris {
+
+    enum class BvarMetricType { COUNTER, GAUGE, HISTOGRAM, SUMMARY, UNTYPED };
+    enum class BvarMetricUnit {
+        NANOSECONDS,
+        MICROSECONDS,
+        MILLISECONDS,
+        SECONDS,
+        BYTES,
+        ROWS,
+        PERCENT,
+        REQUESTS,
+        OPERATIONS,
+        BLOCKS,
+        ROWSETS,
+        CONNECTIONS,
+        PACKETS,
+        NOUNIT,
+        FILESYSTEM
+    };
+    using Labels = std::unordered_map<std::string,std::string>;
+
+    class BvarMetric{
+    public:
+        BvarMetric()= default;
+        virtual ~BvarMetric()=default;
+        BvarMetric(BvarMetric&)=default;
+        BvarMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        
:type_(type),unit_(unit),name_(name),description_(description),group_name_(group_name),labels_(labels)
 {}
+        virtual std::string to_prometheus(bool with_tablet_metrics = false) 
const{return "";};
+        // std::string to_json(bool with_tablet_metrics = false) const;
+        // std::string to_core_string() const;
+    protected:
+        BvarMetricType type_;
+        BvarMetricUnit unit_;
+        std::string name_;
+        std::string description_;
+        std::string group_name_;
+        Labels labels_;
+    };
+
+    template <typename T>
+    class BvarAdderMetric:BvarMetric{
+    public:
+        BvarAdderMetric(BvarMetricType type,BvarMetricUnit unit,std::string 
name,std::string description,std::string group_name,Labels labels)
+        :BvarMetric(type,unit,name,description,group_name,labels){
+            adder_ = 
std::make_shared<bvar::Adder<T>>(group_name,name+'_'+description);
+        }
+        virtual ~BvarAdderMetric()=default;
+        void increment(T value);
+        void set_value(T value);
+        std::string to_prometheus(bool with_tablet_metrics = false) const 
override;
+    private:
+        std::shared_ptr<bvar::Adder<T>> adder_;
+    };
+
+    class BvarMetricEntity{
+    public:
+        BvarMetricEntity()=default;
+        BvarMetricEntity(std::string entity_name){
+            this->entity_name_=entity_name;
+        }
+        BvarMetricEntity(BvarMetricEntity& entity){
+            this->entity_name_=entity.entity_name_;
+            this->map_=entity.map_;
+        }
+        void put(std::string name, BvarMetric metric);
+        std::string to_prometheus();
+    private:
+        std::string entity_name_;
+        std::unordered_map<std::string, std::shared_ptr<BvarMetric>> map_;
+        bthread::Mutex mutex_;
+    };
+
+    class BvarMetricRegistry{
+    public:
+        static BvarMetricRegistry* instance(){
+            static BvarMetricRegistry registry;
+            return &registry;
+        }
+        void put(BvarMetricEntity entity);
+        std::string to_prometheus();
+    private:
+        BvarMetricRegistry()=default;
+        std::string registry_name_;
+        std::vector<std::shared_ptr<BvarMetricEntity>> vec_;
+        bthread::Mutex mutex_;
+    };
+
+    extern BvarMetricEntity server_metric_entity;
+    extern BvarAdderMetric<int64_t> g_adder_segment_read_total;
+    extern BvarAdderMetric<int64_t> g_adder_fragment_request_duration_us;
+    extern BvarAdderMetric<int64_t> g_adder_query_scan_bytes;
+    extern BvarAdderMetric<int64_t> g_adder_segment_read_total;

Review Comment:
   warning: redundant 'g_adder_segment_read_total' declaration 
[readability-redundant-declaration]
   
   ```suggestion
       
   ```
   **be/src/util/bvar_metrics.h:116:** previously declared here
   ```cpp
       extern BvarAdderMetric<int64_t> g_adder_segment_read_total;
                                       ^
   ```
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to