Skip to content

Commit

Permalink
bklog: always enable trace id if it exists
Browse files Browse the repository at this point in the history
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 <jonathan.sternberg@docker.com>
  • Loading branch information
jsternberg committed Sep 9, 2024
1 parent a1993e8 commit 366c355
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions util/bklog/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ var (
L = logrus.NewEntry(logrus.StandardLogger())
)

var (
logWithTraceID = false
)

func EnableLogWithTraceID(b bool) {
logWithTraceID = b
}

type (
loggerKey struct{}
)
Expand All @@ -51,13 +43,11 @@ func GetLogger(ctx context.Context) (l *logrus.Entry) {
l = L
}

if logWithTraceID {
if spanContext := trace.SpanFromContext(ctx).SpanContext(); spanContext.IsValid() {
return l.WithFields(logrus.Fields{
"traceID": spanContext.TraceID(),
"spanID": spanContext.SpanID(),
})
}
if spanContext := trace.SpanFromContext(ctx).SpanContext(); spanContext.IsValid() {
return l.WithFields(logrus.Fields{
"traceID": spanContext.TraceID(),
"spanID": spanContext.SpanID(),
})
}

return l
Expand Down

0 comments on commit 366c355

Please sign in to comment.