From 159b9d0cfba8523cd2fabbf05faa0eb4c61e9980 Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Fri, 3 Jul 2020 12:17:14 +0200 Subject: [PATCH] Make sure the metrics goroutine is scheduled 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. --- metrics/metrics.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/metrics/metrics.go b/metrics/metrics.go index ba2bd1caa..205ca2aff 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -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() @@ -67,6 +72,7 @@ func Track(context string, args []string, flags *flag.FlagSet) { }) } }() + <-wasIn } func getCommand(args []string, flags *flag.FlagSet) string {