-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: Add Terraform command duration to log messages #3484
Conversation
a081b45
to
7c60f3e
Compare
@@ -147,13 +149,16 @@ func (s *ShellCommandRunner) RunCommandAsync(ctx command.ProjectContext) (chan<- | |||
// Wait for the command to complete. | |||
err = s.cmd.Wait() | |||
|
|||
dur := time.Since(start) |
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.
Please add a unit test for this in shell_command_runner_test.go
. if this doesn't exist, please create one to ensure this functionality works as expected and doesn't break in the future.
out, err := cmd.CombinedOutput() | ||
dur := time.Since(start) | ||
log := ctx.Log.With("duration", dur) |
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.
Same test request here (prev comment) please but for terraform_client_test.go
Hey @nitrocode thanks for the review. I definitely agree with that it would be nice to have unit tests for this, although I'm failing to come up with "simple" ones. There are a couple things that are getting in the way:
I'll continue to investigate what it's possible to do, tho, because I believe having tests is really useful. |
Hey @nitrocode I've added a test in |
Nice job @inkel . Yes, please add a test for the terraform client too. These tests will help preserve the feature you're adding. |
@nitrocode done! |
Closes runatlantis#3413. Signed-off-by: Leandro López (inkel) <[email protected]>
Signed-off-by: Leandro López (inkel) <[email protected]>
Signed-off-by: Leandro López (inkel) <[email protected]>
Signed-off-by: Leandro López (inkel) <[email protected]>
2b09c44
to
19efc41
Compare
Thank you! |
* Log duration of Terraform commands Closes runatlantis#3413. Signed-off-by: Leandro López (inkel) <[email protected]> * Make log message casing consistent Signed-off-by: Leandro López (inkel) <[email protected]> * Add tests for passing duration to Terraform comamnds logs Signed-off-by: Leandro López (inkel) <[email protected]> * Add logging mocks for testing Terraform client Signed-off-by: Leandro López (inkel) <[email protected]> --------- Signed-off-by: Leandro López (inkel) <[email protected]>
this does exactly what I want! Thank you!! |
* Log duration of Terraform commands Closes runatlantis#3413. Signed-off-by: Leandro López (inkel) <[email protected]> * Make log message casing consistent Signed-off-by: Leandro López (inkel) <[email protected]> * Add tests for passing duration to Terraform comamnds logs Signed-off-by: Leandro López (inkel) <[email protected]> * Add logging mocks for testing Terraform client Signed-off-by: Leandro López (inkel) <[email protected]> --------- Signed-off-by: Leandro López (inkel) <[email protected]>
* Log duration of Terraform commands Closes runatlantis#3413. Signed-off-by: Leandro López (inkel) <[email protected]> * Make log message casing consistent Signed-off-by: Leandro López (inkel) <[email protected]> * Add tests for passing duration to Terraform comamnds logs Signed-off-by: Leandro López (inkel) <[email protected]> * Add logging mocks for testing Terraform client Signed-off-by: Leandro López (inkel) <[email protected]> --------- Signed-off-by: Leandro López (inkel) <[email protected]>
what
This PR adds the wall clock duration of executing any Terraform command to the logs.
why
This information is useful for observability purposes.
tests
Tested the changes running Atlantis locally. Because it relies on
time.Now
adding tests that are not flaky is difficult.references