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/08/06 01:04:23 UTC

[GitHub] [incubator-brpc] jenrryyou commented on a diff in pull request #1854: support customized server bvar prefix

jenrryyou commented on code in PR #1854:
URL: https://github.com/apache/incubator-brpc/pull/1854#discussion_r939460992


##########
src/brpc/server.cpp:
##########
@@ -271,7 +271,11 @@ static bvar::Vector<unsigned, 2> GetSessionLocalDataCount(void* arg) {
 }
 
 std::string Server::ServerPrefix() const {
-    return butil::string_printf("%s_%d", g_server_info_prefix, listen_address().port);
+    if(_options.name.empty()) {
+        return butil::string_printf("%s_%d", g_server_info_prefix, listen_address().port);
+    } else {
+        return std::string(g_server_info_prefix) + "_" + _options.name;

Review Comment:
   目前PrometheusMetricsDumper::DumpLatencyHistogramRecorderSuffix通过g_server_info_prefix前缀来区分哪些bvar需要导入,全部自定义不好兼容这个逻辑。
   
   ```cpp
   bool PrometheusMetricsDumper::DumpLatencyHistogramRecorderSuffix(
       const butil::StringPiece& name,
       const butil::StringPiece& desc) {
       if (!name.starts_with(_server_prefix)) {
           return false;
       }
   ```
   



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