From 443f78081f24624a1bba7e7a3fb45a97e39e1869 Mon Sep 17 00:00:00 2001 From: thinkgo Date: Sat, 22 Jan 2022 06:35:18 +0800 Subject: [PATCH] update example fib --- example/fib/app.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/example/fib/app.go b/example/fib/app.go index 5085a852dba..907779e613a 100644 --- a/example/fib/app.go +++ b/example/fib/app.go @@ -44,16 +44,16 @@ func NewApp(r io.Reader, l *log.Logger) *App { // Run starts polling users for Fibonacci number requests and writes results. func (a *App) Run(ctx context.Context) error { for { - var span trace.Span - ctx, span = otel.Tracer(name).Start(ctx, "Run") + // Each execution of the run loop, we should get a new "root" span and context. + newCtx, span := otel.Tracer(name).Start(ctx, "Run") - n, err := a.Poll(ctx) + n, err := a.Poll(newCtx) if err != nil { span.End() return err } - a.Write(ctx, n) + a.Write(newCtx, n) span.End() } }