Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions packages/aws-serverless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@
</a>
</p>

# Official Sentry SDK for Serverless environments
# Official Sentry SDK for AWS Lambda

## Links

- [Official SDK Docs](https://docs.sentry.io/)
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/aws-lambda)

## General

This package is a wrapper around `@sentry/node`, with added functionality related to various Serverless solutions. All
This package is a wrapper around `@sentry/node`, with added functionality related to AWS Lambda. All
methods available in `@sentry/node` can be imported from `@sentry/aws-serverless`.

Currently supported environment:

### AWS Lambda

To use this SDK, call `Sentry.init(options)` at the very beginning of your JavaScript file.

```javascript
Expand All @@ -30,14 +26,14 @@ Sentry.init({
});

// async (recommended)
exports.handler = Sentry.wrapHandler(async (event, context) => {
export const handler = async (event, context) => {
throw new Error('oh, hello there!');
});
};

// sync
exports.handler = Sentry.wrapHandler((event, context, callback) => {
export const handler = (event, context, callback) => {
throw new Error('oh, hello there!');
});
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Sentry Integration Missing in Examples

The manual Sentry initialization examples in the README.md removed Sentry.wrapHandler(). This wrapper is crucial for Sentry to automatically capture exceptions, manage the Lambda execution context, and provide performance tracing. Without it, these examples won't properly integrate Sentry.

Fix in Cursor Fix in Web

```

If you also want to trace performance of all the incoming requests and also outgoing AWS service requests, just set the
Expand All @@ -46,21 +42,21 @@ If you also want to trace performance of all the incoming requests and also outg
```javascript
import * as Sentry from '@sentry/aws-serverless';

Sentry.AWSLambda.init({
Sentry.init({
dsn: '__DSN__',
tracesSampleRate: 1.0,
});
```

#### Integrate Sentry using internal extension
#### Integrate Sentry using the Sentry Lambda layer

Another and much simpler way to integrate Sentry to your AWS Lambda function is to add an official layer.
Another much simpler way to integrate Sentry to your AWS Lambda function is to add the official layer.

1. Choose Layers -> Add Layer.
2. Specify an ARN: `arn:aws:lambda:us-west-1:TODO:layer:TODO:VERSION`.
2. Specify an ARN: `arn:aws:lambda:us-west-1:943013980633:layer:SentryNodeServerlessSDKv10:19`. Get the latest ARN from the [docs](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/install/layer).
3. Go to Environment variables and add:
- `NODE_OPTIONS`: `-r @sentry/aws-serverless/build/npm/cjs/awslambda-auto`.
- `NODE_OPTIONS`: `--import @sentry/aws-serverless/awslambda-auto`.
- `SENTRY_DSN`: `your dsn`.
- `SENTRY_TRACES_SAMPLE_RATE`: a number between 0 and 1 representing the chance a transaction is sent to Sentry. For
more information, see
[docs](https://docs.sentry.io/platforms/node/guides/aws-lambda/configuration/options/#tracesSampleRate).
[docs](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#tracesSampleRate).
Loading