Skip to content

Commit

Permalink
do not block to send usage stats (influxdata#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Cook committed Jun 1, 2016
1 parent 880d1cf commit 7334efe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ kapacitor replay-live query -task cpu_alert -query 'SELECT usage_idle FROM teleg
- [#555](https://github.com/influxdata/kapacitor/issues/555): Fixes bug where "time" functions didn't work in lambda expressions.
- [#570](https://github.com/influxdata/kapacitor/issues/570): Removes panic in SMTP service on failed close connection.
- [#587](https://github.com/influxdata/kapacitor/issues/587): Allow number literals without leading zeros.
- [#584](https://github.com/influxdata/kapacitor/issues/584): Do not block during startup to send usage stats.

## v0.13.1 [2016-05-13]

Expand Down
18 changes: 12 additions & 6 deletions services/reporting/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,22 @@ func (s *Service) Open() error {
s.tags["os"] = runtime.GOOS

// Send report on startup
err := s.sendUsageReport()
if err != nil {
s.logger.Println("E! error while sending usage report on startup:", err)
}
s.wg.Add(1)
go func() {
defer s.wg.Done()
err := s.sendUsageReport()
if err != nil {
s.logger.Println("E! error while sending usage report on startup:", err)
}
}()

// Send periodic anonymous usage stats
s.usageTicker = time.NewTicker(reportingInterval)
s.wg.Add(1)
go s.usage()
go func() {
defer s.wg.Done()
s.usage()
}()
return nil
}

Expand All @@ -87,7 +94,6 @@ func (s *Service) Close() error {
}

func (s *Service) usage() {
defer s.wg.Done()
for {
select {
case <-s.closing:
Expand Down

0 comments on commit 7334efe

Please sign in to comment.