From 7775675392f4e55110618e2c64fc1633e41ac3c4 Mon Sep 17 00:00:00 2001 From: thinkgo Date: Fri, 21 Jan 2022 11:55:49 +0800 Subject: [PATCH] Fix getting-started.md Run function, it assigns this new context to a variable shared between connections in to accept loop. Thus creating a growing chain of contexts. so every calculate fibonacci request, all spans in a trace. --- website_docs/getting-started.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/website_docs/getting-started.md b/website_docs/getting-started.md index 35886692be4..ce89d61f2a9 100644 --- a/website_docs/getting-started.md +++ b/website_docs/getting-started.md @@ -184,16 +184,15 @@ Start by instrumenting the `Run` method. // 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") + 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() } }