pull/1001/head
longXboy 4 years ago committed by longxboy
parent c2f077e7f1
commit fd84ed4b52
  1. 6
      log/value.go

@ -51,8 +51,7 @@ func Timestamp(layout string) Valuer {
// TraceID returns a traceid valuer. // TraceID returns a traceid valuer.
func TraceID() Valuer { func TraceID() Valuer {
return func(ctx context.Context) interface{} { return func(ctx context.Context) interface{} {
span := trace.SpanContextFromContext(ctx) if span := trace.SpanContextFromContext(ctx); span.HasTraceID() {
if span.HasTraceID() {
return span.TraceID().String() return span.TraceID().String()
} }
return "" return ""
@ -62,8 +61,7 @@ func TraceID() Valuer {
// SpanID returns a spanid valuer. // SpanID returns a spanid valuer.
func SpanID() Valuer { func SpanID() Valuer {
return func(ctx context.Context) interface{} { return func(ctx context.Context) interface{} {
span := trace.SpanContextFromContext(ctx) if span := trace.SpanContextFromContext(ctx); span.HasSpanID() {
if span.HasSpanID() {
return span.SpanID().String() return span.SpanID().String()
} }
return "" return ""

Loading…
Cancel
Save