|
|
|
@ -6,6 +6,8 @@ import ( |
|
|
|
|
"strconv" |
|
|
|
|
"strings" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"go.opentelemetry.io/otel/trace" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
@ -46,6 +48,18 @@ func Timestamp(layout string) Valuer { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TraceID returns a traceid 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 traceID |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func bindValues(ctx context.Context, keyvals []interface{}) { |
|
|
|
|
for i := 1; i < len(keyvals); i += 2 { |
|
|
|
|
if v, ok := keyvals[i].(Valuer); ok { |
|
|
|
|