-
Notifications
You must be signed in to change notification settings - Fork 24
fix: add log for the result of the step #496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add log for the result of the step #496
Conversation
|
I think we should also add logging around the doRunSetupCommand function. |
|
I think it would be better if we could also get the setup time. |
@yuichi10 For doRunSetupCommand, I think logging is not necessary since this step usually completes very quickly and rarely fails( and I want to avoid repeating the same logging logic any more).
@foxtrot0304 Thanks for your comment, I had the same thought. |
|
The other setup steps are already covered by the current code. Here are the results from running it locally. |
Thank you! You’re right. it looks like logging for doRunSetupCommand isn’t necessary.
I see. I thought it wouldn't be too complex, especially since we don't need to consider doRunSetupCommand. I just thought we need to prepare one function like below. ( I do not care about func name. Also it's may not work ) func RunWithLogging(name string, fn func() (int, error)) (int, error) {
start := time.Now()
code, err := fn()
elapsedMS := time.Since(start).Milliseconds()
log.Printf("Completed step: name=%s, exit_code=%d, elapsed_ms=%d", name, code, elapsedMS)
return code, err
}
runCode, rcErr := RunWithLogging(cmd.Name, func() (int, error) {
return doRunCommand(guid, stepFilePath, emitter, f, fReader, cmd.Name)
})
eCode <- runCode
runErr <- rcErrIf we're logging the same information in both doRunCommand and doRunTeardownCommand, I felt it would be better to reduce duplicate code. Otherwise, if we need to change the log format later, we'd have to update it in two places. If the concern is more about having a wrapper itself making things complicated rather than the code being complex, I’m okay with keeping it as is. |
|
@yuichi10 Thanks for the comment — you’re right that if we change the log format later, we’d need to update it in multiple places. That said, if you think maintainability of the logging format is more important, I’m fine with updating it based on your suggested approach. |
|
We only have two places for now, so I think it’s fine to keep it simple without a wrapper. |
foxtrot0304
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Context
We’d like to analyze the build results and execution times for each step to understand which steps fail most often and which take the longest.
Objective
Add logging for each build step to include:
References
License
I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.