Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions metrics/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func (r *reporter) run() {
intervalTicker := time.NewTicker(r.interval)
pingTicker := time.NewTicker(time.Second * 5)

defer intervalTicker.Stop()
defer pingTicker.Stop()

Comment on lines +104 to +106
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, you are not wrong. But on the other hand, this method run loops forever -- there is no path in which it exits. So there is no path in which these deferred statements are executed.

One could argue that "if we ever add a return, then this will be a resource leak, and this change is thus good to have".

I don't know, I'll let someone else chime in and see what they think. cc @fjl

(same goes for the other change)

for {
select {
case <-intervalTicker.C:
Expand Down
3 changes: 3 additions & 0 deletions metrics/influxdb/influxdbv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func (r *v2Reporter) run() {
intervalTicker := time.NewTicker(r.interval)
pingTicker := time.NewTicker(time.Second * 5)

defer intervalTicker.Stop()
defer pingTicker.Stop()

for {
select {
case <-intervalTicker.C:
Expand Down