Skip to content

Commit 366c355

Browse files
committed
bklog: always enable trace id if it exists
Previous version of the detect package would only enable trace ids in the build log if tracing was in use. For practical purposes, there was always a tracer in use (either the recorder which was always enabled or one of the detected tracers). When this package was refactored, the call to enable the trace id was accidentally removed. This removes the option to enable or disable the trace id from the log and instead just always enables it since this was the behavior previously. Signed-off-by: Jonathan A. Sternberg <[email protected]>
1 parent a1993e8 commit 366c355

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

util/bklog/log.go

Lines changed: 5 additions & 15 deletions
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)