npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@raygun.io/aws-lambda

v0.0.3

Published

Raygun Crash Reporting for AWS Lambda functions

Downloads

1,108

Readme

Raygun AWS Lambda + Node

GitHub CI

Raygun.com package for AWS Lambda + Node, written in TypeScript.

This package improves the experience when using Raygun with AWS Lambda using JavaScript.

Provides two main advantages compared to using Raygun directly:

  1. Captures any uncaught error in the AWS Lambda function and reports it to Raygun automatically.
  2. Scopes Breadcrumbs to the current function session.

Getting Started

Install the module with: npm install @raygun.io/aws-lambda

Set up the Raygun client as described in the Raygun package.

Import the awsHandler method:

const { awsHandler } = require("@raygun/aws-lambda");

Adding Raygun to a AWS Lambda function

To add Raygun to an existing AWS Lambda function, wrap the existing handler implementation with the awsHandler function.

Before:

exports.handler = async function (event, context) {
    // your code
}

After:

// 1. Configure your Raygun client outside the AWS Lambda function
const client = new Raygun.client().init( ... );

// 2. Wrap the existing function with awsHandler
// 3. Pass the client as the first parameter
exports.handler = awsHandler({ client }, async function (event, context) {
    // your code
});

Using AWS Lambda functions with callbacks

Raygun AWS Lambda handler also supports functions with three parameters and callbacks.

// Wrap the existing function with callback
exports.handler = awsHandler({ client }, function (event, context, callback) {
    // your code
});

Sending errors to Raygun from an AWS Lambda function

Any errors thrown in code will be automatically captured by the awsHandler.

exports.handler = awsHandler({ client }, async function (event, context) {
    // Captured by awsHandler and reported to Raygun
    throw "error";
});

Errors are also automatically reported when using the callback version.

exports.handler = awsHandler({ client }, function (event, context, callback) {
    // Captured by awsHandler and reported to Raygun
    callback("error", null);
});

As well, you can keep using the send() method.

exports.handler = awsHandler({ client }, async function (event, context) {
    await client.send("error");
});

Important: The awsHandler will rethrow the error back to AWS once it has been captured.

Adding breadcrumbs to Raygun error reports

Breadcumbs are included automatically to all error reports sent from the awsHandler or when using the send() method.

Call to client.addBreadcrumb() to add breadcrumbs.

exports.handler = awsHandler({ client }, async function (event, context) {
    // Add a breadcrumb
    client.addBreadcrumb("breadcrumb");
    
    // Captured error includes the above breadcrumb
    throw "error";
});

AWS Lambda function context in Custom Data

The awsHandler also adds automatically the function call context in the "Custom Data" payload of the error report.

This payload can be found in the "Custom" tab in the Raygun Crash Reporting error report page.

context: {
  callbackWaitsForEmptyEventLoop: true,
  functionVersion: "$LATEST",
  functionName: "xyz",
  memoryLimitInMB: "128",
  logGroupName: "/aws/lambda/xyz",
  logStreamName: "2024/05/31/[$LATEST]xyz",
  invokedFunctionArn: "arn:aws:lambda:xyz",
  awsRequestId: "xyz"
}

Release History

View the changelog here

License

Copyright (c) 2024 Raygun Limited

Licensed under the MIT license.