Task state change logging: use logger.Fields instead of plain strings #3674
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Refactor log messages for sending state changes to ECS to use logger.Fields and make container state change strings more readable.
In addition to refactoring the format, have also added the container runtime ID(s) and essential status.
from this:
level=info time=2023-05-03T21:47:39Z msg="Sending state change to ECS" eventType="task" eventData="TaskChange: [arn:aws:ecs:us-west-2:039193556298:task/usw2/53669439b60a420dbbf59d2ecaf5206f -> STOPPED, Known Sent: RUNNING, PullStartedAt: 2023-05-03 21:44:48.851603466 +0000 UTC, PullStoppedAt: 2023-05-03 21:44:50.425831882 +0000 UTC, ExecutionStoppedAt: 2023-05-03 21:47:39.738389362 +0000 UTC m=+1.237742685, container change: arn:aws:ecs:us-west-2:039193556298:task/usw2/53669439b60a420dbbf59d2ecaf5206f main -> STOPPED, Exit 137, , Known Sent: RUNNING] sent: false"
to this:
level=info time=2023-05-04T22:48:12Z msg="Sending state change to ECS" eventType="TaskStateChange" taskStatus="STOPPED" reason="" taskPullStartedAt="2023-05-04T21:56:30Z" taskExecutionStoppedAt="2023-05-04T22:48:12Z" containerChange-0="containerName=main containerStatus=STOPPED containerExitCode=137 containerKnownSentStatus=RUNNING containerRuntimeID=32745980a9121de4a8a39d91ceb35ff74a77737f25ce1de9b8a8dead166306cc containerIsEssential=true" taskArn="arn:aws:ecs:us-west-2:039193556298:task/usw2/8d73d245d6794ff695b1fcf14f8934da" taskKnownSentStatus="RUNNING" taskPullStoppedAt="2023-05-04T21:56:32Z"
Testing
make release
Description for the changelog
NA
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.