sampling: run @atexitr handlers in a try/catch, log if failure

Summary: sunshowers hit an exception (either an upgrade race or a module deinitialization) and while it was spurious, it can't hurt to run this logic in a try/catch anyway.

Reviewed By: ikostia

Differential Revision: D8360101

fbshipit-source-id: e581bdeb69e22571f547633b7219d6886cab1aa7
This commit is contained in:
Phil Cohen 2018-06-12 13:08:18 -07:00 committed by Facebook Github Bot
parent 2b01a523e3
commit dedad2a212

View File

@ -143,25 +143,25 @@ def gettopdir(repo):
def reposetup(ui, repo):
@repo.ui.atexit
def telemetry():
if util.safehasattr(repo, "requirements"):
ui.log(
"requirements",
generaldelta=str("generaldelta" in repo.requirements).lower(),
)
ui.log(
"requirements",
remotefilelog=str("remotefilelog" in repo.requirements).lower(),
)
try:
if util.safehasattr(repo, "requirements"):
ui.log(
"requirements",
generaldelta=str("generaldelta" in repo.requirements).lower(),
)
ui.log(
"requirements",
remotefilelog=str("remotefilelog" in repo.requirements).lower(),
)
maxrss = util.getmaxrss()
# Log maxrss from within the hg process. The wrapper logs its own
# value (which is incorrect if chg is used) so the column is
# prefixed.
ui.log("command_info", hg_maxrss=maxrss)
except NotImplementedError:
pass
except Exception as e:
ui.log("command_info", sampling_failure=e.message)
# Log other information that we don't want to log in the wrapper, if it's
# cheap to do so.