tracer: write log fields only if span exists and recording
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -29,10 +29,10 @@ type ContextAttrFunc func(ctx context.Context) []interface{}
|
|||||||
func init() {
|
func init() {
|
||||||
logger.DefaultContextAttrFuncs = append(logger.DefaultContextAttrFuncs,
|
logger.DefaultContextAttrFuncs = append(logger.DefaultContextAttrFuncs,
|
||||||
func(ctx context.Context) []interface{} {
|
func(ctx context.Context) []interface{} {
|
||||||
if span, ok := SpanFromContext(ctx); ok {
|
if sp, ok := SpanFromContext(ctx); ok && sp != nil && sp.IsRecording() {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
TraceIDKey, span.TraceID(),
|
TraceIDKey, sp.TraceID(),
|
||||||
SpanIDKey, span.SpanID(),
|
SpanIDKey, sp.SpanID(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user