Skip to content

Instantly share code, notes, and snippets.

@blanchonvincent
Created November 21, 2019 17:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blanchonvincent/18fc9dd743066d14bb29bdae2131c6c4 to your computer and use it in GitHub Desktop.
Save blanchonvincent/18fc9dd743066d14bb29bdae2131c6c4 to your computer and use it in GitHub Desktop.
Medium - Tracing
func main() {
ctx, task := trace.NewTask(context.Background(), "main start")
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
r := trace.StartRegion(ctx, "reading file")
defer r.End()
ioutil.ReadFile(`n1.txt`)
}()
go func() {
defer wg.Done()
r := trace.StartRegion(ctx, "writing file")
defer r.End()
ioutil.WriteFile(`n2.txt`, []byte(`42`), 0644)
}()
wg.Wait()
defer task.End()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment