Created
November 21, 2019 17:50
-
-
Save blanchonvincent/18fc9dd743066d14bb29bdae2131c6c4 to your computer and use it in GitHub Desktop.
Medium - Tracing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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