stats icon indicating copy to clipboard operation
stats copied to clipboard

datadog/client.NewClientWith swallows errors

Open shawnHartsell opened this issue 7 years ago • 2 comments

When constructing a new DataDog client with this method, I noticed that if the call to dial fails the error is only logged. Returning the error would let callers take specific actions during their application's initialization.

I realize this proposal is a breaking change; if you all think this is a good idea I would be willing to create the patch!

shawnHartsell avatar Dec 14 '18 17:12 shawnHartsell

For context, this has never really been an issue because it's pretty easy to spot when metrics just don't work.

If this is a feature you need we can introduce a new function that constructs the client but also returns any error that it would observe (NewClientWithError?), I don't think we have to make it a breaking change.

What do you think?

achille-roussel avatar Dec 14 '18 18:12 achille-roussel

Makes sense, and yes, something like NewClientWithError would work.

Specifically, I'm instrumenting a business critical service and want to have the option to not spin it up if initialization fails (e.g. bad addr, an internal error making the sys calls, etc)

shawnHartsell avatar Dec 14 '18 18:12 shawnHartsell