Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sentry/serverless

Package Overview
Dependencies
Maintainers
11
Versions
306
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/serverless

Official Sentry SDK for various serverless solutions

  • 7.114.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
66K
decreased by-76.38%
Maintainers
11
Weekly downloads
 
Created

What is @sentry/serverless?

@sentry/serverless is an npm package that provides error tracking and performance monitoring for serverless applications. It helps developers capture and report errors, exceptions, and performance issues in serverless environments such as AWS Lambda, Google Cloud Functions, and Azure Functions.

What are @sentry/serverless's main functionalities?

Error Tracking

This feature allows you to capture and report errors in your serverless functions. The code sample demonstrates how to initialize Sentry for AWS Lambda and wrap a handler to automatically capture any errors that occur.

const Sentry = require('@sentry/serverless');

Sentry.AWSLambda.init({
  dsn: 'your-dsn-url',
});

exports.handler = Sentry.AWSLambda.wrapHandler(async (event, context) => {
  // Your handler code
  throw new Error('Something went wrong!');
});

Performance Monitoring

This feature allows you to monitor the performance of your serverless functions. The code sample demonstrates how to initialize Sentry with performance monitoring enabled and how to create and finish a transaction to measure the duration of a task.

const Sentry = require('@sentry/serverless');

Sentry.AWSLambda.init({
  dsn: 'your-dsn-url',
  tracesSampleRate: 1.0,
});

exports.handler = Sentry.AWSLambda.wrapHandler(async (event, context) => {
  // Your handler code
  const transaction = Sentry.startTransaction({
    op: 'task',
    name: 'My Task',
  });

  // Simulate some work
  await new Promise(resolve => setTimeout(resolve, 1000));

  transaction.finish();
});

Custom Context

This feature allows you to add custom context to your error reports. The code sample demonstrates how to set tags, user information, and extra data in the Sentry scope before throwing an error.

const Sentry = require('@sentry/serverless');

Sentry.AWSLambda.init({
  dsn: 'your-dsn-url',
});

exports.handler = Sentry.AWSLambda.wrapHandler(async (event, context) => {
  Sentry.configureScope(scope => {
    scope.setTag('my-tag', 'my-value');
    scope.setUser({ id: 'user-id' });
    scope.setExtra('extra-info', 'some extra information');
  });

  // Your handler code
  throw new Error('Something went wrong!');
});

Other packages similar to @sentry/serverless

FAQs

Package last updated on 08 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc