8000 Improve test log format by MichaelSnowden · Pull Request #3634 · temporalio/temporal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve test log format #3634

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

Merged
merged 1 commit into from
Nov 22, 2022
Merged

Improve test log format #3634

merged 1 commit into from
Nov 22, 2022

Conversation

MichaelSnowden
Copy link
Contributor

What changed?
I changed the Zap encoding of our logs to "console" instead of "json" during tests.

Why?
I made this change because it will give us more human-readable output when running tests, without affecting production. For example, stack traces will appear across multiple lines instead of a newline-escaped string on one line of JSON.

How did you test it?
Logs with this change:

=== RUN   TestTransferQueueStandbyTaskExecutorSuite/TestProcessActivityTask_Pending
2022-11-21T10:44:48.580-0800	error	example error	{"logging-call-at": "transferQueueStandbyTaskExecutor.go:78"}
go.temporal.io/server/common/log.(*zapLogger).Error
	/Users/michael.snowden/src/temporalio/temporal/common/log/zap_logger.go:144
go.temporal.io/server/service/history.newTransferQueueStandbyTaskExecutor
	/Users/michael.snowden/src/temporalio/temporal/service/history/transferQueueStandbyTaskExecutor.go:78
go.temporal.io/server/service/history.(*transferQueueStandbyTaskExecutorSuite).SetupTest
	/Users/michael.snowden/src/temporalio/temporal/service/history/transferQueueStandbyTaskExecutor_test.go:208
github.com/stretchr/testify/suite.Run.func1
	/Users/michael.snowden/go/1.19.2/pkg/mod/github.com/stretchr/testify@v1.8.1/suite/suite.go:165
testing.tRunner
	/Users/michael.snowden/.goenv/versions/1.19.2/src/testing/testing.go:1446
2022-11-21T10:44:48.582-0800	info	none	{"lifecycle": "Stopping", "component": "shard-engine", "logging-call-at": "context_impl.go:1525"}
2022-11-21T10:44:48.582-0800	info	none	{"lifecycle": "Stopped", "component": "shard-engine", "logging-call-at": "context_impl.go:1527"}
--- PASS: TestTransferQueueStandbyTaskExecutorSuite (0.00s)
    --- PASS: TestTransferQueueStandbyTaskExecutorSuite/TestProcessActivityTask_Pending (0.00s)
PASS

Logs without this change:

=== RUN   TestTransferQueueStandbyTaskExecutorSuite/TestProcessActivityTask_Pending
{"level":"error","ts":"2022-11-21T10:45:16.669-0800","msg":"example error","logging-call-at":"transferQueueStandbyTaskExecutor.go:78","stacktrace":"go.temporal.io/server/common/log.(*zapLogger).Error\n\t/Users/michael.snowden/src/temporalio/temporal/common/log/zap_logger.go:144\ngo.temporal.io/server/service/history.newTransferQueueStandbyTaskExecutor\n\t/Users/michael.snowden/src/temporalio/temporal/service/history/transferQueueStandbyTaskExecutor.go:78\ngo.temporal.io/server/service/history.(*transferQueueStandbyTaskExecutorSuite).SetupTest\n\t/Users/michael.snowden/src/temporalio/temporal/service/history/transferQueueStandbyTaskExecutor_test.go:208\ngithub.com/stretchr/testify/suite.Run.func1\n\t/Users/michael.snowden/go/1.19.2/pkg/mod/github.com/stretchr/testify@v1.8.1/suite/suite.go:165\ntesting.tRunner\n\t/Users/michael.snowden/.goenv/versions/1.19.2/src/testing/testing.go:1446"}
{"level":"info","ts":"2022-11-21T10:45:16.670-0800","msg":"none","lifecycle":"Stopping","component":"shard-engine","logging-call-at":"context_impl.go:1525"}
{"level":"info","ts":"2022-11-21T10:45:16.671-0800","msg":"none","lifecycle":"Stopped","component":"shard-engine","logging-call-at":"context_impl.go:1527"}
--- PASS: TestTransferQueueStandbyTaskExecutorSuite (0.00s)
    --- PASS: TestTransferQueueStandbyTaskExecutorSuite/TestProcessActivityTask_Pending (0.00s)
PASS

Potential risks
Anything that depends on this test output being JSON will be broken by this change.

Is hotfix candidate?
No.

@MichaelSnowden MichaelSnowden requested a review from a team as a code owner November 21, 2022 18:47
@MichaelSnowden MichaelSnowden merged commit ded2f67 into master Nov 22, 2022
@MichaelSnowden MichaelSnowden deleted the test-log-format branch November 22, 2022 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0