1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-07-03 00:57:56 +02:00

fix tracing: call tracer.End() in closure. (#928)

This commit is contained in:
dowenliu-xyz
2021-05-18 20:37:49 +08:00
committed by GitHub
parent ba5b8d1ee3
commit aab0d5aa43

View File

@ -58,7 +58,7 @@ func Server(opts ...Option) middleware.Middleware {
} }
} }
ctx, span := tracer.Start(ctx, component, operation, carrier) ctx, span := tracer.Start(ctx, component, operation, carrier)
defer tracer.End(ctx, span, err) defer func() { tracer.End(ctx, span, err) }()
reply, err = handler(ctx, req) reply, err = handler(ctx, req)
@ -95,7 +95,7 @@ func Client(opts ...Option) middleware.Middleware {
ctx = metadata.NewOutgoingContext(ctx, md) ctx = metadata.NewOutgoingContext(ctx, md)
} }
ctx, span := tracer.Start(ctx, component, operation, carrier) ctx, span := tracer.Start(ctx, component, operation, carrier)
defer tracer.End(ctx, span, err) defer func() { tracer.End(ctx, span, err) }()
reply, err = handler(ctx, req) reply, err = handler(ctx, req)