Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to stop SendLoop when used with time.Ticker #836

Closed
jlordiales opened this issue Feb 17, 2019 · 4 comments
Closed

No way to stop SendLoop when used with time.Ticker #836

jlordiales opened this issue Feb 17, 2019 · 4 comments

Comments

@jlordiales
Copy link
Contributor

The SendLoop func on many of the metric reporters takes in a <-chan time.Time and blocks until that channel is closed.
As the docs say, this is most typically used by creating a time.Ticker and passing its C channel.

This works great except for the fact that the C channel in the ticker can never be closed. You can call Stop on the ticker but this doesn't close the channel (golang/go#2650).
This effectively means that there's no straightforward way to return from the SendLoop func when used together with a time.Ticker.

I guess it would be nice if the func could take a ctx as first parameter and return when ctx.Done() is closed.

@peterbourgon
Copy link
Member

As far as I know there is no practical reason to shut down any of these reporters, neither in actual programs nor in tests.

@peterbourgon
Copy link
Member

Said another way: changing the API is a breaking change, and I don't see a good reason to do it. But I'm open to arguments otherwise.

@jlordiales
Copy link
Contributor Author

jlordiales commented Feb 19, 2019 via email

@peterbourgon
Copy link
Member

That's a great point. I'll happily take a PR. I agree that ctx is the right approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants