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/12/23 11:22:33 UTC

[GitHub] [incubator-brpc] 17336 opened a new issue, #2059: 请问bvar变量的expose接口有什么用呢?

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

   我初始化了一个bvar变量,没有经过expose也能在http网页上观察到bvar的变化,所以expose接口有什么用呢
   ![image](https://user-images.githubusercontent.com/74393844/209327675-c06fd1c8-5ce8-4ad2-be36-27800eb6075b.png)
   


-- 
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] leaf-potato commented on issue #2059: 请问bvar变量的expose接口有什么用呢?

Posted by GitBox <gi...@apache.org>.
leaf-potato commented on issue #2059:
URL: https://github.com/apache/incubator-brpc/issues/2059#issuecomment-1363967074

   使用的多维度bvar?能否给下使用代码例子?


-- 
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] 17336 commented on issue #2059: 请问bvar变量的expose接口有什么用呢?

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

   > 使用的多维度bvar?能否给下使用代码例子?
   
   不是,单维度的bvar
   
   ```
   namespace other_metric {
       bvar::Adder<int> time;
       bvar::Window<bvar::Adder<int> > time_minitue("metric", "time", &time, 60);
   }
   void increase_bvar() {
       while(true){
           other_metric::time<<1;
           std::this_thread::sleep_for(std::chrono::seconds(1));
       }
   }
   
   int main(int argc, char* argv[]) {
       // Parse gflags. We recommend you to use gflags as well.
       GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
   
       // Generally you only need one Server.
       brpc::Server server;
   
       // Instance of your service.
       example::EchoServiceImpl echo_service_impl;
   
       // Add the service into server. Notice the second parameter, because the
       // service is put on stack, we don't want server to delete it, otherwise
       // use brpc::SERVER_OWNS_SERVICE.
       if (server.AddService(&echo_service_impl, 
                             brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
           LOG(ERROR) << "Fail to add service";
           return -1;
       }
   
       butil::EndPoint point;
       if (!FLAGS_listen_addr.empty()) {
           if (butil::str2endpoint(FLAGS_listen_addr.c_str(), &point) < 0) {
               LOG(ERROR) << "Invalid listen address:" << FLAGS_listen_addr;
               return -1;
           }
       } else {
           point = butil::EndPoint(butil::IP_ANY, FLAGS_port);
       }
       // Start the server.
       brpc::ServerOptions options;
       options.idle_timeout_sec = FLAGS_idle_timeout_s;
       if (server.Start(point, &options) != 0) {
           LOG(ERROR) << "Fail to start EchoServer";
           return -1;
       }
       std::thread t(increase_bvar);
       // Wait until Ctrl-C is pressed, then Stop() and Join() the server.
       server.RunUntilAskedToQuit();
       t.join();
       return 0;
   }
   ```


-- 
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] 17336 closed issue #2059: 请问bvar变量的expose接口有什么用呢?

Posted by GitBox <gi...@apache.org>.
17336 closed issue #2059: 请问bvar变量的expose接口有什么用呢?
URL: https://github.com/apache/incubator-brpc/issues/2059


-- 
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] 17336 commented on issue #2059: 请问bvar变量的expose接口有什么用呢?

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

   > 使用的多维度bvar?能否给下使用代码例子?
   我知道了,源码里Window类型的bvar会在初始化时自动expose,但是Adder不行,需要手动expose。


-- 
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