alexcesaro/statsd

On `New()` would like to have a client even if the preflight check fails

abourget opened this issue · 2 comments

Right now, a call to New() with no statsd server on the local machine will have all my code fail, as I'd get no *Client anywhere.

Would it be possible to simply return a Client that is ready, but with an additional error so the caller can decide if he wants to go forth with a potentially unresponsive statsd backend.

With the current state of affairs, my process is absolutely dependent on the statsd server being present. Very annoying for tests also, as I want to have a global var stats = *statsd.Client and use it throughout my code.

You can do something like:

if err != nil {
    stats = statsd.New(statsd.Mute(true))
}

Is it what you need? New could also return a muted client when there is an error. But I am currently on holidays and won't be able to add this feature before March. So feel free to send a PR.

Thanks. New() now returns a muted client if there is an error.