Skip to content

AddEventAsync fire and forget? #30

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

Closed
Sbopf opened this issue Apr 19, 2016 · 1 comment
Closed

AddEventAsync fire and forget? #30

Sbopf opened this issue Apr 19, 2016 · 1 comment

Comments

@Sbopf
Copy link

Sbopf commented Apr 19, 2016

Hi Keen Team,

I use the keen .NET SDK and have just noticed a few errors popped up the other day in my .NET WEB API application. The error points back to the keenClient.AddEvent() function not completing, timing out or failing to connect.

I don’t mind if these events don’t make it to keen, I would prefer the API transaction to succeed and not get the stats, rather than have the process fall over because the API couldn't contact Keen. I just want to implement a "fire and forget" pattern.

So my question is:
Does the asynchronous version of AddEvent (I.e. KeenClient.AddEventAsync()) still cause exceptions if it cannot connect? Or should I just wrap the keenClient.AddEvent() call in a try/catch block and ignore the exception?

@baumatron
Copy link
Contributor

Hey @Sbopf. I realize this is a really old issue, but wanted to address this.

If you aren't using an EventCache, AddEventAsync will immediately send your events using an HttpClient, and it will propagate any exceptions thrown back to your client, which will need to handle those exceptions.

I'd suggest the correct way to handle this situation is to wrap AddEventAsync with a try block and handle the specific exception you're trying to squelch. As you've seen, an unhandled exception is going to take down your app.

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

No branches or pull requests

2 participants