-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: #220 AWS Lambda Handler #244
Conversation
}, | ||
"dependencies": { | ||
"@types/aws-lambda": "^8.10.138", | ||
"raygun": "file:../" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Change this file reference to ^1.1.0
when 1.1.0
is released.
aws-lambda/tsconfig.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from root tsconfig.json
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will typescript automatically search up the tree for config? Do we want this to be a second root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I will see if it is the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I resolved this using "extends": "../tsconfig.json",
plus a couple of changes
@@ -25,6 +25,7 @@ export default tseslint.config( | |||
"process": false, | |||
"require": false, | |||
"setTimeout": false, | |||
"exports": false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore error in exports.handler
from the aws-lambda-sample
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To better read this file and see the screenshots, tap on ". . ." and select "View file"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some really small nits or questions from my testing, but nothing that should stop you shipping 🚢
|
||
![Screenshot from 2024-06-06 10-33-11](https://github.com/MindscapeHQ/raygun4node/assets/2494376/762e07b9-e456-4dc2-b9b9-65228ef7f09c) | ||
|
||
You should see execution results similar to these: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks correct to me. The awsHandler
rethrows the error and we can seee the "successfully sent message".
I don't see "from callback!" in there
I forgot to update the pasted logs when I changed the example code, I will update that.
But looks like the example run as expected.
aws-lambda/tsconfig.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will typescript automatically search up the tree for config? Do we want this to be a second root?
We already have an internal SDK we use to construct our Lambda Handlers, using abstract classes and various other helper classes. Something like below: class Handler exports AbstractHandler {
main = async () => {
// code here in a try/catch
}
}
const handler = new Handler({
// maybe some options set
})
export const main = handler.main.bind(handler); How would this awsHandler work with our setup? also, whats the ETA on getting this released, as I'm struggling to get WinstonJS and Raygun playing nicely together, so this would be a god send. |
@paul-uz since the // client is the Raygun Client instance
exports.handler = awsHandler({ client }, handler); The advantage of using our ETA still hard to say, we are considering moving the |
@miquelbeltran looking at your example code exports.handler = awsHandler({ client }, async function (event, context) {
// Your AWS Lambda function code
}); It looks to me that the 2nd param is equivalent to my Also, in your example, you use |
That would be the idea, yes. The method accepts any
Yes, just like the |
Hmm, ideally, I'd like to be able to pass our custom Handler class (which contains the I'm wondering if I could do something like this? const client = new raygun.Client().init({ apiKey: process.env.RAYGUN });
class Handler extends AbstractHandler {
main = async (event) {
console.log(event)
...
}
}
const handler = new Handler();
export const main = awsHandler({ client }, handler.main(event));` |
I believe it will be like: export const main = awsHandler({ client }, handler.main);` I think you should be able to try it already. You can clone this repo/branch and install the package as reference. Let me know how it goes! |
This PR got moved to the repo https://github.com/MindscapeHQ/raygun4node-aws-lambda TODO List before version 0.0.1: MindscapeHQ/raygun4node-aws-lambda#1 |
feat: AWS Lambda Handler
Description 📝
Usage is as follows:
Any errors occurring in your AWS Lambda function will be automatically captured by Raygun.
Also, any breadcrumbs will be automatically scoped to the function session.
Type of change
Updates
@raygun.io/aws-lambda
inaws-lambda
folder. Package name follows the organization scope format: https://docs.npmjs.com/about-organization-scopes-and-packages like we do with the@raygun.io/webpack-plugin
.raygun.aws.ts
with new AWS Handler code.README.md
aws-lambda/test/raygun_aws_test.js
examples/aws-lambda-sample
including instructions andprepare.sh
script..github/workflows/aws-lambda.yml
.TODO:
raygun
package with required breadcrumbs function change.package.json
to point to newraygun
release..github/workflows/aws-lambda.yml
Test plan 🧪
Author to check 👓
Reviewer to check ✔️