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

Commit

Permalink
Merge pull request #335 from docker/fix-metrics-goroutine
Browse files Browse the repository at this point in the history
Make sure the metrics goroutine is scheduled
  • Loading branch information
rumpl authored Jul 3, 2020
2 parents 1b9dd7a + 159b9d0 commit c4c0c24
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 @@ -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()
Expand All @@ -71,6 +76,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 c4c0c24

Please sign in to comment.