MindscapeHQ / raygun4node-aws-lambda

MIT License
2 stars 0 forks source link

Initial impressions and suggestions #20

Open paul-uz opened 2 weeks ago

paul-uz commented 2 weeks ago

So I have found a few spare minutes to take a look at the new package and see how it works in situ.

I think I blanked out the part where it said "uncaught exceptions", as when I tried my own test code, with a try/catch in the invoked method, I got no errors being reported in Raygun. then I reread everything thoroughly, and spotted those two important words.

I removed the try/catch and threw some errors, and eh voila, errors reported in Raygun. Brilliant! Except I'm always going to use a try/catch, as I need the Lambda function to return a valid response for API Gateway. I can never have uncaught exceptions.

So I need to just use client.send(), making this library a bit... pointless, currently.

I wonder, is it possible to have the new awsHandler report any thrown errors, whether they are caught or not? This would save me having to remember to use client.send() in my catch block. It would also mean all errors get the context attached to them automatically.

Hope this feedbacj is of some use to you.

miquelbeltran commented 2 weeks ago

So I need to just use client.send(), making this library a bit... pointless, currently.

There is another part, which is scoping breadcrumbs. e.g. calling to client.addBreadcrumb(something).

When you add breadcrumbs, the breadcrumbs will be automatically scoped and grouped into the function call, and attached to the error report.

At the moment, we just pass the function name in a breadcrumb, but we could consider adding all the provided context to it automatically.

So every time you call to client.send() the breadcrumbs also include this extra information, i.e. the function context.

I wonder, is it possible to have the new awsHandler report any thrown errors, whether they are caught or not? This would save me having to remember to use client.send() in my catch block.

I don't think that is possible, without either you calling client.send() in the catch or rethrowing the exception.

It would also mean all errors get the context attached to them automatically.

This is something we can accomplish with breadcrumbs indeed.

paul-uz commented 2 weeks ago

@miquelbeltran thank you for the response.

Tell me more about breadcrumbs and how I can leverage them in my code.

miquelbeltran commented 2 weeks ago

No problem! Breadcrumbs have been part of Raygun crash reporting for a while, but the node client missed that functionality. We added it in 1.0.0: https://github.com/MindscapeHQ/raygun4node?tab=readme-ov-file#breadcrumbs

There is more info in general here: https://raygun.com/documentation/product-guides/crash-reporting/breadcrumbs/

Hope that helps!

paul-uz commented 2 weeks ago

@miquelbeltran there is seems to be a lack of breadcrumb info in the following docs; https://raygun.com/documentation/language-guides/nodejs/crash-reporting/installation/

miquelbeltran commented 2 weeks ago

Thanks for bringing this up, that documentation is very much outdated