1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-07 23:02:12 +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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)