Skip to content

Commit

Permalink
v8: change serverless package names
Browse files Browse the repository at this point in the history
  • Loading branch information
s1gr1d committed May 3, 2024
1 parent 17784a6 commit d353e5d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Replace `VERSION` with a specific version number (for example, 28). You can see

Set the following environment variables in AWS:

- Set `NODE_OPTIONS` to `-r @sentry/serverless/dist/awslambda-auto`
- Set `NODE_OPTIONS` to `-r @sentry/aws-serverless/dist/awslambda-auto`
- Set `SENTRY_DSN` to your Sentry's DSN
- Set `SENTRY_TRACES_SAMPLE_RATE` to your preferred [sampling rate](/platforms/python/configuration/sampling/#sampling-transaction-events) for transactions

Expand All @@ -31,7 +31,7 @@ Alternatively, you can also set the environment variables in the Dockerfile:
<SignInNote />

```docker {tabTitle: Dockerfile}
ENV NODE_OPTIONS="-r @sentry/serverless/dist/awslambda-auto"
ENV NODE_OPTIONS="-r @sentry/aws-serverless/dist/awslambda-auto"
ENV SENTRY_DSN="___PUBLIC_DSN___"
ENV SENTRY_TRACES_SAMPLE_RATE="1.0"
```
Expand Down
35 changes: 18 additions & 17 deletions docs/platforms/javascript/guides/aws-lambda/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ Before you begin, note:
- You need to have experience with AWS console and a basic understanding of Lambda.
- You'll need an AWS account and you have to create an [IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html).

_(New in version 5.26.0)_
<Note>
This guide is for Version 8.0.0 and up of `@sentry/aws-serverless`.
</Note>

Create a deployment package on your local machine and install the required dependencies in the deployment package. For more information, see [Building an AWS Lambda deployment package for Node.js](https://aws.amazon.com/premiumsupport/knowledge-center/lambda-deployment-package-nodejs/).

Add `@sentry/serverless` as a dependency:
Add `@sentry/aws-serverless` as a dependency:

```bash {tabTitle:npm}
npm install --save @sentry/serverless
npm install --save @sentry/aws-serverless
```

```bash {tabTitle:Yarn}
yarn add @sentry/serverless
yarn add @sentry/aws-serverless
```

We also support [installing Sentry as a Container Image](/platforms/javascript/guides/aws-lambda/container-image/) and [installing Sentry in Lambda Layer](/platforms/javascript/guides/aws-lambda/layer/).
Expand All @@ -39,33 +41,34 @@ You can use the AWS Lambda integration for the Node like this:
<SignInNote />

```javascript {tabTitle:async}
const Sentry = require("@sentry/serverless");
const Sentry = require("@sentry/aws-serverless");

Sentry.AWSLambda.init({
Sentry.init({
dsn: "___PUBLIC_DSN___",

// We recommend adjusting this value in production, or using tracesSampler
// for finer control
// Add Performance Monitoring by setting tracesSampleRate and adding integration
// Set tracesSampleRate to 1.0 to capture 100% of transactions
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});

exports.handler = Sentry.AWSLambda.wrapHandler(async (event, context) => {
exports.handler = Sentry.wrapHandler(async (event, context) => {
// Your handler code
});
```

```javascript {tabTitle:sync}
const Sentry = require("@sentry/serverless");
const Sentry = require("@sentry/aws-serverless");

Sentry.AWSLambda.init({
Sentry.init({
dsn: "___PUBLIC_DSN___",

// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
});

exports.handler = Sentry.AWSLambda.wrapHandler((event, context, callback) => {
exports.handler = Sentry.wrapHandler((event, context, callback) => {
// Your handler code
});
```
Expand All @@ -77,29 +80,27 @@ exports.handler = Sentry.AWSLambda.wrapHandler((event, context, callback) => {
Sentry reports timeout warning when the function is within 500ms of its execution time. You can turn off timeout warnings by setting `captureTimeoutWarning` to `false` in the handler options. To change timeout warning limit, assign a numeric value (in ms) to `timeoutWarningLimit`

```javascript {tabTitle:captureTimeoutWarning}
exports.handler = Sentry.AWSLambda.wrapHandler(yourHandler, {
exports.handler = Sentry.wrapHandler(yourHandler, {
captureTimeoutWarning: false,
});
```

```javascript {tabTitle:timeoutWarning}
exports.handler = Sentry.AWSLambda.wrapHandler(yourHandler, {
exports.handler = Sentry.wrapHandler(yourHandler, {
timeoutWarningLimit: 50,
});
```

## Capture Rejected Promises in `Promise.allSettled`

_(New in version 6.14.3)_

By default, Sentry captures errors raised by your handler.
However, your handler might return a `Promise.allSettled` result.
In this case, even if one of the messages has failed, Sentry won't capture any exception.

The `captureAllSettledReasons` (default: `false`) option captures all promise rejected results

```javascript {tabTitle:captureAllSettledReasons}
exports.handler = Sentry.AWSLambda.wrapHandler(
exports.handler = Sentry.wrapHandler(
() => {
return Promise.allSettled([
Promise.rejected(new Error("first")),
Expand Down
4 changes: 2 additions & 2 deletions docs/platforms/javascript/guides/aws-lambda/layer/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ title: AWS Lambda Layer (Node)
description: "Learn how to set up Sentry with a Layer"
---

You can also install Sentry using a [Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) instead of adding `@sentry/serverless` with `npm` or `yarn`. Import Sentry as usual:
You can also install Sentry using a [Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) instead of adding `@sentry/aws-serverless` with `npm` or `yarn`. Import Sentry as usual:

```javascript
const Sentry = require("@sentry/serverless");
const Sentry = require("@sentry/aws-serverless");
```

<Note>
Expand Down
30 changes: 19 additions & 11 deletions docs/platforms/javascript/guides/gcp-functions/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,61 @@ categories:
- serverless
---

Add `@sentry/serverless` as a dependency to `package.json`:
<Note>
This guide is for Version 8.0.0 and up of `@sentry/google-cloud-serverless`.
</Note>

Add `@sentry/google-cloud-serverless` as a dependency to `package.json`:

```bash
"@sentry/serverless": "^{{@inject packages.version('sentry.javascript.node') }}"
"@sentry/google-cloud-serverless": "^{{@inject packages.version('sentry.javascript.node') }}"
```

To set up Sentry for a Google Cloud Function:

<SignInNote />

```javascript {tabTitle:Http functions}
const Sentry = require("@sentry/serverless");
const Sentry = require("@sentry/google-cloud-serverless");

Sentry.GCPFunction.init({
Sentry.init({
dsn: "___PUBLIC_DSN___",

// Add Performance Monitoring by setting tracesSampleRate and adding integration
// Set tracesSampleRate to 1.0 to capture 100% of transactions
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});

exports.helloHttp = Sentry.GCPFunction.wrapHttpFunction((req, res) => {
exports.helloHttp = Sentry.wrapHttpFunction((req, res) => {
throw new Error("oh, hello there!");
});
```

```javascript {tabTitle:Background functions}
const Sentry = require("@sentry/serverless");
const Sentry = require("@sentry/google-cloud-serverless");

Sentry.GCPFunction.init({
Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0,
});

exports.helloEvents = Sentry.GCPFunction.wrapEventFunction(
exports.helloEvents = Sentry.wrapEventFunction(
(data, context, callback) => {
throw new Error("oh, hello there!");
}
);
```

```javascript {tabTitle:CloudEvent functions}
const Sentry = require("@sentry/serverless");
const Sentry = require("@sentry/google-cloud-serverless");

Sentry.GCPFunction.init({
Sentry.init({
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0,
});

exports.helloEvents = Sentry.GCPFunction.wrapCloudEventFunction(
exports.helloEvents = Sentry.wrapCloudEventFunction(
(context, callback) => {
throw new Error("oh, hello there!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ provider:
environment:
SENTRY_TRACES_SAMPLE_RATE: "1.0"
SENTRY_DSN: "<SENTRY_DSN>"
NODE_OPTIONS: "-r @sentry/serverless/dist/awslambda-auto"
NODE_OPTIONS: "-r @sentry/aws-serverless/dist/awslambda-auto"

custom:
layers:
Expand Down

0 comments on commit d353e5d

Please sign in to comment.