Improves logging message for failed analysis#442
Conversation
c7aeb3e to
e586c2c
Compare
|
UPDATE: this comments now refers to #443 This PR is composed by two commits. Actually the first one is enough to close #368. Anyway with the second commit I tried to remove some duplicated code. Let me know what do you think (as obviously I don't have the big picture 😛yet), in any case it can be easily removed and it was very helpful for studying the code in depth 👍. One thing to note regarding the duplicated code removal is that there could be a slight worsening in performance given that |
c75df77 to
744eb7c
Compare
932fa6e to
578836d
Compare
42709cb to
8b79c93
Compare
8b79c93 to
0871118
Compare
|
Splitted the refactor part into a separate PR. |
0871118 to
2958e90
Compare
|
I saw some messages from
|
|
@dpordomingo Resolved and added comments on |
2958e90 to
e7484c6
Compare
server/server.go
Outdated
| errMessage = fmt.Sprintf("code: %s - message: %s", grpcStatus.Code(), grpcStatus.Message()) | ||
| } | ||
|
|
||
| aLogger.Errorf(err, "analysis failed: %s", errMessage) |
There was a problem hiding this comment.
aren't we repeat code&message here?
There was a problem hiding this comment.
Are you talking about errors without a friendly message? In that case the logged message is something like this:
msg="analysis failed: code: Unknown - message: review error" analyzer=Dummy app=lookoutd error="rpc error: code = Unknown desc = review error"
so code and message are repeated in the error object of the log context. Maybe something as follows is better?
if err != nil {
grpcStatus := status.Convert(err)
errMessage := "analysis failed"
friendlyMessage, ok := logErrorMessages[grpcStatus.Code()]
if ok {
errMessage = fmt.Sprintf("%s: %s", errMessage, friendlyMessage)
}
aLogger.Errorf(err, errMessage)
...
}
There was a problem hiding this comment.
Yep. It makes more sense for me.
|
|
||
| func TestErrorAnalyzerIntegrationSuite(t *testing.T) { | ||
| suite.Run(t, new(ErrorAnalyzerIntegrationSuite)) | ||
| suite.Run(t, &ErrorAnalyzerIntegrationSuite{ |
There was a problem hiding this comment.
Usually Test...Suite is just a wrapper for one stretchr/testify suite. With these two suite.Run inside the same test we get:
go test -v -parallel 1 -tags='integration' github.com/src-d/lookout/cmd/server-test -run TestErrorAnalyzerIntegrationSuite/TestAnalyzerErr
=== RUN TestErrorAnalyzerIntegrationSuite
=== RUN TestErrorAnalyzerIntegrationSuite/TestAnalyzerErr
=== RUN TestErrorAnalyzerIntegrationSuite/TestAnalyzerErr#01
--- PASS: TestErrorAnalyzerIntegrationSuite (15.60s)
--- PASS: TestErrorAnalyzerIntegrationSuite/TestAnalyzerErr (8.33s)
--- PASS: TestErrorAnalyzerIntegrationSuite/TestAnalyzerErr#01 (7.26s)
If one of the suites fails, it's hard to know which one is it. Also, it's hard to run only one of them, since they are bundled togueter.
Since you made a different mock analyzer for the timeout error, you could have two Test...Suite, probably in a different file, e.g. timeout_analyzer_test.go. startAnalyzer could be moved to common_test.go, maybe renaming it to startMockAnalyzer to avoid confusion.
server/server.go
Outdated
|
|
||
| var grpcErrorMessages = map[lookout.EventType]map[codes.Code]string{ | ||
| pb.PushEventType: map[codes.Code]string{ | ||
| codes.DeadlineExceeded: "timeout exceeded, try increasing analyzerPushTimeout", |
There was a problem hiding this comment.
analyzerPushTimeout is an internal name that will not be familiar to a user. Let's change this instead to
| codes.DeadlineExceeded: "timeout exceeded, try increasing analyzerPushTimeout", | |
| codes.DeadlineExceeded: "timeout exceeded, try increasing analyzer_push in config.yml", |
Same for the other message below.
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
838465a to
091605f
Compare
|
|
||
| func TestErrorAnalyzerIntegrationSuite(t *testing.T) { | ||
| suite.Run(t, new(ErrorAnalyzerIntegrationSuite)) | ||
| suite.Run(t, &ErrorAnalyzerIntegrationSuite{ |
There was a problem hiding this comment.
Now that ErrorAnalyzerIntegrationSuite and TimeoutErrorAnalyzerIntegrationSuite are different types maybe we could revert the changes for the new fields (configFile, analyzer, errMessage), and call suite.Run(t, new(ErrorAnalyzerIntegrationSuite)) here.
…yzerIntegrationSuite Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
|
I'm gonna rebase to |
dpordomingo
left a comment
There was a problem hiding this comment.
too late, but there in case you want to address it in a separated PR
| suite.sendEvent(successJSON) | ||
|
|
||
| suite.GrepTrue(suite.r, suite.errMessage) | ||
| suite.GrepTrue(suite.r, `msg="analysis failed: timeout exceeded, try increasing analyzer_review in config.yml" analyzer=Dummy app=lookoutd error="rpc error: code = DeadlineExceeded desc = context deadline exceeded"`) |
There was a problem hiding this comment.
@carlosms @se7entyse7en The config file could be a different file if passed with --config=; I'd purpose /config.yml/the config file/s, or similar, to cover those cases.
This closes #368.