Skip to content

Commit 775c52d

Browse files
AJAJ
authored andcommitted
automated EoF fix
1 parent a2c4cab commit 775c52d

File tree

3 files changed

+69
-43
lines changed

3 files changed

+69
-43
lines changed

src/platforms/node/guides/aws-lambda/index.mdx

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ redirect_from:
44
- /platforms/node/aws_lambda/
55
---
66

7+
_(New in version 5.22.x)_
8+
79
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/).
810

911
Add `@sentry/node` as a dependency:
@@ -16,37 +18,54 @@ $ npm install --save @sentry/node
1618
$ yarn add @sentry/node
1719
```
1820

19-
To set up Sentry error logging for a Lambda Function, build a wrapper:
21+
You can use the AWS Lambda integration for the Node SDK like this:
2022

2123
```javascript
22-
"use strict";
23-
24+
*Update Sample Code*
25+
const http = require("http");
2426
const Sentry = require("@sentry/node");
27+
const { AWSLambdaIntegration } = require("@sentry/integrations");
2528

29+
// Configure the Sentry SDK.
2630
Sentry.init({
27-
dsn: "___PUBLIC_DSN___",
31+
dsn:
32+
"___PUBLIC_DSN___",
33+
integrations: [AWSLambdaIntegration],
2834
});
2935

30-
function sentryHandler(lambdaHandler) {
31-
return async event => {
32-
try {
33-
return await lambdaHandler(event);
34-
} catch (e) {
35-
Sentry.captureException(e);
36-
await Sentry.flush(2000);
37-
return e;
38-
}
39-
};
40-
}
41-
42-
module.exports.hello = sentryHandler(async event => {
43-
notExistFunction();
44-
return event;
36+
exports.handler = (event, context) => {
37+
AWSLambdaIntegration.providedContext(context);
38+
throw new Error("this is a dummy error")
39+
};
40+
```
41+
42+
<!-- TODO-ADD-VERIFICATION-EXAMPLE -->
43+
44+
## Enable Timeout Warning
45+
46+
Timeout warning indicates high probability of the function timing out. Update the sentry initialization to set `timeoutWarning` to `true`
47+
48+
```javascript
49+
Sentry.init({
50+
dsn:
51+
"___PUBLIC_DSN___",
52+
integrations: [AWSLambdaIntegration(true)],
4553
});
4654
```
4755

48-
You can obtain the DSN using your Sentry account from your organization's _Settings > Projects > Client Keys (DSN)_ in the Sentry web UI.
56+
The timeout warning is sent only if the "timeout" in the Lambda Function configuration is set to a value greater than one second.
57+
58+
59+
## Behavior
60+
61+
With the AWS Lambda integration enabled, the Node SDK will:
4962

50-
Note: You need to call both `captureException` and `flush` for captured events to be successfully delivered to Sentry.
63+
- Automatically report all exceptions from your lambda functions
64+
- Issue reports automatically include:
5165

52-
Create the deployment package in `.zip` format, then upload it to AWS Lambda as a Lambda Function. Checkout Sentry's [aws sample apps](https://github.com/getsentry/examples/tree/master/aws-lambda/node) for detailed examples. Refer to the [JavaScript docs](/platforms/javascript/) for more configuration options.
66+
- A link to the cloudwatch logs
67+
- Function details
68+
- sys.argv for the function
69+
- AWS Request ID
70+
- Function execution time
71+
- Function version

src/platforms/python/guides/aws-lambda/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ If you are using another web framework inside of AWS Lambda, the framework might
6161
With the AWS Lambda integration enabled, the Python SDK will:
6262

6363
- Automatically report all exceptions from your lambda functions
64-
- Issues reports automatically include:
64+
- Issue reports automatically include:
6565

6666
- A link to the cloudwatch logs
6767
- Function details

src/wizard/node/awslambda.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ doc_link: https://docs.sentry.io/platforms/node/guides/aws-lambda/
44
support_level: production
55
type: framework
66
---
7+
78
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/).
89

910
Add `@sentry/node` as a dependency:
@@ -16,33 +17,39 @@ $ npm install --save @sentry/node
1617
$ yarn add @sentry/node
1718
```
1819

19-
To set up Sentry error logging for a Lambda Function, build a wrapper:
20+
You can use the AWS Lambda integration for the Node SDK like this:
2021

2122
```javascript
22-
"use strict";
23-
23+
*Update Sample Code*
24+
const http = require("http");
2425
const Sentry = require("@sentry/node");
26+
const { AWSLambdaIntegration } = require("@sentry/integrations");
2527

28+
// Configure the Sentry SDK.
2629
Sentry.init({
27-
dsn: "___PUBLIC_DSN___",
30+
dsn:
31+
"___PUBLIC_DSN___",
32+
integrations: [AWSLambdaIntegration],
2833
});
2934

30-
function sentryHandler(lambdaHandler) {
31-
return async event => {
32-
try {
33-
return await lambdaHandler(event);
34-
} catch (e) {
35-
Sentry.captureException(e);
36-
await Sentry.flush(2000);
37-
return e;
38-
}
39-
};
40-
}
41-
42-
module.exports.hello = sentryHandler(async event => {
43-
notExistFunction();
44-
return event;
35+
exports.handler = (event, context) => {
36+
AWSLambdaIntegration.providedContext(context);
37+
throw new Error("this is a dummy error")
38+
};
39+
```
40+
41+
<!-- TODO-ADD-VERIFICATION-EXAMPLE -->
42+
43+
## Enable Timeout Warning
44+
45+
Timeout warning indicates high probability of the function timing out. Update the sentry initialization to set `timeoutWarning` to `true`
46+
47+
```javascript
48+
Sentry.init({
49+
dsn:
50+
"___PUBLIC_DSN___",
51+
integrations: [AWSLambdaIntegration(true)],
4552
});
4653
```
4754

48-
Note: You need to call both `captureException` and `flush` for captured events to be successfully delivered to Sentry.
55+
The timeout warning is sent only if the "timeout" in the Lambda Function configuration is set to a value greater than one second.

0 commit comments

Comments
 (0)