You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/aws-lambda/install/layer.mdx
+8-71Lines changed: 8 additions & 71 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,24 +32,7 @@ Finally, set the region and copy the provided ARN value into the input.
32
32
33
33
## 2. Setup Options
34
34
35
-
Choose your setup method based on your Lambda function type:
36
-
37
-
<Alertlevel="info"title="ESM vs. CommonJS">
38
-
39
-
The setup instructions you should follow depend on how your function **runs** at runtime, not how it's written in your source code.
40
-
41
-
-**Use CommonJS instructions** if your function runs with CommonJS modules (uses `require()` and `module.exports` at runtime)
42
-
-**Use ESM instructions** if your function runs with ES modules (uses `import`/`export` at runtime)
43
-
44
-
**Important:** Even if you write your code with `import`/`export` syntax, your function might still run as CommonJS if you're using TypeScript or a build tool that compiles to CommonJS. Check your build output or Lambda runtime configuration to determine which applies to your function.
45
-
46
-
</Alert>
47
-
48
-
### Option A: Automatic Setup
49
-
50
-
**CommonJS functions** support fully automatic setup using environment variables - both SDK initialization and handler wrapping are handled automatically.
51
-
52
-
**ESM functions** support automatic SDK initialization via environment variables, but require manual handler wrapping.
35
+
### Option A: Automatic Setup (recommended)
53
36
54
37
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
55
38
@@ -59,15 +42,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
59
42
60
43
Set the following environment variables in your Lambda function configuration:
Instead of using environment variables, you can manually initialize the SDK and wrap your handler in code. This approach works for both CommonJS and ESM functions and allows for further customization of the SDK setup.
59
+
To further customize the SDK setup, you can also manually initialize the SDK in your lambda function. The benefit of this installation method is that you can fully customize your Sentry SDK setup in a `Sentry.init` call.
99
60
100
61
Note that you don't have to actually install an NPM package for this to work, as the package is already included in the Lambda Layer.
101
62
102
-
#### For CommonJS Lambda Functions
63
+
Create a new file, for example `instrument.js` to initialize the SDK:
It's important to add both, the `Sentry.init` call outside the handler function and the `Sentry.wrapHandler` wrapper around your function to automatically catch errors and performance data. Make sure that the `Sentry.init` call and the import statement are at the very top of your file before any other imports.
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/aws-lambda/install/npm.mdx
+10-75Lines changed: 10 additions & 75 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,17 +17,6 @@ Before you begin, make sure you have the following:
17
17
- You have a Lambda function deployed in AWS.
18
18
- You're able to deploy dependencies (i.e. `node_modules`) alongside your function code to AWS Lambda.
19
19
20
-
<Alertlevel="info"title="ESM vs. CommonJS">
21
-
22
-
The setup instructions you should follow depend on how your Lambda function **runs** at runtime, not how it's written in your source code.
23
-
24
-
-**Use CommonJS instructions** if your function runs with CommonJS modules (uses `require()` and `module.exports` at runtime)
25
-
-**Use ESM instructions** if your function runs with ES modules (uses `import`/`export` at runtime)
26
-
27
-
**Important:** Even if you write your code with `import`/`export` syntax, your function might still run as CommonJS if you're using TypeScript or a build tool that compiles to CommonJS. Check your build output or Lambda runtime configuration to determine which applies to your function.
28
-
29
-
</Alert>
30
-
31
20
## 2. Install
32
21
33
22
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/).
Choose your setup method based on your Lambda function type:
78
-
79
-
### Option A: Automatic Setup
80
-
81
-
**CommonJS functions** support fully automatic setup using environment variables - both SDK initialization and handler wrapping are handled automatically.
82
-
83
-
**ESM functions** support automatic SDK initialization via environment variables, but require manual handler wrapping.
66
+
### Option A: Automatic Setup (recommended)
84
67
85
68
Set the following environment variables in your Lambda function configuration:
That's it - make sure to re-deploy your function and you're all set!
122
83
123
84
### Option B: Manual Setup
124
85
125
86
To further customize the SDK setup, you can also manually initialize the SDK in your lambda function. The benefit of this installation method is that you can fully customize your Sentry SDK setup in a `Sentry.init` call.
126
87
127
-
#### For CommonJS Lambda Functions
128
-
129
-
You can initialize the SDK directly in your main handler file:
88
+
Create a new file, for example `instrument.js` to initialize the SDK:
It's important to add both, the `Sentry.init` call outside the handler function and the `Sentry.wrapHandler` wrapper around your function to automatically catch errors and performance data. Make sure that the `Sentry.init` call and the import statement are at the very top of your file before any other imports.
0 commit comments