From e311ea8f9f1ef00c14727da3aba8feb7d6fd7031 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Jul 2024 10:45:54 +0200 Subject: [PATCH] feat(node): Add docs for skipping instrumentation (#10803) --- docs/platforms/javascript/common/install/esm.mdx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/platforms/javascript/common/install/esm.mdx b/docs/platforms/javascript/common/install/esm.mdx index 3d6d37a9c14fd..d93658a9219e4 100644 --- a/docs/platforms/javascript/common/install/esm.mdx +++ b/docs/platforms/javascript/common/install/esm.mdx @@ -48,3 +48,19 @@ NODE_OPTIONS="--import ./instrument.mjs" npm run start ``` We do not support ESM in Node versions before 18.19.0. + +## Skipping instrumentation + +By default, all packages are wrapped under the hood by [import-in-the-middle](https://www.npmjs.com/package/import-in-the-middle). If you run into a problem with a package, you can skip instrumentation for it by configuring `registerEsmLoaderHooks` in your `Sentry.init()` config: + +```javascript {tabTitle:ESM} {filename: instrument.mjs} +import * as Sentry from "@sentry/node"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + registerEsmLoaderHooks: { + // Provide a list of package names to exclude from instrumentation + exclude: ["package-name"], + }, +}); +```