Google Cloud Functions

(New in version 5.26.0)

Add @sentry/serverless as a dependency to package.json:

Copied
  "@sentry/serverless": "^7.111.0"

To set up Sentry for a Google Cloud Function:

Copied
const Sentry = require("@sentry/serverless");

Sentry.GCPFunction.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  tracesSampleRate: 1.0,
});

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

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").