-
Notifications
You must be signed in to change notification settings - Fork 351
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
Provide TraceID in the logs #2269
Conversation
48b53f9
to
e8d3148
Compare
Please describe the problem it solves. Is this open tracing relevant only? Do we need to log it for each log statement or only for selected logs? |
df429e2
to
5320626
Compare
@AlexanderYastrebov this is a draft PR for me to create a test image and use this image to check how will it work (and would it work at all) to provide traceID inside all logs. I just picked up some logs but hope this change to have an effect on all possible logs. |
4c899fb
to
ddf3927
Compare
ddf3927
to
e839801
Compare
2c09001
to
cb5aa90
Compare
64882d5
to
9dcbdd6
Compare
89cfe2d
to
378b919
Compare
09d44d0
to
5f6d7e2
Compare
filters/diag/logheader.go
Outdated
@@ -83,7 +82,7 @@ func (lh logHeader) Response(ctx filters.FilterContext) { | |||
} | |||
buf.WriteString("\r\n") | |||
|
|||
log.Println("Response for", buf.String()) | |||
ctx.Logger().Infof("Response for " + buf.String()) |
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.
Format string should always be a constant. Imagine what happens if buf contains format specifier e.g. %
:
package main
import "fmt"
func main() {
buf := "%s"
fmt.Printf("Response for " + buf)
}
outputs
Response for %!s(MISSING)
The proper way is ctx.Logger().Infof("Response for %s", buf)
.
The same applies to ctx.Logger().Errorf(err.Error())
as error message potentially may contain format specifiers.
See also https://owasp.org/www-community/attacks/Format_string_attack
5f6d7e2
to
c891f0e
Compare
b5dd90e
to
9e4bb39
Compare
Signed-off-by: Roman Zavodskikh <[email protected]>
9e4bb39
to
4024ece
Compare
👍 |
1 similar comment
👍 |
Followup on #2269 Signed-off-by: Alexander Yastrebov <[email protected]>
Followup on #2269 Signed-off-by: Alexander Yastrebov <[email protected]>
Signed-off-by: Roman Zavodskikh [email protected]