From a81b31ce763ea71d8ae57ae3e88520123d47fd36 Mon Sep 17 00:00:00 2001 From: Jiashuo Date: Tue, 16 Nov 2021 14:20:38 +0800 Subject: [PATCH] fix: break execute some method when disable latency tracer (#965) --- src/utils/latency_tracer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/latency_tracer.cpp b/src/utils/latency_tracer.cpp index f0d2e660a2..b61eb5638c 100644 --- a/src/utils/latency_tracer.cpp +++ b/src/utils/latency_tracer.cpp @@ -131,7 +131,7 @@ latency_tracer::latency_tracer(bool is_sub, latency_tracer::~latency_tracer() { - if (_is_sub) { + if (!_enable_trace || _is_sub) { return; } @@ -190,6 +190,10 @@ void latency_tracer::add_sub_tracer(const std::shared_ptr &trace std::shared_ptr latency_tracer::sub_tracer(const std::string &name) { + if (!_enable_trace) { + return nullptr; + } + utils::auto_read_lock read(_sub_lock); auto iter = _sub_tracers.find(name); if (iter != _sub_tracers.end()) {