scm: truncate long command output in logs (Bug 2036740)#1123
scm: truncate long command output in logs (Bug 2036740)#1123cgsheeh wants to merge 4 commits intomozilla-conduit:mainfrom
Conversation
|
View this pull request in Lando to land it once approved. |
zzzeid
left a comment
There was a problem hiding this comment.
Curious what problems this has already presented in the logs? Seems like something we can handle when parsing logs or via the logs UI / query. We could be losing some info here, and setting an arbitrary value for length doesn't seem like an improvement.
@zzzeid we're logging the entire patch content for each commit when running Alternatively we could add a flag to control the behaviour. We could either enable/disable the truncation, or enable/disable logging the command output altogether where appropriate. I figured this approach was a reasonable middle ground for now. |
It sounds like Lastly if there's an error with that command, we should probably still log the output as is since even the patch content may reveal something important. |
zzzeid
left a comment
There was a problem hiding this comment.
Having looked at this implementation, it would actually be more suitable as something that we define in the logging framework. Maybe adding a filter or special formatter in main.logging and making it applicable only to certain modules/commands that way, and only enabling it for say remote logging (or even prod) in settings.
This would avoid making any changes to scm.git or scm.hg.
There was a problem hiding this comment.
In your original description you mentioned this issue is with the hg export command. Do we need this to apply to git commands as well?
There was a problem hiding this comment.
Yes, git diff content doesn't need to be emitted in full to the logs, hence why I added truncate_log_output below.
There was a problem hiding this comment.
Hmm, for both the git cases, I think we could simply remove --stdout or use --output to prevent the unnecessary output in the first place (which may be a legacy implementation anyway). I wonder if this is something we can also do in hg commands? I think if we can avoid truncating output it would be best.
There was a problem hiding this comment.
In a way, if the output somehow ends up being incorrect, it's probably best to have some of it in the logs, for quicker identification, than none at all. Truncating would allow to retain that.
There was a problem hiding this comment.
That said, yes, not using --stdout may be a good idea (likely with --output-directory and --numbered-files to get predictable names).
How would you suggest we define this in the logging framework? We need to truncate the log output on a per-callsite basis, not a per-module or app-wide basis. We would either need to match commands by string in the log message (brittle), or have the call site add flags to opt them into the truncated logging (via |
I guess with our existing implementation there wouldn't be a way to do it without adding something to the if record.module == "hg" and record.funcName == "_hg_run":
...But if possible we should solve this problem by not using stdout in the first place (as I mentioned in the other comment). |
zzzeid
left a comment
There was a problem hiding this comment.
Oops my other comment did not get submitted, here it is.
There was a problem hiding this comment.
Hmm, for both the git cases, I think we could simply remove --stdout or use --output to prevent the unnecessary output in the first place (which may be a legacy implementation anyway). I wonder if this is something we can also do in hg commands? I think if we can avoid truncating output it would be best.
No description provided.