From 3b39763e2aac340b986fa82b6a5bf33d64fb4202 Mon Sep 17 00:00:00 2001 From: kanade Date: Wed, 24 Aug 2022 12:42:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jaeger.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 }