Skip to content

Commit 5421dc9

Browse files
authored
Usage of GCPFunction in serverless/README (#2969)
1 parent c04330e commit 5421dc9

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

packages/serverless/README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ methods available in `@sentry/node` can be imported from `@sentry/serverless`.
1919

2020
Currently supported environment:
2121

22-
*AWS Lambda*
22+
### AWS Lambda
2323

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

@@ -52,3 +52,35 @@ Sentry.AWSLambda.init({
5252
tracesSampleRate: 1.0,
5353
});
5454
```
55+
56+
### Google Cloud Functions
57+
58+
To use this SDK, call `Sentry.GCPFunction.init(options)` at the very beginning of your JavaScript file.
59+
60+
```javascript
61+
import * as Sentry from '@sentry/serverless';
62+
63+
Sentry.GCPFunction.init({
64+
dsn: '__DSN__',
65+
tracesSampleRate: 1.0,
66+
// ...
67+
});
68+
69+
// For HTTP Functions:
70+
71+
exports.helloHttp = Sentry.GCPFunction.wrapHttpFunction((req, res) => {
72+
throw new Error('oh, hello there!');
73+
});
74+
75+
// For Background Functions:
76+
77+
exports.helloEvents = Sentry.GCPFunction.wrapEventFunction((data, context, callback) => {
78+
throw new Error('oh, hello there!');
79+
});
80+
81+
// For CloudEvents:
82+
83+
exports.helloEvents = Sentry.GCPFunction.wrapCloudEventFunction((context, callback) => {
84+
throw new Error('oh, hello there!');
85+
});
86+
```

0 commit comments

Comments
 (0)