-
Notifications
You must be signed in to change notification settings - Fork 812
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
Add traceID if possible when using context logger. #2518
Conversation
Need rebase on #2521 once merged. |
Signed-off-by: Cyril Tovena <[email protected]>
I've pushed a commit to rebase |
7671211
to
8c39552
Compare
@@ -127,7 +129,7 @@ func WithUserID(userID string, l log.Logger) log.Logger { | |||
// its details. | |||
func WithTraceID(traceID string, l log.Logger) log.Logger { | |||
// See note in WithContext. | |||
return log.With(l, "trace_id", traceID) | |||
return log.With(l, "traceID", traceID) |
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.
I'm also renaming span_id to spanID because we have inconsistency with weaveworks server which uses spanID.
Note to myself: I guess you meant traceID
and not spanID
.
pkg/util/log.go
Outdated
if err != nil { | ||
if err != nil && err != user.ErrNoOrgID { | ||
return l | ||
} | ||
l = WithUserID(userID, l) | ||
if err == nil { | ||
l = WithUserID(userID, l) | ||
} |
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.
Can't we simplify it as the following, so that the trace ID is injected in any case?
if err == nil {
l = WithUserID(userID, l)
}
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.
Agree, let's do that.
For reference:
|
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
This change the behaviour of the context logger, there is situation where we don't have an org_id and we would still want to log with the spanID.
I'm also renaming
span_id
tospanID
because we have inconsistency with weaveworks server which usesspanID
. Wasn't sure if this would be welcomed change in weaveworks but I'm can send the PR there.Signed-off-by: Cyril Tovena [email protected]