Skip to content

Commit c9d08dd

Browse files
authored
Merge pull request #5315 from jsternberg/trace-id-in-log
bklog: always enable trace id if it exists
2 parents b2b8b1c + 366c355 commit c9d08dd

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

util/bklog/log.go

+5-15
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ var (
2020
L = logrus.NewEntry(logrus.StandardLogger())
2121
)
2222

23-
var (
24-
logWithTraceID = false
25-
)
26-
27-
func EnableLogWithTraceID(b bool) {
28-
logWithTraceID = b
29-
}
30-
3123
type (
3224
loggerKey struct{}
3325
)
@@ -51,13 +43,11 @@ func GetLogger(ctx context.Context) (l *logrus.Entry) {
5143
l = L
5244
}
5345

54-
if logWithTraceID {
55-
if spanContext := trace.SpanFromContext(ctx).SpanContext(); spanContext.IsValid() {
56-
return l.WithFields(logrus.Fields{
57-
"traceID": spanContext.TraceID(),
58-
"spanID": spanContext.SpanID(),
59-
})
60-
}
46+
if spanContext := trace.SpanFromContext(ctx).SpanContext(); spanContext.IsValid() {
47+
return l.WithFields(logrus.Fields{
48+
"traceID": spanContext.TraceID(),
49+
"spanID": spanContext.SpanID(),
50+
})
6151
}
6252

6353
return l

0 commit comments

Comments
 (0)