Skip to content

Commit 10528c9

Browse files
committed
only record exit telemetry for non-success case
1 parent b5a5837 commit 10528c9

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

lldb/source/Target/Process.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,27 +1069,31 @@ bool Process::SetExitStatus(int status, llvm::StringRef exit_string) {
10691069
std::lock_guard<std::mutex> guard(m_exit_status_mutex);
10701070
telemetry::ScopedDispatcher<telemetry::ProcessExitInfo> helper;
10711071

1072-
// Find the executable-module's UUID, if available.
1073-
UUID module_uuid;
1074-
TargetSP target_sp(Debugger::FindTargetWithProcessID(m_pid));
1075-
if (target_sp) {
1076-
helper.SetDebugger(&target_sp->GetDebugger());
1077-
if (ModuleSP mod = target_sp->GetExecutableModule())
1078-
module_uuid = mod->GetUUID();
1079-
}
1080-
1081-
helper.DispatchNow([&](telemetry::ProcessExitInfo *info) {
1082-
info->module_uuid = module_uuid;
1083-
info->pid = m_pid;
1084-
info->is_start_entry = true;
1085-
info->exit_desc = {status, exit_string.str()};
1086-
});
1072+
// Only dispatch telemetry for a non-success case to reduce
1073+
// chances of slowing down the code.
1074+
// FIXME: Remove this conditional monitoring as it means we lose the ability
1075+
// to monitor exit-operations' time for the average case.
1076+
if (status != 0) {
1077+
UUID module_uuid;
1078+
TargetSP target_sp(Debugger::FindTargetWithProcessID(m_pid));
1079+
if (target_sp) {
1080+
helper.SetDebugger(&target_sp->GetDebugger());
1081+
if (ModuleSP mod = target_sp->GetExecutableModule())
1082+
module_uuid = mod->GetUUID();
1083+
}
10871084

1088-
helper.DispatchOnExit([&](telemetry::ProcessExitInfo *info) {
1089-
info->module_uuid = module_uuid;
1090-
info->pid = m_pid;
1091-
});
1085+
helper.DispatchNow([&](telemetry::ProcessExitInfo *info) {
1086+
info->module_uuid = module_uuid;
1087+
info->pid = m_pid;
1088+
info->is_start_entry = true;
1089+
info->exit_desc = {status, exit_string.str()};
1090+
});
10921091

1092+
helper.DispatchOnExit([&](telemetry::ProcessExitInfo *info) {
1093+
info->module_uuid = module_uuid;
1094+
info->pid = m_pid;
1095+
});
1096+
}
10931097
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
10941098
LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",
10951099
GetPluginName(), status, exit_string);

0 commit comments

Comments
 (0)