You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "haolujun (via GitHub)" <gi...@apache.org> on 2023/05/12 02:26:47 UTC

[I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

haolujun opened a new issue, #2244:
URL: https://github.com/apache/brpc/issues/2244

   **Describe the bug (描述bug)**
   如何用代码的方式关闭sampling 线程?
   
   **To Reproduce (复现方法)**
   namespace bvar {
   namespace detai {
     DECLARE_bool(bvar_enable_sampling);
   }
   }
   
   int main () {
    bvar::detail::FLAGS_bvar_enable_sampling = false;
    return 0;
   }
   
   **Expected behavior (期望行为)**
   关闭bvar的sampling线程。
   
   **Versions (各种版本)**
   OS:
   Linux c1089df56064 4.9.70-040970-generic #201712161132 SMP Sat Dec 16 16:33:52 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
   
   Compiler:
   gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
   Copyright (C) 2017 Free Software Foundation, Inc.
   This is free software; see the source for copying conditions.  There is NO
   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   
   brpc: 1.4.0
   protobuf: protobuf-3.19.5
   
   **Additional context/screenshots (更多上下文/截图)**
   
   :W20230511 18:29:16.687115    87 sampler.cpp:194] bvar is busy at sampling for 2 seconds!


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


Re: [I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

Posted by "antkiller996 (via GitHub)" <gi...@apache.org>.
antkiller996 commented on issue #2244:
URL: https://github.com/apache/brpc/issues/2244#issuecomment-1835500056

   举个例子,如果我开启enable_rpcz,并且关闭bvar_enable_sampling,按照预期rpc_data目录不会记录span信息,文件也不会膨胀。


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


Re: [I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
wwbmmm commented on issue #2244:
URL: https://github.com/apache/brpc/issues/2244#issuecomment-1545031483

   使用google::SetCommandLineOption("bvar_enable_sampling", "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


Re: [I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

Posted by "yanglimingcn (via GitHub)" <gi...@apache.org>.
yanglimingcn commented on issue #2244:
URL: https://github.com/apache/brpc/issues/2244#issuecomment-1573318452

   关闭这个对监控指标会有啥问题吗?
   比如,curl http://xxx:port/vars


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


Re: [I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

Posted by "leaf-potato (via GitHub)" <gi...@apache.org>.
leaf-potato commented on issue #2244:
URL: https://github.com/apache/brpc/issues/2244#issuecomment-1638025055

   > 关闭这个对监控指标会有啥问题吗? 比如,curl http://xxx:port/vars
   
   @yanglimingcn bvar的统计值都会失效,参考https://github.com/apache/brpc/issues/1891


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


Re: [I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

Posted by "leaf-potato (via GitHub)" <gi...@apache.org>.
leaf-potato commented on issue #2244:
URL: https://github.com/apache/brpc/issues/2244#issuecomment-1817802398

   > ![image](https://user-images.githubusercontent.com/126752534/281655776-a7eafedf-b1fc-4575-9e10-2f3db7ed2b00.png)
   > 
   > 这个Flags使用是在main函数之前的,所以在main函数之后任何对其操作貌似都不会关闭统计线程。
   
   注释想表法:`SamplerCollector`单例在main函数之前构造的&启动了线程,所以flag实现不能放在`SamplerCollector`类中,因为不会生效。所以才放到了`Sampler::schedule`函数这儿控制。
   
   另外在`echo_c++`例子中使用下面两种方式看着都可以正确关闭:
   1. `bvar::detail::FLAGS_bvar_enable_sampling = false;`
   2. `google::SetCommandLineOption("bvar_enable_sampling", "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


Re: [I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

Posted by "antkiller996 (via GitHub)" <gi...@apache.org>.
antkiller996 commented on issue #2244:
URL: https://github.com/apache/brpc/issues/2244#issuecomment-1835488939

   > > ![image](https://user-images.githubusercontent.com/126752534/281655776-a7eafedf-b1fc-4575-9e10-2f3db7ed2b00.png)
   > > 这个Flags使用是在main函数之前的,所以在main函数之后任何对其操作貌似都不会关闭统计线程。
   > 
   > 注释想表达:`SamplerCollector`单例在main函数之前构造的&启动了线程,所以flag实现不能放在`SamplerCollector`类中,因为不会生效。所以才放到了`Sampler::schedule`函数这儿控制。
   > 
   > 另外在`echo_c++`例子中使用下面两种方式看着都可以正确关闭:
   > 
   > 1. `bvar::detail::FLAGS_bvar_enable_sampling = false;`
   > 2. `google::SetCommandLineOption("bvar_enable_sampling", "false");`
   
   我使用的是1.6.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


Re: [I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

Posted by "antkiller996 (via GitHub)" <gi...@apache.org>.
antkiller996 commented on issue #2244:
URL: https://github.com/apache/brpc/issues/2244#issuecomment-1835515012

   ![image](https://github.com/apache/brpc/assets/126752534/91f68c48-bac8-4d6e-9e5d-b325b8704801)
   看起了Sampler::schedule() 也在main函数之前运行了。所以这个FLAGS_bvar_enable_sampling 并控制不到sampling线程是否启动


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


Re: [I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

Posted by "Karssadin (via GitHub)" <gi...@apache.org>.
Karssadin commented on issue #2244:
URL: https://github.com/apache/brpc/issues/2244#issuecomment-3095812230

   > 看起了Sampler::schedule() 也在main函数之前运行了。所以这个FLAGS_bvar_enable_sampling 并控制不到sampling线程是否启动
   
   可以试下__attribute__((constructor())弄一个函数来set flag,因为在执行时static的变量要先于main


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

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


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


Re: [I] 为什么代码方式关闭不了bvar sampling线程? (brpc)

Posted by "antkiller996 (via GitHub)" <gi...@apache.org>.
antkiller996 commented on issue #2244:
URL: https://github.com/apache/brpc/issues/2244#issuecomment-1803317613

   ![image](https://github.com/apache/brpc/assets/126752534/a7eafedf-b1fc-4575-9e10-2f3db7ed2b00)
   
   这个Flags使用是在main函数之前的,所以在main函数之后任何对其操作貌似都不会关闭统计线程。


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