Google Cloud Functions
Learn about using Sentry with Google Cloud Functions.
This guide is for version 8.0.0 and up of @sentry/google-cloud-serverless
.
Add @sentry/google-cloud-serverless
as a dependency to package.json
:
Copied
"@sentry/google-cloud-serverless": "^8.2.1"
To set up Sentry for a Google Cloud Function:
Copied
const Sentry = require('@sentry/google-cloud-serverless');
Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
// 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.wrapHttpFunction((req, res) => {
throw new Error('oh, hello there!');
});
Note
Sentry JavaScript Serverless SDK does not support Cloud Functions for Firebase at the moment.
Check out Sentry's GCP sample apps for detailed examples. Refer to the JavaScript docs for more configuration options.
With the Google Cloud Functions integration enabled, the Node SDK will:
- Automatically report all events from your Cloud Functions.
- Allows you to modify the transaction sample rate using
tracesSampleRate
. - Issue reports automatically include:
- A link to the Stackdriver logs
- Function details
- sys.argv for the function
- Function execution time
- Function version
- Sentry holds the thread for up to two seconds to report errors. You can change flush time limit by defining a
flushTimeout
value in the handler options
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").