Skip to content

Commit

Permalink
Fix getting-started.md Run function, it assigns this new context to a…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
thinkgos committed Jan 21, 2022
1 parent 9407bf3 commit 7775675
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions website_docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down

0 comments on commit 7775675

Please sign in to comment.