diff --git a/log/value.go b/log/value.go index 94d339994..cddce3a8f 100644 --- a/log/value.go +++ b/log/value.go @@ -52,11 +52,21 @@ func Timestamp(layout string) Valuer { func TraceID() Valuer { return func(ctx context.Context) interface{} { span := trace.SpanContextFromContext(ctx) - var traceID string if span.HasTraceID() { - traceID = span.TraceID().String() + return span.TraceID().String() } - return traceID + return "" + } +} + +// SpanID returns a spanid valuer. +func SpanID() Valuer { + return func(ctx context.Context) interface{} { + span := trace.SpanContextFromContext(ctx) + if span.HasSpanID() { + return span.SpanID().String() + } + return "" } }