Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Make sure the metrics goroutine is scheduled
Browse files Browse the repository at this point in the history
Wait for the goroutine to be scheduled before exiting. We don't wait for
the metrics event to be sent, we only make sure the goroutine is called.
  • Loading branch information
rumpl committed Jul 3, 2020
1 parent ae76e0c commit 159b9d0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ var managementCommands = []string{

// Track sends the tracking analytics to Docker Desktop
func Track(context string, args []string, flags *flag.FlagSet) {
wasIn := make(chan bool)

// Fire and forget, we don't want to slow down the user waiting for DD
// metrics endpoint to respond. We could lose some events but that's ok.
go func() {
defer func() {
_ = recover()
}()

wasIn <- true

command := getCommand(args, flags)
if command != "" {
c := NewClient()
Expand All @@ -67,6 +72,7 @@ func Track(context string, args []string, flags *flag.FlagSet) {
})
}
}()
<-wasIn
}

func getCommand(args []string, flags *flag.FlagSet) string {
Expand Down

0 comments on commit 159b9d0

Please sign in to comment.