Skip to content

Instantly share code, notes, and snippets.

@piclez
Created June 12, 2024 19:52
Show Gist options
  • Save piclez/fa2518a82bd1f26a69991eb610a5fd3f to your computer and use it in GitHub Desktop.
Save piclez/fa2518a82bd1f26a69991eb610a5fd3f to your computer and use it in GitHub Desktop.
Lambda Sentry Error
const Sentry = require("@sentry/node");
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
Sentry.init({
dsn: "",
integrations: [
nodeProfilingIntegration(),
],
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
});
// exports.handler = async (event) => {
// // console.log('hello world');
// const response = {
// statusCode: 200,
// body: JSON.stringify('Hello from Lambda!')
// };
// return response;
// };
exports.handler = Sentry.wrapHandler(async (event, context) => {
let error = event?.error
if (error) {
Sentry.captureException(JSON.stringify(error));
}
return {
error: error
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment