Be consistent with span logging, set error=true and use otlog.Error#2970
Conversation
|
Isn’t this better solved by consistently using spanlogger that we use elsewhere? |
|
Good point, looks like spanlogger |
pracucci
left a comment
There was a problem hiding this comment.
@cstyan Thanks for fixing this. I left few comments.
Could you fix the linter, please? For the error Error return value of log.Error is not checked (errcheck) you could just add it to the ignore list defined in .errcheck-exclude (we don't want to check errors from logger)
There was a problem hiding this comment.
New span here. Should replace the context, no?
There was a problem hiding this comment.
I'm basing this off how we used the ot library sp, _ := opentracing.StartSpanFromContext(ctx, "ParseQueryRangeResponse"), where we ignored the returned context. I don't know the historical reason behind doing it that way, so if you think it should change here with the introduction of spanlogger that's fine by me.
There was a problem hiding this comment.
I think the reason is that ctx is not used below within this function. I believe replacing it is more future proof to avoid mistakes (we should do it once we'll start using ctx below and it's easy to forget to do it).
There was a problem hiding this comment.
Isn't the previous message "wrong number of samples" more correct? It's also what we log.
|
Thanks for the review @pracucci, I've replied to the comments that are still open, let me know what you think. |
|
@pracucci can you let me know your preferences re: my replies to your comments? |
There was a problem hiding this comment.
I believe we shouldn't repeat this nolint comment wherever we use log.Error() but add it to .errcheck-exclude. What do you think?
There was a problem hiding this comment.
I couldn't get that to work properly, for various variations of (import path.Struct).Function. If you have a suggestion for what to use as the entry in that file let me know.
There was a problem hiding this comment.
Please see the latest commit as well, if we want to have the ctx assignment in the bigtable index client for example, we need nolint comments again.
There was a problem hiding this comment.
I think (*github.com/cortexproject/cortex/pkg/util/spanlogger.SpanLogger).Error should work (it does with standalone errcheck utility). When I update golangci-lint in the build image to 1.30.0, I no longer see this warning, even without changing .errcheck-exclude. 😕
We could also remove error return value from this method, since no production code uses it.
There was a problem hiding this comment.
I think the reason is that ctx is not used below within this function. I believe replacing it is more future proof to avoid mistakes (we should do it once we'll start using ctx below and it's easy to forget to do it).
|
While doing this change, would it make sense to move error-marking to This would also make (I thought it already works this way when making my earlier suggestion, but that doesn't seem to be the case) |
|
Thanks for the review again @pracucci I think everything is updated correctly now. There's just the lint exclusion left, I was not able to get an entry into the file that worked locally, which is why I went with the nolint comments. @pstibrany are you referring to the spanloggers |
error, this is so we consistently have the error=true tag set. Signed-off-by: Callum Styan <callumstyan@gmail.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>
Yes, I'm referring to |
attempt to avoid use of the incorrect ctx in the future. Signed-off-by: Callum Styan <callumstyan@gmail.com>
Oh interesting, TIL. Good find, yeah we could then check Are you okay if I just open a new issue to look into this, instead of doing it as part of this PR? Having the error tags in general is going to help with debugging the ruler already, which is what prompted me to make this change. |
pstibrany
left a comment
There was a problem hiding this comment.
Oh interesting, TIL. Good find, yeah we could then check
kvpsfor alevel=errorcombination and set the tag on the span. The question would be whether we want to assign all kvps as fields on the span as tags or log messages, or just look for a second fielderrorerror.
Log method already adds all kvps as fields to the span, but doesn't mark span with error flag, and doesn't use correct key for error value.
Are you okay if I just open a new issue to look into this, instead of doing it as part of this PR? Having the error tags in general is going to help with debugging the ruler already, which is what prompted me to make this change.
👍
There was a problem hiding this comment.
I think (*github.com/cortexproject/cortex/pkg/util/spanlogger.SpanLogger).Error should work (it does with standalone errcheck utility). When I update golangci-lint in the build image to 1.30.0, I no longer see this warning, even without changing .errcheck-exclude. 😕
We could also remove error return value from this method, since no production code uses it.
Signed-off-by: Marco Pracucci <marco@pracucci.com>
pracucci
left a comment
There was a problem hiding this comment.
LGTM! @pstibrany do you have any other comment?
It's very confusing to look at a trace UI for two traces that seemed to have failed for the same reason, yet one has error ! icons and the other doesn't. This seems to be a side effect of not setting
error=trueon all error cases, and one case where we haderror="a string".There's also a change required in upstream weaveworks/common to add another
error=trueSigned-off-by: Callum Styan callumstyan@gmail.com
cc @gouthamve @gotjosh @joe-elliott
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]