WingsGo commented on a change in pull request #4110: URL: https://github.com/apache/incubator-doris/pull/4110#discussion_r457223557
########## File path: be/src/util/thread.cpp ########## @@ -169,6 +174,81 @@ void ThreadMgr::remove_thread(const pthread_t& pthread_id, const std::string& ca ANNOTATE_IGNORE_READS_AND_WRITES_END(); } +void ThreadMgr::start_instrumentation(const WebPageHandler::ArgumentMap& args, EasyJson* ej) const { + const auto* category_name = FindOrNull(args, "group"); + if (category_name) { + bool requested_all = (*category_name == "all"); + ej->Set("requested_thread_group", EasyJson::kObject); + (*ej)["group_name"] = escape_for_html_to_string(*category_name); + (*ej)["requested_all"] = requested_all; + + // The critical section is as short as possible so as to minimize the delay + // imposed on new threads that acquire the lock in write mode. + vector<ThreadDescriptor> descriptors_to_print; + if (!requested_all) { + MutexLock l(&_lock); + const auto* category = FindOrNull(_thread_categories, *category_name); + if (category) { + for (const auto& elem : *category) { + descriptors_to_print.emplace_back(elem.second); + } + } + } else { + MutexLock l(&_lock); + for (const auto& category : _thread_categories) { + for (const auto& elem : category.second) { + descriptors_to_print.emplace_back(elem.second); + } + } + } + + EasyJson found = (*ej).Set("found", EasyJson::kObject); Review comment: I changed it, if category is not found, we will not show it ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org