From 6b602592f5db1d2ce7cd8d890cdaf7c49e683576 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Wed, 6 Nov 2019 05:52:12 -0800 Subject: [PATCH] Allow disabling of stacksampling with an env var This gives an easy way to do so across all services without adding new options. Reasons to do so might be to avoid overheads or because your prometheus metrics grow too large. --- common/common/stats.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/common/stats.py b/common/common/stats.py index d8f83bf..86e7b39 100644 --- a/common/common/stats.py +++ b/common/common/stats.py @@ -194,6 +194,10 @@ def install_stacksampler(interval=0.005): We could use user+sys time but that leads to interrupting syscalls, which may affect performance, and we care mostly about user time anyway. """ + if os.environ.get('WUBLOADER_DISABLE_STACKSAMPLER', '').lower() == 'true': + logging.info("Not installing stacksampler - disabled by WUBLOADER_DISABLE_STACKSAMPLER env var") + return + # Note we only start each next timer once the previous timer signal has been processed. # There are two reasons for this: # 1. Avoid handling a signal while already handling a signal, however unlikely,