You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2022/10/18 04:01:34 UTC

[GitHub] [incubator-brpc] ldak4747 opened a new issue, #1956: 支持MultiDimension后,如果想获取1秒内,该metric的各个label的"求和"/"均值",应该怎么做?

ldak4747 opened a new issue, #1956:
URL: https://github.com/apache/incubator-brpc/issues/1956

   即,是不是对于同一个MultiDimension(如求和,bvar::MultiDimension<bvar::Adder<uint32_t>>),其每个label取值,对应的recorder(如求和,bvar::Adder<uint32_t>),都需要一个Window的实例?
   
   类似,如已有:
       static const std::list<std::string> labels = {"idc", "method", "status"};
   ......
       std::list<std::string> labels_value = {"bj", "get", "200"};
       bvar::MultiDimension<bvar::Adder<uint32_t> > my_madder1("request_count_madder_uint32_t", labels);
       bvar::Adder<uint32_t>* my_adder1 = my_madder1.get_stats(labels_value);
   
       针对label取值为 {"bj", "get", "200"},获取其一秒window(求和/平均),是否需要一个:
       bvar::Window<bvar::Adder<uint32_t>>(.....)与之对应呢?


-- 
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: dev-unsubscribe@brpc.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] ldak4747 closed issue #1956: 支持MultiDimension后,如果想获取1秒内,该metric的各个label的"求和"/"均值",应该怎么做?

Posted by GitBox <gi...@apache.org>.
ldak4747 closed issue #1956: 支持MultiDimension后,如果想获取1秒内,该metric的各个label的"求和"/"均值",应该怎么做?
URL: https://github.com/apache/incubator-brpc/issues/1956


-- 
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: dev-unsubscribe@brpc.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] wwbmmm commented on issue #1956: 支持MultiDimension后,如果想获取1秒内,该metric的各个label的"求和"/"均值",应该怎么做?

Posted by GitBox <gi...@apache.org>.
wwbmmm commented on issue #1956:
URL: https://github.com/apache/incubator-brpc/issues/1956#issuecomment-1281848836

   @serverglen 看下


-- 
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: dev-unsubscribe@brpc.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] serverglen commented on issue #1956: 支持MultiDimension后,如果想获取1秒内,该metric的各个label的"求和"/"均值",应该怎么做?

Posted by GitBox <gi...@apache.org>.
serverglen commented on issue #1956:
URL: https://github.com/apache/incubator-brpc/issues/1956#issuecomment-1283825698

   我们内部目前还没有这种使用场景,需要在多维度的基础上设计下这种场景的实现方式。


-- 
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: dev-unsubscribe@brpc.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] ldak4747 commented on issue #1956: 支持MultiDimension后,如果想获取1秒内,该metric的各个label的"求和"/"均值",应该怎么做?

Posted by GitBox <gi...@apache.org>.
ldak4747 commented on issue #1956:
URL: https://github.com/apache/incubator-brpc/issues/1956#issuecomment-1283839476

   我这两天的实践发现不太明白,我贴下代码:
   
   ////// 1、基类,定义了一个多维度的metric,::bvar::MultiDimension<Recorder>类型
   template<class Recorder>
   class MBvarBaseInstance {
   public:
       using MdRecorder = ::bvar::MultiDimension<Recorder>;
       MBvarBaseInstance(
           const std::string &metric_name, const std::list<std::string> &labels)
           : metric_name_(metric_name) {
           recorder_md_.reset(
               new ::bvar::MultiDimension<Recorder>(metric_name, labels));
       }
   
       const std::string &GetMetricName() const { return metric_name_; }
   
       void EventRecordIncr(const std::list<std::string> &label_value) const {
           if (!recorder_md_) { return; }
           Recorder *recorder = GetLabelRecorder(label_value);
           if (recorder) { (*recorder) << 1; }
       }
   
       Recorder *GetLabelRecorder(const std::list<std::string> &label_value) const {
           if (!recorder_md_) { return nullptr; }
           return recorder_md_->get_stats(label_value);
       }
   
   private:
       std::string metric_name_;
       std::unique_ptr<MdRecorder> recorder_md_;
   };
   
   
   /////// 2、用于生成多维度的window实例的类型,通过具体的labels,获取对应的adder,并根据adder生成::bvar::Window对象
   /////// 也就是,每个维度取值,对应一个本类的对象:含有该label对应的adder,还含有根据此adder生成的::bvar::Window对象
   template<class Recorder>
   class MBvarInstance {
   public:
       using WindowType = ::bvar::Window<Recorder, ::bvar::SERIES_IN_SECOND>;
       MBvarInstance() = default;
       MBvarInstance(const MBvarBaseInstance<Recorder> &base_instance,
                     const std::list<std::string> &label_values,
                     time_t window_size = 1) {
           recorder_ = base_instance.GetLabelRecorder(label_values);
           if (window_size > 0 && recorder_) {
               window_.reset(
               new WindowType(base_instance.GetMetricName(), recorder_, window_size));
           }
       }
       ~MBvarInstance() { recorder_ = nullptr; }
   
       template<class DataType>
       MBvarInstance<Recorder> &operator<<(DataType value) {
           if (recorder_) {
               (*recorder_) << value;
           }
   
           return *this;
       }
   
   private:
       Recorder *recorder_ = nullptr;
       std::unique_ptr<WindowType> window_;
   };
   
   
   
   
   ////// 3、全局变量index_req_md_stater,它只有一种类型的label
   using SumWindowRecorder = ::bvar::Adder<uint64_t>;
   MBvarBaseInstance<SumWindowRecorder> index_req_md_stater(
       "index_req_cnt", {"index_name"});
   
   //////// 4、针对"index_1",生产该label取值,对应的"含adder和::bvar::Window对象"的MBvarInstance实例
   std::list<std::string> label = {"index_1"};
   MBvarInstance<SumWindowRecorder> index_req_handle(index_req_md_stater, label);
   
   /////// 5、MBvarInstance实例,自增这个计数
   index_req_handle << 1
   
   
   
   //////// 6、curl 127.0.0.1:8080/brpc_metrics | grep -E 'index_req_cnt|index_1'
   为空,也就是多维的metric"index_req_cnt",及其label"index_1",都没有获取到
   
   
   
   
   
   是不是我的用法有问题?


-- 
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: dev-unsubscribe@brpc.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] cdjingit commented on issue #1956: 支持MultiDimension后,如果想获取1秒内,该metric的各个label的"求和"/"均值",应该怎么做?

Posted by GitBox <gi...@apache.org>.
cdjingit commented on issue #1956:
URL: https://github.com/apache/incubator-brpc/issues/1956#issuecomment-1284852528

   可以用bvar::WindowEx实现多维度, 不过现在多维度不支持metic的导出


-- 
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: dev-unsubscribe@brpc.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org