diff --git a/jaeger.go b/jaeger.go index a9dd537..7db3fad 100644 --- a/jaeger.go +++ b/jaeger.go @@ -48,7 +48,11 @@ func BeforeHandel(ctx context.Context, baseName, serviceName, serviceMethod stri span.AddEvent(fmt.Sprintf("调用rpc服务:%s,%s,%s", baseName, serviceName, serviceMethod)) spanCtx := ctx.Value(CtxSpanCtxName).(context.Context) meta := ctx.Value(share.ReqMetaDataKey) - spanCtx = context.WithValue(spanCtx, share.ReqMetaDataKey, meta) + if meta == nil { + spanCtx = context.WithValue(spanCtx, share.ReqMetaDataKey, map[string]string{}) + } else { + spanCtx = context.WithValue(spanCtx, share.ReqMetaDataKey, meta) + } share2.Inject(spanCtx, otel.GetTextMapPropagator()) ctx = spanCtx }