1
0
Эх сурвалжийг харах

Merge pull request #335 from docker/fix-metrics-goroutine

Make sure the metrics goroutine is scheduled
Djordje Lukic 5 жил өмнө
parent
commit
c4c0c24dca
1 өөрчлөгдсөн 6 нэмэгдсэн , 0 устгасан
  1. 6 0
      metrics/metrics.go

+ 6 - 0
metrics/metrics.go

@@ -56,12 +56,17 @@ const (
 
 // 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()
@@ -71,6 +76,7 @@ func Track(context string, args []string, flags *flag.FlagSet) {
 			})
 		}
 	}()
+	<-wasIn
 }
 
 func getCommand(args []string, flags *flag.FlagSet) string {