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

Don't mute/discard connection when "quick listener check" fails #6

Open
zstyblik opened this issue Jun 3, 2016 · 3 comments
Open

Comments

@zstyblik
Copy link

zstyblik commented Jun 3, 2016

Hello,

I'm wondering whether it would be possible to try to either connect(un-mute) or from time to time.

Currently, when:

Failed to init StatsD: write udp [::1]:51628->[::1]:8125: write: connection refusedSlept: 0

Then no attempt is made to connect again. I don't want to fail application just because connection cannot be established, although may be I should. Also, it seems to me a bit cumbersome to introduce some check-whether-StatsD-is-initialized logic.

Would it be possible to try to connect from time to time eg. on flush() or just from time to time and un-mute?

If I kill listener, then connection is re-established once listener comes back. However, if listener isn't there when StatsD client is initialized, we never try again.

Thanks,
Z.

@zstyblik
Copy link
Author

zstyblik commented Jun 4, 2016

The "problem" is in https://github.com/alexcesaro/statsd/blob/master/conn.go#L50. But after reading the code, the only thing I came up is to remove this code block. :| Because then it works as ... I need it to. :)

It seems gdiazlo@d12d68c did the same.

@zstyblik zstyblik changed the title Try to connect(un-mute) on flush() or from time to time Don't mute/discard connection when "quick listener check" fails Jun 4, 2016
zstyblik added a commit to zstyblik/statsd that referenced this issue Jun 8, 2016
Commit removes "quick listener check" which mutes connection and returns error
when listener isn't available at the time of inicialization.
It seems as this there is no need to scrap connection, because when remote
endpoint comes around later, metrics will be received by that endpoint just
fine.

Fixes alexcesaro#6
@wbbradley
Copy link

@zstyblik's fork seems good. @alexcesaro is there a great reason to keep that check in there? Would you be willing to accept a PR where that check is optional?

astromechza added a commit to astromechza/go-statsd that referenced this issue Dec 23, 2017
heedson added a commit to heedson/statsd that referenced this issue Apr 6, 2018
Please refer to https://github.com/gdiazlo/statsd as a solution to this issue in the original repo alexcesaro#6.

This will add the functionality needed while keeping the additional changes that are currently present in this fork.

It is useful to have this change as the metrics within a service *shouldn't* stop a service from operating. Currently, it works as is but as soon as `.Clone` is called on the client, it crashes due to a nil conn (caused by this check).
joeycumines added a commit to joeycumines/statsd that referenced this issue Dec 31, 2021
This implementation does not provide connection state management. Handling
connection failures and retrying as necessary should be implemented by the
caller, if desired.
joeycumines added a commit to joeycumines/statsd that referenced this issue Dec 31, 2021
(fix 2/2 for alexcesaro#6)

Adds an option to facilitate initialising an unmuted client for UDP conns
where the server is unreachable.
@joeycumines
Copy link

Very old issue, but I've been doing some work on my fork.

As I understand it, muting the client returned by New on error is intentional and desirable behavior, that makes the UDP and TCP/streaming implementations consistent. For the UDP case, it is beneficial to be able to fail fast (like TCP), if possible, to detect potential misconfigurations.

Ignoring the initial check is still a valid use case, though, so I've made two changes:

  1. Documented that New always returns a non-nil client, but it (and all clients cloned from it) will be muted, if it was returned with an error
  2. Added an option that allows the initial UDP conn checking to be disabled (does what y'all seem to want, without breaking the existing behavior)

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

No branches or pull requests

3 participants