@sentry/node 9.34.0-alpha.1 → 9.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/cron/common.js +56 -0
- package/build/cjs/cron/common.js.map +1 -0
- package/build/cjs/cron/cron.js +112 -0
- package/build/cjs/cron/cron.js.map +1 -0
- package/build/cjs/cron/index.js +15 -0
- package/build/cjs/cron/index.js.map +1 -0
- package/build/cjs/cron/node-cron.js +71 -0
- package/build/cjs/cron/node-cron.js.map +1 -0
- package/build/cjs/cron/node-schedule.js +65 -0
- package/build/cjs/cron/node-schedule.js.map +1 -0
- package/build/cjs/index.js +56 -38
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/anr/index.js +238 -0
- package/build/cjs/integrations/anr/index.js.map +1 -0
- package/build/cjs/integrations/childProcess.js +100 -0
- package/build/cjs/integrations/childProcess.js.map +1 -0
- package/build/cjs/integrations/context.js +457 -0
- package/build/cjs/integrations/context.js.map +1 -0
- package/build/cjs/integrations/contextlines.js +405 -0
- package/build/cjs/integrations/contextlines.js.map +1 -0
- package/build/cjs/integrations/fs.js +2 -2
- package/build/cjs/integrations/fs.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +558 -0
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -0
- package/build/cjs/integrations/http/index.js +11 -7
- package/build/cjs/integrations/http/index.js.map +1 -1
- package/build/cjs/integrations/local-variables/common.js +69 -0
- package/build/cjs/integrations/local-variables/common.js.map +1 -0
- package/build/cjs/integrations/local-variables/index.js +12 -0
- package/build/cjs/integrations/local-variables/index.js.map +1 -0
- package/build/cjs/integrations/local-variables/local-variables-async.js +143 -0
- package/build/cjs/integrations/local-variables/local-variables-async.js.map +1 -0
- package/build/cjs/integrations/local-variables/local-variables-sync.js +410 -0
- package/build/cjs/integrations/local-variables/local-variables-sync.js.map +1 -0
- package/build/cjs/integrations/modules.js +135 -0
- package/build/cjs/integrations/modules.js.map +1 -0
- package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js +291 -0
- package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
- package/build/cjs/integrations/node-fetch/index.js +5 -4
- package/build/cjs/integrations/node-fetch/index.js.map +1 -1
- package/build/cjs/integrations/onuncaughtexception.js +134 -0
- package/build/cjs/integrations/onuncaughtexception.js.map +1 -0
- package/build/cjs/integrations/onunhandledrejection.js +89 -0
- package/build/cjs/integrations/onunhandledrejection.js.map +1 -0
- package/build/cjs/integrations/processSession.js +36 -0
- package/build/cjs/integrations/processSession.js.map +1 -0
- package/build/cjs/integrations/spotlight.js +101 -0
- package/build/cjs/integrations/spotlight.js.map +1 -0
- package/build/cjs/integrations/tracing/amqplib.js +5 -4
- package/build/cjs/integrations/tracing/amqplib.js.map +1 -1
- package/build/cjs/integrations/tracing/connect.js +4 -3
- package/build/cjs/integrations/tracing/connect.js.map +1 -1
- package/build/cjs/integrations/tracing/dataloader.js +3 -3
- package/build/cjs/integrations/tracing/dataloader.js.map +1 -1
- package/build/cjs/integrations/tracing/express.js +7 -5
- package/build/cjs/integrations/tracing/express.js.map +1 -1
- package/build/cjs/integrations/tracing/fastify/fastify-otel/index.js +3 -3
- package/build/cjs/integrations/tracing/fastify/fastify-otel/index.js.map +1 -1
- package/build/cjs/integrations/tracing/fastify/index.js +6 -6
- package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
- package/build/cjs/integrations/tracing/genericPool.js +3 -3
- package/build/cjs/integrations/tracing/genericPool.js.map +1 -1
- package/build/cjs/integrations/tracing/graphql.js +4 -3
- package/build/cjs/integrations/tracing/graphql.js.map +1 -1
- package/build/cjs/integrations/tracing/hapi/index.js +4 -3
- package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka.js +5 -4
- package/build/cjs/integrations/tracing/kafka.js.map +1 -1
- package/build/cjs/integrations/tracing/knex.js +3 -3
- package/build/cjs/integrations/tracing/knex.js.map +1 -1
- package/build/cjs/integrations/tracing/koa.js +6 -4
- package/build/cjs/integrations/tracing/koa.js.map +1 -1
- package/build/cjs/integrations/tracing/lrumemoizer.js +2 -2
- package/build/cjs/integrations/tracing/lrumemoizer.js.map +1 -1
- package/build/cjs/integrations/tracing/mongo.js +4 -3
- package/build/cjs/integrations/tracing/mongo.js.map +1 -1
- package/build/cjs/integrations/tracing/mongoose.js +4 -3
- package/build/cjs/integrations/tracing/mongoose.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql.js +2 -2
- package/build/cjs/integrations/tracing/mysql.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql2.js +4 -3
- package/build/cjs/integrations/tracing/mysql2.js.map +1 -1
- package/build/cjs/integrations/tracing/postgres.js +4 -3
- package/build/cjs/integrations/tracing/postgres.js.map +1 -1
- package/build/cjs/integrations/tracing/postgresjs.js +4 -3
- package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma.js +2 -2
- package/build/cjs/integrations/tracing/prisma.js.map +1 -1
- package/build/cjs/integrations/tracing/redis.js +3 -3
- package/build/cjs/integrations/tracing/redis.js.map +1 -1
- package/build/cjs/integrations/tracing/tedious.js +3 -3
- package/build/cjs/integrations/tracing/tedious.js.map +1 -1
- package/build/cjs/integrations/tracing/vercelai/index.js +2 -2
- package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -1
- package/build/cjs/integrations/winston.js +151 -0
- package/build/cjs/integrations/winston.js.map +1 -0
- package/build/cjs/logs/capture.js +29 -0
- package/build/cjs/logs/capture.js.map +1 -0
- package/build/cjs/logs/exports.js +178 -0
- package/build/cjs/logs/exports.js.map +1 -0
- package/build/cjs/nodeVersion.js +12 -0
- package/build/cjs/nodeVersion.js.map +1 -0
- package/build/cjs/otel/contextManager.js +16 -0
- package/build/cjs/otel/contextManager.js.map +1 -0
- package/build/cjs/otel/instrument.js +139 -0
- package/build/cjs/otel/instrument.js.map +1 -0
- package/build/cjs/preload.js +2 -2
- package/build/cjs/preload.js.map +1 -1
- package/build/cjs/proxy/base.js +122 -0
- package/build/cjs/proxy/base.js.map +1 -0
- package/build/cjs/proxy/index.js +173 -0
- package/build/cjs/proxy/index.js.map +1 -0
- package/build/cjs/proxy/parse-proxy-response.js +104 -0
- package/build/cjs/proxy/parse-proxy-response.js.map +1 -0
- package/build/cjs/sdk/api.js +117 -0
- package/build/cjs/sdk/api.js.map +1 -0
- package/build/cjs/sdk/client.js +156 -0
- package/build/cjs/sdk/client.js.map +1 -0
- package/build/cjs/sdk/index.js +203 -22
- package/build/cjs/sdk/index.js.map +1 -1
- package/build/cjs/sdk/initOtel.js +22 -4
- package/build/cjs/sdk/initOtel.js.map +1 -1
- package/build/cjs/transports/http.js +158 -0
- package/build/cjs/transports/http.js.map +1 -0
- package/build/cjs/utils/addOriginToSpan.js +11 -0
- package/build/cjs/utils/addOriginToSpan.js.map +1 -0
- package/build/cjs/utils/baggage.js +36 -0
- package/build/cjs/utils/baggage.js.map +1 -0
- package/build/cjs/utils/commonjs.js +13 -0
- package/build/cjs/utils/commonjs.js.map +1 -0
- package/build/cjs/utils/createMissingInstrumentationContext.js +11 -0
- package/build/cjs/utils/createMissingInstrumentationContext.js.map +1 -0
- package/build/cjs/utils/debug.js +23 -0
- package/build/cjs/utils/debug.js.map +1 -0
- package/build/cjs/utils/ensureIsWrapped.js +41 -0
- package/build/cjs/utils/ensureIsWrapped.js.map +1 -0
- package/build/cjs/utils/envToBool.js +32 -0
- package/build/cjs/utils/envToBool.js.map +1 -0
- package/build/cjs/utils/errorhandling.js +42 -0
- package/build/cjs/utils/errorhandling.js.map +1 -0
- package/build/cjs/utils/getRequestUrl.js +18 -0
- package/build/cjs/utils/getRequestUrl.js.map +1 -0
- package/build/cjs/utils/module.js +60 -0
- package/build/cjs/utils/module.js.map +1 -0
- package/build/esm/cron/common.js +54 -0
- package/build/esm/cron/common.js.map +1 -0
- package/build/esm/cron/cron.js +110 -0
- package/build/esm/cron/cron.js.map +1 -0
- package/build/esm/cron/index.js +13 -0
- package/build/esm/cron/index.js.map +1 -0
- package/build/esm/cron/node-cron.js +69 -0
- package/build/esm/cron/node-cron.js.map +1 -0
- package/build/esm/cron/node-schedule.js +63 -0
- package/build/esm/cron/node-schedule.js.map +1 -0
- package/build/esm/index.js +21 -2
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/anr/index.js +234 -0
- package/build/esm/integrations/anr/index.js.map +1 -0
- package/build/esm/integrations/anr/worker-script.js +2 -0
- package/build/esm/integrations/childProcess.js +98 -0
- package/build/esm/integrations/childProcess.js.map +1 -0
- package/build/esm/integrations/context.js +451 -0
- package/build/esm/integrations/context.js.map +1 -0
- package/build/esm/integrations/contextlines.js +399 -0
- package/build/esm/integrations/contextlines.js.map +1 -0
- package/build/esm/integrations/fs.js +1 -1
- package/build/esm/integrations/fs.js.map +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +555 -0
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -0
- package/build/esm/integrations/http/index.js +5 -1
- package/build/esm/integrations/http/index.js.map +1 -1
- package/build/esm/integrations/local-variables/common.js +64 -0
- package/build/esm/integrations/local-variables/common.js.map +1 -0
- package/build/esm/integrations/local-variables/index.js +10 -0
- package/build/esm/integrations/local-variables/index.js.map +1 -0
- package/build/esm/integrations/local-variables/local-variables-async.js +140 -0
- package/build/esm/integrations/local-variables/local-variables-async.js.map +1 -0
- package/build/esm/integrations/local-variables/local-variables-sync.js +405 -0
- package/build/esm/integrations/local-variables/local-variables-sync.js.map +1 -0
- package/build/esm/integrations/local-variables/worker-script.js +2 -0
- package/build/esm/integrations/modules.js +133 -0
- package/build/esm/integrations/modules.js.map +1 -0
- package/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js +289 -0
- package/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
- package/build/esm/integrations/node-fetch/index.js +3 -2
- package/build/esm/integrations/node-fetch/index.js.map +1 -1
- package/build/esm/integrations/onuncaughtexception.js +131 -0
- package/build/esm/integrations/onuncaughtexception.js.map +1 -0
- package/build/esm/integrations/onunhandledrejection.js +86 -0
- package/build/esm/integrations/onunhandledrejection.js.map +1 -0
- package/build/esm/integrations/processSession.js +34 -0
- package/build/esm/integrations/processSession.js.map +1 -0
- package/build/esm/integrations/spotlight.js +98 -0
- package/build/esm/integrations/spotlight.js.map +1 -0
- package/build/esm/integrations/tracing/amqplib.js +2 -1
- package/build/esm/integrations/tracing/amqplib.js.map +1 -1
- package/build/esm/integrations/tracing/connect.js +2 -1
- package/build/esm/integrations/tracing/connect.js.map +1 -1
- package/build/esm/integrations/tracing/dataloader.js +1 -1
- package/build/esm/integrations/tracing/dataloader.js.map +1 -1
- package/build/esm/integrations/tracing/express.js +4 -2
- package/build/esm/integrations/tracing/express.js.map +1 -1
- package/build/esm/integrations/tracing/fastify/fastify-otel/index.js +3 -3
- package/build/esm/integrations/tracing/fastify/fastify-otel/index.js.map +1 -1
- package/build/esm/integrations/tracing/fastify/index.js +5 -5
- package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
- package/build/esm/integrations/tracing/genericPool.js +1 -1
- package/build/esm/integrations/tracing/genericPool.js.map +1 -1
- package/build/esm/integrations/tracing/graphql.js +3 -2
- package/build/esm/integrations/tracing/graphql.js.map +1 -1
- package/build/esm/integrations/tracing/hapi/index.js +2 -1
- package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
- package/build/esm/integrations/tracing/kafka.js +2 -1
- package/build/esm/integrations/tracing/kafka.js.map +1 -1
- package/build/esm/integrations/tracing/knex.js +1 -1
- package/build/esm/integrations/tracing/knex.js.map +1 -1
- package/build/esm/integrations/tracing/koa.js +4 -2
- package/build/esm/integrations/tracing/koa.js.map +1 -1
- package/build/esm/integrations/tracing/lrumemoizer.js +1 -1
- package/build/esm/integrations/tracing/lrumemoizer.js.map +1 -1
- package/build/esm/integrations/tracing/mongo.js +2 -1
- package/build/esm/integrations/tracing/mongo.js.map +1 -1
- package/build/esm/integrations/tracing/mongoose.js +2 -1
- package/build/esm/integrations/tracing/mongoose.js.map +1 -1
- package/build/esm/integrations/tracing/mysql.js +1 -1
- package/build/esm/integrations/tracing/mysql.js.map +1 -1
- package/build/esm/integrations/tracing/mysql2.js +2 -1
- package/build/esm/integrations/tracing/mysql2.js.map +1 -1
- package/build/esm/integrations/tracing/postgres.js +2 -1
- package/build/esm/integrations/tracing/postgres.js.map +1 -1
- package/build/esm/integrations/tracing/postgresjs.js +3 -2
- package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
- package/build/esm/integrations/tracing/prisma.js +1 -1
- package/build/esm/integrations/tracing/prisma.js.map +1 -1
- package/build/esm/integrations/tracing/redis.js +1 -1
- package/build/esm/integrations/tracing/redis.js.map +1 -1
- package/build/esm/integrations/tracing/tedious.js +1 -1
- package/build/esm/integrations/tracing/tedious.js.map +1 -1
- package/build/esm/integrations/tracing/vercelai/index.js +1 -1
- package/build/esm/integrations/tracing/vercelai/index.js.map +1 -1
- package/build/esm/integrations/winston.js +149 -0
- package/build/esm/integrations/winston.js.map +1 -0
- package/build/esm/logs/capture.js +27 -0
- package/build/esm/logs/capture.js.map +1 -0
- package/build/esm/logs/exports.js +170 -0
- package/build/esm/logs/exports.js.map +1 -0
- package/build/esm/nodeVersion.js +8 -0
- package/build/esm/nodeVersion.js.map +1 -0
- package/build/esm/otel/contextManager.js +14 -0
- package/build/esm/otel/contextManager.js.map +1 -0
- package/build/esm/otel/instrument.js +135 -0
- package/build/esm/otel/instrument.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/preload.js +1 -1
- package/build/esm/preload.js.map +1 -1
- package/build/esm/proxy/base.js +120 -0
- package/build/esm/proxy/base.js.map +1 -0
- package/build/esm/proxy/index.js +171 -0
- package/build/esm/proxy/index.js.map +1 -0
- package/build/esm/proxy/parse-proxy-response.js +102 -0
- package/build/esm/proxy/parse-proxy-response.js.map +1 -0
- package/build/esm/sdk/api.js +114 -0
- package/build/esm/sdk/api.js.map +1 -0
- package/build/esm/sdk/client.js +154 -0
- package/build/esm/sdk/client.js.map +1 -0
- package/build/esm/sdk/index.js +202 -22
- package/build/esm/sdk/index.js.map +1 -1
- package/build/esm/sdk/initOtel.js +21 -3
- package/build/esm/sdk/initOtel.js.map +1 -1
- package/build/esm/transports/http.js +156 -0
- package/build/esm/transports/http.js.map +1 -0
- package/build/esm/utils/addOriginToSpan.js +9 -0
- package/build/esm/utils/addOriginToSpan.js.map +1 -0
- package/build/esm/utils/baggage.js +34 -0
- package/build/esm/utils/baggage.js.map +1 -0
- package/build/esm/utils/commonjs.js +11 -0
- package/build/esm/utils/commonjs.js.map +1 -0
- package/build/esm/utils/createMissingInstrumentationContext.js +9 -0
- package/build/esm/utils/createMissingInstrumentationContext.js.map +1 -0
- package/build/esm/utils/debug.js +21 -0
- package/build/esm/utils/debug.js.map +1 -0
- package/build/esm/utils/ensureIsWrapped.js +39 -0
- package/build/esm/utils/ensureIsWrapped.js.map +1 -0
- package/build/esm/utils/envToBool.js +28 -0
- package/build/esm/utils/envToBool.js.map +1 -0
- package/build/esm/utils/errorhandling.js +40 -0
- package/build/esm/utils/errorhandling.js.map +1 -0
- package/build/esm/utils/getRequestUrl.js +16 -0
- package/build/esm/utils/getRequestUrl.js.map +1 -0
- package/build/esm/utils/module.js +58 -0
- package/build/esm/utils/module.js.map +1 -0
- package/build/types/cron/common.d.ts +5 -0
- package/build/types/cron/common.d.ts.map +1 -0
- package/build/types/cron/cron.d.ts +43 -0
- package/build/types/cron/cron.d.ts.map +1 -0
- package/build/types/cron/index.d.ts +10 -0
- package/build/types/cron/index.d.ts.map +1 -0
- package/build/types/cron/node-cron.d.ts +27 -0
- package/build/types/cron/node-cron.d.ts.map +1 -0
- package/build/types/cron/node-schedule.d.ts +19 -0
- package/build/types/cron/node-schedule.d.ts.map +1 -0
- package/build/types/index.d.ts +21 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/anr/common.d.ts +52 -0
- package/build/types/integrations/anr/common.d.ts.map +1 -0
- package/build/types/integrations/anr/index.d.ts +13 -0
- package/build/types/integrations/anr/index.d.ts.map +1 -0
- package/build/types/integrations/anr/worker.d.ts +2 -0
- package/build/types/integrations/anr/worker.d.ts.map +1 -0
- package/build/types/integrations/childProcess.d.ts +20 -0
- package/build/types/integrations/childProcess.d.ts.map +1 -0
- package/build/types/integrations/context.d.ts +30 -0
- package/build/types/integrations/context.d.ts.map +1 -0
- package/build/types/integrations/contextlines.d.ts +31 -0
- package/build/types/integrations/contextlines.d.ts.map +1 -0
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +131 -0
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -0
- package/build/types/integrations/http/index.d.ts +1 -1
- package/build/types/integrations/http/index.d.ts.map +1 -1
- package/build/types/integrations/local-variables/common.d.ts +66 -0
- package/build/types/integrations/local-variables/common.d.ts.map +1 -0
- package/build/types/integrations/local-variables/index.d.ts +4 -0
- package/build/types/integrations/local-variables/index.d.ts.map +1 -0
- package/build/types/integrations/local-variables/local-variables-async.d.ts +7 -0
- package/build/types/integrations/local-variables/local-variables-async.d.ts.map +1 -0
- package/build/types/integrations/local-variables/local-variables-sync.d.ts +34 -0
- package/build/types/integrations/local-variables/local-variables-sync.d.ts.map +1 -0
- package/build/types/integrations/local-variables/worker.d.ts +2 -0
- package/build/types/integrations/local-variables/worker.d.ts.map +1 -0
- package/build/types/integrations/modules.d.ts +17 -0
- package/build/types/integrations/modules.d.ts.map +1 -0
- package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +56 -0
- package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts.map +1 -0
- package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
- package/build/types/integrations/onuncaughtexception.d.ts +31 -0
- package/build/types/integrations/onuncaughtexception.d.ts.map +1 -0
- package/build/types/integrations/onunhandledrejection.d.ts +23 -0
- package/build/types/integrations/onunhandledrejection.d.ts.map +1 -0
- package/build/types/integrations/processSession.d.ts +5 -0
- package/build/types/integrations/processSession.d.ts.map +1 -0
- package/build/types/integrations/spotlight.d.ts +18 -0
- package/build/types/integrations/spotlight.d.ts.map +1 -0
- package/build/types/integrations/tracing/amqplib.d.ts.map +1 -1
- package/build/types/integrations/tracing/connect.d.ts.map +1 -1
- package/build/types/integrations/tracing/express.d.ts.map +1 -1
- package/build/types/integrations/tracing/graphql.d.ts.map +1 -1
- package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka.d.ts.map +1 -1
- package/build/types/integrations/tracing/koa.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongo.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongoose.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql2.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgres.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -1
- package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -1
- package/build/types/integrations/winston.d.ts +44 -0
- package/build/types/integrations/winston.d.ts.map +1 -0
- package/build/types/logs/capture.d.ts +11 -0
- package/build/types/logs/capture.d.ts.map +1 -0
- package/build/types/logs/exports.d.ts +150 -0
- package/build/types/logs/exports.d.ts.map +1 -0
- package/build/types/nodeVersion.d.ts +8 -0
- package/build/types/nodeVersion.d.ts.map +1 -0
- package/build/types/otel/contextManager.d.ts +10 -0
- package/build/types/otel/contextManager.d.ts.map +1 -0
- package/build/types/otel/instrument.d.ts +23 -0
- package/build/types/otel/instrument.d.ts.map +1 -0
- package/build/types/proxy/base.d.ts +65 -0
- package/build/types/proxy/base.d.ts.map +1 -0
- package/build/types/proxy/helpers.d.ts +42 -0
- package/build/types/proxy/helpers.d.ts.map +1 -0
- package/build/types/proxy/index.d.ts +73 -0
- package/build/types/proxy/index.d.ts.map +1 -0
- package/build/types/proxy/parse-proxy-response.d.ts +43 -0
- package/build/types/proxy/parse-proxy-response.d.ts.map +1 -0
- package/build/types/sdk/api.d.ts +8 -0
- package/build/types/sdk/api.d.ts.map +1 -0
- package/build/types/sdk/client.d.ts +29 -0
- package/build/types/sdk/client.d.ts.map +1 -0
- package/build/types/sdk/index.d.ts +6 -2
- package/build/types/sdk/index.d.ts.map +1 -1
- package/build/types/sdk/initOtel.d.ts +1 -1
- package/build/types/sdk/initOtel.d.ts.map +1 -1
- package/build/types/sdk/scope.d.ts +7 -0
- package/build/types/sdk/scope.d.ts.map +1 -0
- package/build/types/transports/http-module.d.ts +31 -0
- package/build/types/transports/http-module.d.ts.map +1 -0
- package/build/types/transports/http.d.ts +21 -0
- package/build/types/transports/http.d.ts.map +1 -0
- package/build/types/transports/index.d.ts +3 -0
- package/build/types/transports/index.d.ts.map +1 -0
- package/build/types/types.d.ts +1 -1
- package/build/types/types.d.ts.map +1 -1
- package/build/types/utils/addOriginToSpan.d.ts +5 -0
- package/build/types/utils/addOriginToSpan.d.ts.map +1 -0
- package/build/types/utils/baggage.d.ts +6 -0
- package/build/types/utils/baggage.d.ts.map +1 -0
- package/build/types/utils/commonjs.d.ts +3 -0
- package/build/types/utils/commonjs.d.ts.map +1 -0
- package/build/types/utils/createMissingInstrumentationContext.d.ts +3 -0
- package/build/types/utils/createMissingInstrumentationContext.d.ts.map +1 -0
- package/build/types/utils/debug.d.ts +5 -0
- package/build/types/utils/debug.d.ts.map +1 -0
- package/build/types/utils/ensureIsWrapped.d.ts +5 -0
- package/build/types/utils/ensureIsWrapped.d.ts.map +1 -0
- package/build/types/utils/entry-point.d.ts +24 -0
- package/build/types/utils/entry-point.d.ts.map +1 -0
- package/build/types/utils/envToBool.d.ts +13 -0
- package/build/types/utils/envToBool.d.ts.map +1 -0
- package/build/types/utils/errorhandling.d.ts +5 -0
- package/build/types/utils/errorhandling.d.ts.map +1 -0
- package/build/types/utils/getRequestUrl.d.ts +5 -0
- package/build/types/utils/getRequestUrl.d.ts.map +1 -0
- package/build/types/utils/module.d.ts +3 -0
- package/build/types/utils/module.d.ts.map +1 -0
- package/build/types/utils/prepareEvent.d.ts +17 -0
- package/build/types/utils/prepareEvent.d.ts.map +1 -0
- package/build/types-ts3.8/cron/common.d.ts +5 -0
- package/build/types-ts3.8/cron/cron.d.ts +43 -0
- package/build/types-ts3.8/cron/index.d.ts +10 -0
- package/build/types-ts3.8/cron/node-cron.d.ts +27 -0
- package/build/types-ts3.8/cron/node-schedule.d.ts +19 -0
- package/build/types-ts3.8/index.d.ts +21 -2
- package/build/types-ts3.8/integrations/anr/common.d.ts +52 -0
- package/build/types-ts3.8/integrations/anr/index.d.ts +13 -0
- package/build/types-ts3.8/integrations/anr/worker.d.ts +2 -0
- package/build/types-ts3.8/integrations/childProcess.d.ts +20 -0
- package/build/types-ts3.8/integrations/context.d.ts +30 -0
- package/build/types-ts3.8/integrations/contextlines.d.ts +31 -0
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +133 -0
- package/build/types-ts3.8/integrations/http/index.d.ts +1 -1
- package/build/types-ts3.8/integrations/local-variables/common.d.ts +66 -0
- package/build/types-ts3.8/integrations/local-variables/index.d.ts +4 -0
- package/build/types-ts3.8/integrations/local-variables/local-variables-async.d.ts +7 -0
- package/build/types-ts3.8/integrations/local-variables/local-variables-sync.d.ts +34 -0
- package/build/types-ts3.8/integrations/local-variables/worker.d.ts +2 -0
- package/build/types-ts3.8/integrations/modules.d.ts +17 -0
- package/build/types-ts3.8/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +56 -0
- package/build/types-ts3.8/integrations/onuncaughtexception.d.ts +31 -0
- package/build/types-ts3.8/integrations/onunhandledrejection.d.ts +23 -0
- package/build/types-ts3.8/integrations/processSession.d.ts +5 -0
- package/build/types-ts3.8/integrations/spotlight.d.ts +18 -0
- package/build/types-ts3.8/integrations/winston.d.ts +44 -0
- package/build/types-ts3.8/logs/capture.d.ts +18 -0
- package/build/types-ts3.8/logs/exports.d.ts +150 -0
- package/build/types-ts3.8/nodeVersion.d.ts +8 -0
- package/build/types-ts3.8/otel/contextManager.d.ts +10 -0
- package/build/types-ts3.8/otel/instrument.d.ts +23 -0
- package/build/types-ts3.8/proxy/base.d.ts +60 -0
- package/build/types-ts3.8/proxy/helpers.d.ts +38 -0
- package/build/types-ts3.8/proxy/index.d.ts +74 -0
- package/build/types-ts3.8/proxy/parse-proxy-response.d.ts +40 -0
- package/build/types-ts3.8/sdk/api.d.ts +8 -0
- package/build/types-ts3.8/sdk/client.d.ts +32 -0
- package/build/types-ts3.8/sdk/index.d.ts +6 -2
- package/build/types-ts3.8/sdk/initOtel.d.ts +1 -1
- package/build/types-ts3.8/sdk/scope.d.ts +7 -0
- package/build/types-ts3.8/transports/http-module.d.ts +28 -0
- package/build/types-ts3.8/transports/http.d.ts +20 -0
- package/build/types-ts3.8/transports/index.d.ts +3 -0
- package/build/types-ts3.8/types.d.ts +1 -1
- package/build/types-ts3.8/utils/addOriginToSpan.d.ts +5 -0
- package/build/types-ts3.8/utils/baggage.d.ts +6 -0
- package/build/types-ts3.8/utils/commonjs.d.ts +3 -0
- package/build/types-ts3.8/utils/createMissingInstrumentationContext.d.ts +3 -0
- package/build/types-ts3.8/utils/debug.d.ts +5 -0
- package/build/types-ts3.8/utils/ensureIsWrapped.d.ts +5 -0
- package/build/types-ts3.8/utils/entry-point.d.ts +24 -0
- package/build/types-ts3.8/utils/envToBool.d.ts +13 -0
- package/build/types-ts3.8/utils/errorhandling.d.ts +5 -0
- package/build/types-ts3.8/utils/getRequestUrl.d.ts +5 -0
- package/build/types-ts3.8/utils/module.d.ts +3 -0
- package/build/types-ts3.8/utils/prepareEvent.d.ts +17 -0
- package/package.json +3 -4
|
@@ -3,20 +3,24 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const api = require('@opentelemetry/api');
|
|
4
4
|
const instrumentationHttp = require('@opentelemetry/instrumentation-http');
|
|
5
5
|
const core = require('@sentry/core');
|
|
6
|
-
const
|
|
6
|
+
const nodeVersion = require('../../nodeVersion.js');
|
|
7
|
+
const instrument = require('../../otel/instrument.js');
|
|
8
|
+
const addOriginToSpan = require('../../utils/addOriginToSpan.js');
|
|
9
|
+
const getRequestUrl = require('../../utils/getRequestUrl.js');
|
|
10
|
+
const SentryHttpInstrumentation = require('./SentryHttpInstrumentation.js');
|
|
7
11
|
|
|
8
12
|
const INTEGRATION_NAME = 'Http';
|
|
9
13
|
|
|
10
14
|
const INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';
|
|
11
15
|
|
|
12
|
-
const instrumentSentryHttp =
|
|
16
|
+
const instrumentSentryHttp = instrument.generateInstrumentOnce(
|
|
13
17
|
`${INTEGRATION_NAME}.sentry`,
|
|
14
18
|
options => {
|
|
15
|
-
return new
|
|
19
|
+
return new SentryHttpInstrumentation.SentryHttpInstrumentation(options);
|
|
16
20
|
},
|
|
17
21
|
);
|
|
18
22
|
|
|
19
|
-
const instrumentOtelHttp =
|
|
23
|
+
const instrumentOtelHttp = instrument.generateInstrumentOnce(INTEGRATION_NAME, config => {
|
|
20
24
|
const instrumentation = new instrumentationHttp.HttpInstrumentation(config);
|
|
21
25
|
|
|
22
26
|
// We want to update the logger namespace so we can better identify what is happening here
|
|
@@ -47,7 +51,7 @@ function _shouldInstrumentSpans(options, clientOptions = {}) {
|
|
|
47
51
|
|
|
48
52
|
// IMPORTANT: We only disable span instrumentation when spans are not enabled _and_ we are on Node 22+,
|
|
49
53
|
// as otherwise the necessary diagnostics channel is not available yet
|
|
50
|
-
if (!core.hasSpansEnabled(clientOptions) &&
|
|
54
|
+
if (!core.hasSpansEnabled(clientOptions) && nodeVersion.NODE_VERSION.major >= 22) {
|
|
51
55
|
return false;
|
|
52
56
|
}
|
|
53
57
|
|
|
@@ -131,7 +135,7 @@ function getConfigWithDefaults(options = {}) {
|
|
|
131
135
|
disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,
|
|
132
136
|
|
|
133
137
|
ignoreOutgoingRequestHook: request => {
|
|
134
|
-
const url =
|
|
138
|
+
const url = getRequestUrl.getRequestUrl(request);
|
|
135
139
|
|
|
136
140
|
if (!url) {
|
|
137
141
|
return false;
|
|
@@ -167,7 +171,7 @@ function getConfigWithDefaults(options = {}) {
|
|
|
167
171
|
requireParentforOutgoingSpans: false,
|
|
168
172
|
requireParentforIncomingSpans: false,
|
|
169
173
|
requestHook: (span, req) => {
|
|
170
|
-
|
|
174
|
+
addOriginToSpan.addOriginToSpan(span, 'auto.http.otel.http');
|
|
171
175
|
if (!_isClientRequest(req) && isKnownPrefetchRequest(req)) {
|
|
172
176
|
span.setAttribute('sentry.http.prefetch', true);
|
|
173
177
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/integrations/http/index.ts"],"sourcesContent":["import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';\nimport { diag } from '@opentelemetry/api';\nimport type { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport type { Span } from '@sentry/core';\nimport { defineIntegration, getClient, hasSpansEnabled } from '@sentry/core';\nimport type { HTTPModuleRequestIncomingMessage, NodeClient } from '@sentry/node-core';\nimport {\n type SentryHttpInstrumentationOptions,\n addOriginToSpan,\n generateInstrumentOnce,\n getRequestUrl,\n NODE_VERSION,\n SentryHttpInstrumentation,\n} from '@sentry/node-core';\nimport type { NodeClientOptions } from '../../types';\n\nconst INTEGRATION_NAME = 'Http';\n\nconst INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';\n\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n *\n * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests with the given status codes.\n * By default, spans with 404 status code are ignored.\n * Expects an array of status codes or a range of status codes, e.g. [[300,399], 404] would ignore 3xx and 404 status codes.\n *\n * @default `[404]`\n */\n dropSpansForIncomingRequestStatusCodes?: (number | [number, number])[];\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed and we want to avoid capturing it.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the incoming request.\n * @param request Contains the {@type RequestOptions} object used to make the incoming request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Controls the maximum size of incoming HTTP request bodies attached to events.\n *\n * Available options:\n * - 'none': No request bodies will be attached\n * - 'small': Request bodies up to 1,000 bytes will be attached\n * - 'medium': Request bodies up to 10,000 bytes will be attached (default)\n * - 'always': Request bodies will always be attached\n *\n * Note that even with 'always' setting, bodies exceeding 1MB will never be attached\n * for performance and security reasons.\n *\n * @default 'medium'\n */\n maxIncomingRequestBodySize?: 'none' | 'small' | 'medium' | 'always';\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;\n responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => void;\n\n /**\n * You can pass any configuration through to the underlying instrumentation.\n * Note that there are no semver guarantees for this!\n */\n _experimentalConfig?: ConstructorParameters<typeof HttpInstrumentation>[0];\n };\n}\n\nconst instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(\n `${INTEGRATION_NAME}.sentry`,\n options => {\n return new SentryHttpInstrumentation(options);\n },\n);\n\nexport const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConfig>(INTEGRATION_NAME, config => {\n const instrumentation = new HttpInstrumentation(config);\n\n // We want to update the logger namespace so we can better identify what is happening here\n try {\n instrumentation['_diag'] = diag.createComponentLogger({\n namespace: INSTRUMENTATION_NAME,\n });\n // @ts-expect-error We are writing a read-only property here...\n instrumentation.instrumentationName = INSTRUMENTATION_NAME;\n } catch {\n // ignore errors here...\n }\n\n return instrumentation;\n});\n\n/** Exported only for tests. */\nexport function _shouldInstrumentSpans(options: HttpOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true` or spans are not enabled\n if (typeof options.spans === 'boolean') {\n return options.spans;\n }\n\n if (clientOptions.skipOpenTelemetrySetup) {\n return false;\n }\n\n // IMPORTANT: We only disable span instrumentation when spans are not enabled _and_ we are on Node 22+,\n // as otherwise the necessary diagnostics channel is not available yet\n if (!hasSpansEnabled(clientOptions) && NODE_VERSION.major >= 22) {\n return false;\n }\n\n return true;\n}\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [404];\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is Sentry-specific instrumentation for request isolation and breadcrumbs\n instrumentSentryHttp({\n ...options,\n // If spans are not instrumented, it means the HttpInstrumentation has not been added\n // In that case, we want to handle incoming trace extraction ourselves\n extractIncomingTraceFromHeader: !instrumentSpans,\n // If spans are not instrumented, it means the HttpInstrumentation has not been added\n // In that case, we want to handle trace propagation ourselves\n propagateTraceInOutgoingRequests: !instrumentSpans,\n });\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n },\n processEvent(event) {\n // Drop transaction if it has a status code that should be ignored\n if (event.type === 'transaction') {\n const statusCode = event.contexts?.trace?.data?.['http.response.status_code'];\n if (\n typeof statusCode === 'number' &&\n dropSpansForIncomingRequestStatusCodes.some(code => {\n if (typeof code === 'number') {\n return code === statusCode;\n }\n\n const [min, max] = code;\n return statusCode >= min && statusCode <= max;\n })\n ) {\n return null;\n }\n }\n\n return event;\n },\n };\n});\n\n/**\n * Determines if @param req is a ClientRequest, meaning the request was created within the express app\n * and it's an outgoing request.\n * Checking for properties instead of using `instanceOf` to avoid importing the request classes.\n */\nfunction _isClientRequest(req: ClientRequest | HTTPModuleRequestIncomingMessage): req is ClientRequest {\n return 'outputData' in req && 'outputSize' in req && !('client' in req) && !('statusCode' in req);\n}\n\n/**\n * Detects if an incoming request is a prefetch request.\n */\nfunction isKnownPrefetchRequest(req: HTTPModuleRequestIncomingMessage): boolean {\n // Currently only handles Next.js prefetch requests but may check other frameworks in the future.\n return req.headers['next-router-prefetch'] === '1';\n}\n\nfunction getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrumentationConfig {\n const instrumentationConfig = {\n ...options.instrumentation?._experimentalConfig,\n\n disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,\n\n ignoreOutgoingRequestHook: request => {\n const url = getRequestUrl(request);\n\n if (!url) {\n return false;\n }\n\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n if (_ignoreOutgoingRequests?.(url, request)) {\n return true;\n }\n\n return false;\n },\n\n ignoreIncomingRequestHook: request => {\n // request.url is the only property that holds any information about the url\n // it only consists of the URL path and query string (if any)\n const urlPath = request.url;\n\n const method = request.method?.toUpperCase();\n // We do not capture OPTIONS/HEAD requests as transactions\n if (method === 'OPTIONS' || method === 'HEAD') {\n return true;\n }\n\n const _ignoreIncomingRequests = options.ignoreIncomingRequests;\n if (urlPath && _ignoreIncomingRequests?.(urlPath, request)) {\n return true;\n }\n\n return false;\n },\n\n requireParentforOutgoingSpans: false,\n requireParentforIncomingSpans: false,\n requestHook: (span, req) => {\n addOriginToSpan(span, 'auto.http.otel.http');\n if (!_isClientRequest(req) && isKnownPrefetchRequest(req)) {\n span.setAttribute('sentry.http.prefetch', true);\n }\n\n options.instrumentation?.requestHook?.(span, req);\n },\n responseHook: (span, res) => {\n options.instrumentation?.responseHook?.(span, res);\n },\n applyCustomAttributesOnSpan: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => {\n options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);\n },\n } satisfies HttpInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":["generateInstrumentOnce","SentryHttpInstrumentation","HttpInstrumentation","diag","hasSpansEnabled","NODE_VERSION","defineIntegration","getClient","getRequestUrl","addOriginToSpan"],"mappings":";;;;;;;AAiBA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B,MAAM,oBAAA,GAAuB,oDAAoD;;AAqHjF,MAAM,oBAAA,GAAuBA,+BAAsB;AACnD,EAAE,CAAC,EAAA,gBAAA,CAAA,OAAA,CAAA;AACA,EAAA,OAAA,IAAA;AACA,IAAA,OAAA,IAAAC,kCAAA,CAAA,OAAA,CAAA;AACA,GAAA;AACA,CAAA;;AAEA,MAAA,kBAAA,GAAAD,+BAAA,CAAA,gBAAA,EAAA,MAAA,IAAA;AACA,EAAA,MAAA,eAAA,GAAA,IAAAE,uCAAA,CAAA,MAAA,CAAA;;AAEA;AACA,EAAA,IAAA;AACA,IAAA,eAAA,CAAA,OAAA,CAAA,GAAAC,QAAA,CAAA,qBAAA,CAAA;AACA,MAAA,SAAA,EAAA,oBAAA;AACA,KAAA,CAAA;AACA;AACA,IAAA,eAAA,CAAA,mBAAA,GAAA,oBAAA;AACA,GAAA,CAAA,MAAA;AACA;AACA;;AAEA,EAAA,OAAA,eAAA;AACA,CAAA;;AAEA;AACA,SAAA,sBAAA,CAAA,OAAA,EAAA,aAAA,GAAA,EAAA,EAAA;AACA;AACA;AACA,EAAA,IAAA,OAAA,OAAA,CAAA,KAAA,KAAA,SAAA,EAAA;AACA,IAAA,OAAA,OAAA,CAAA,KAAA;AACA;;AAEA,EAAA,IAAA,aAAA,CAAA,sBAAA,EAAA;AACA,IAAA,OAAA,KAAA;AACA;;AAEA;AACA;AACA,EAAA,IAAA,CAAAC,oBAAA,CAAA,aAAA,CAAA,IAA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AA,sBAAA;AACA,MAAA,IAAA,OAAA,IAAA,uBAAA,GAAA,OAAA,EAAA,OAAA,CAAA,EAAA;AACA,QAAA,OAAA,IAAA;AACA;;AAEA,MAAA,OAAA,KAAA;AACA,KAAA;;AAEA,IAAA,6BAAA,EAAA,KAAA;AACA,IAAA,6BAAA,EAAA,KAAA;AACA,IAAA,WAAA,EAAA,CAAA,IAAA,EAAA,GAAA,KAAA;AACA,MAAAC,wBAAA,CAAA,IAAA,EAAA,qBAAA,CAAA;AACA,MAAA,IAAA,CAAA,gBAAA,CAAA,GAAA,CAAA,IAAA,sBAAA,CAAA,GAAA,CAAA,EAAA;AACA,QAAA,IAAA,CAAA,YAAA,CAAA,sBAAA,EAAA,IAAA,CAAA;AACA;;AAEA,MAAA,OAAA,CAAA,eAAA,EAAA,WAAA,GAAA,IAAA,EAAA,GAAA,CAAA;AACA,KAAA;AACA,IAAA,YAAA,EAAA,CAAA,IAAA,EAAA,GAAA,KAAA;AACA,MAAA,OAAA,CAAA,eAAA,EAAA,YAAA,GAAA,IAAA,EAAA,GAAA,CAAA;AACA,KAAA;AACA,IAAA,2BAAA,EAAA;AACA,MAAA,IAAA;AACA,MAAA,OAAA;AACA,MAAA,QAAA;AACA,SAAA;AACA,MAAA,OAAA,CAAA,eAAA,EAAA,2BAAA,GAAA,IAAA,EAAA,OAAA,EAAA,QAAA,CAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAA,OAAA,qBAAA;AACA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/http/index.ts"],"sourcesContent":["import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';\nimport { diag } from '@opentelemetry/api';\nimport type { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport type { Span } from '@sentry/core';\nimport { defineIntegration, getClient, hasSpansEnabled } from '@sentry/core';\nimport { NODE_VERSION } from '../../nodeVersion';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { NodeClient } from '../../sdk/client';\nimport type { HTTPModuleRequestIncomingMessage } from '../../transports/http-module';\nimport type { NodeClientOptions } from '../../types';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport type { SentryHttpInstrumentationOptions } from './SentryHttpInstrumentation';\nimport { SentryHttpInstrumentation } from './SentryHttpInstrumentation';\n\nconst INTEGRATION_NAME = 'Http';\n\nconst INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';\n\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n *\n * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests with the given status codes.\n * By default, spans with 404 status code are ignored.\n * Expects an array of status codes or a range of status codes, e.g. [[300,399], 404] would ignore 3xx and 404 status codes.\n *\n * @default `[404]`\n */\n dropSpansForIncomingRequestStatusCodes?: (number | [number, number])[];\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed and we want to avoid capturing it.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the incoming request.\n * @param request Contains the {@type RequestOptions} object used to make the incoming request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Controls the maximum size of incoming HTTP request bodies attached to events.\n *\n * Available options:\n * - 'none': No request bodies will be attached\n * - 'small': Request bodies up to 1,000 bytes will be attached\n * - 'medium': Request bodies up to 10,000 bytes will be attached (default)\n * - 'always': Request bodies will always be attached\n *\n * Note that even with 'always' setting, bodies exceeding 1MB will never be attached\n * for performance and security reasons.\n *\n * @default 'medium'\n */\n maxIncomingRequestBodySize?: 'none' | 'small' | 'medium' | 'always';\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;\n responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => void;\n\n /**\n * You can pass any configuration through to the underlying instrumentation.\n * Note that there are no semver guarantees for this!\n */\n _experimentalConfig?: ConstructorParameters<typeof HttpInstrumentation>[0];\n };\n}\n\nconst instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(\n `${INTEGRATION_NAME}.sentry`,\n options => {\n return new SentryHttpInstrumentation(options);\n },\n);\n\nexport const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConfig>(INTEGRATION_NAME, config => {\n const instrumentation = new HttpInstrumentation(config);\n\n // We want to update the logger namespace so we can better identify what is happening here\n try {\n instrumentation['_diag'] = diag.createComponentLogger({\n namespace: INSTRUMENTATION_NAME,\n });\n // @ts-expect-error We are writing a read-only property here...\n instrumentation.instrumentationName = INSTRUMENTATION_NAME;\n } catch {\n // ignore errors here...\n }\n\n return instrumentation;\n});\n\n/** Exported only for tests. */\nexport function _shouldInstrumentSpans(options: HttpOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true` or spans are not enabled\n if (typeof options.spans === 'boolean') {\n return options.spans;\n }\n\n if (clientOptions.skipOpenTelemetrySetup) {\n return false;\n }\n\n // IMPORTANT: We only disable span instrumentation when spans are not enabled _and_ we are on Node 22+,\n // as otherwise the necessary diagnostics channel is not available yet\n if (!hasSpansEnabled(clientOptions) && NODE_VERSION.major >= 22) {\n return false;\n }\n\n return true;\n}\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [404];\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is Sentry-specific instrumentation for request isolation and breadcrumbs\n instrumentSentryHttp({\n ...options,\n // If spans are not instrumented, it means the HttpInstrumentation has not been added\n // In that case, we want to handle incoming trace extraction ourselves\n extractIncomingTraceFromHeader: !instrumentSpans,\n // If spans are not instrumented, it means the HttpInstrumentation has not been added\n // In that case, we want to handle trace propagation ourselves\n propagateTraceInOutgoingRequests: !instrumentSpans,\n });\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n },\n processEvent(event) {\n // Drop transaction if it has a status code that should be ignored\n if (event.type === 'transaction') {\n const statusCode = event.contexts?.trace?.data?.['http.response.status_code'];\n if (\n typeof statusCode === 'number' &&\n dropSpansForIncomingRequestStatusCodes.some(code => {\n if (typeof code === 'number') {\n return code === statusCode;\n }\n\n const [min, max] = code;\n return statusCode >= min && statusCode <= max;\n })\n ) {\n return null;\n }\n }\n\n return event;\n },\n };\n});\n\n/**\n * Determines if @param req is a ClientRequest, meaning the request was created within the express app\n * and it's an outgoing request.\n * Checking for properties instead of using `instanceOf` to avoid importing the request classes.\n */\nfunction _isClientRequest(req: ClientRequest | HTTPModuleRequestIncomingMessage): req is ClientRequest {\n return 'outputData' in req && 'outputSize' in req && !('client' in req) && !('statusCode' in req);\n}\n\n/**\n * Detects if an incoming request is a prefetch request.\n */\nfunction isKnownPrefetchRequest(req: HTTPModuleRequestIncomingMessage): boolean {\n // Currently only handles Next.js prefetch requests but may check other frameworks in the future.\n return req.headers['next-router-prefetch'] === '1';\n}\n\nfunction getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrumentationConfig {\n const instrumentationConfig = {\n ...options.instrumentation?._experimentalConfig,\n\n disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,\n\n ignoreOutgoingRequestHook: request => {\n const url = getRequestUrl(request);\n\n if (!url) {\n return false;\n }\n\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n if (_ignoreOutgoingRequests?.(url, request)) {\n return true;\n }\n\n return false;\n },\n\n ignoreIncomingRequestHook: request => {\n // request.url is the only property that holds any information about the url\n // it only consists of the URL path and query string (if any)\n const urlPath = request.url;\n\n const method = request.method?.toUpperCase();\n // We do not capture OPTIONS/HEAD requests as transactions\n if (method === 'OPTIONS' || method === 'HEAD') {\n return true;\n }\n\n const _ignoreIncomingRequests = options.ignoreIncomingRequests;\n if (urlPath && _ignoreIncomingRequests?.(urlPath, request)) {\n return true;\n }\n\n return false;\n },\n\n requireParentforOutgoingSpans: false,\n requireParentforIncomingSpans: false,\n requestHook: (span, req) => {\n addOriginToSpan(span, 'auto.http.otel.http');\n if (!_isClientRequest(req) && isKnownPrefetchRequest(req)) {\n span.setAttribute('sentry.http.prefetch', true);\n }\n\n options.instrumentation?.requestHook?.(span, req);\n },\n responseHook: (span, res) => {\n options.instrumentation?.responseHook?.(span, res);\n },\n applyCustomAttributesOnSpan: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => {\n options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);\n },\n } satisfies HttpInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":["generateInstrumentOnce","SentryHttpInstrumentation","HttpInstrumentation","diag","hasSpansEnabled","NODE_VERSION","defineIntegration","getClient","getRequestUrl","addOriginToSpan"],"mappings":";;;;;;;;;;;AAgBA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B,MAAM,oBAAA,GAAuB,oDAAoD;;AAqHjF,MAAM,oBAAA,GAAuBA,iCAAsB;AACnD,EAAE,CAAC,EAAA,gBAAA,CAAA,OAAA,CAAA;AACA,EAAA,OAAA,IAAA;AACA,IAAA,OAAA,IAAAC,mDAAA,CAAA,OAAA,CAAA;AACA,GAAA;AACA,CAAA;;AAEA,MAAA,kBAAA,GAAAD,iCAAA,CAAA,gBAAA,EAAA,MAA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KAAA;AACA,MAAA,OAAA,CAAA,eAAA,EAAA,YAAA,GAAA,IAAA,EAAA,GAAA,CAAA;AACA,KAAA;AACA,IAAA,2BAAA,EAAA;AACA,MAAA,IAAA;AACA,MAAA,OAAA;AACA,MAAA,QAAA;AACA,SAAA;AACA,MAAA,OAAA,CAAA,eAAA,EAAA,2BAAA,GAAA,IAAA,EAAA,OAAA,EAAA,QAAA,CAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAA,OAAA,qBAAA;AACA;;;;;;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The key used to store the local variables on the error object.
|
|
5
|
+
*/
|
|
6
|
+
const LOCAL_VARIABLES_KEY = '__SENTRY_ERROR_LOCAL_VARIABLES__';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a rate limiter that will call the disable callback when the rate limit is reached and the enable callback
|
|
10
|
+
* when a timeout has occurred.
|
|
11
|
+
* @param maxPerSecond Maximum number of calls per second
|
|
12
|
+
* @param enable Callback to enable capture
|
|
13
|
+
* @param disable Callback to disable capture
|
|
14
|
+
* @returns A function to call to increment the rate limiter count
|
|
15
|
+
*/
|
|
16
|
+
function createRateLimiter(
|
|
17
|
+
maxPerSecond,
|
|
18
|
+
enable,
|
|
19
|
+
disable,
|
|
20
|
+
) {
|
|
21
|
+
let count = 0;
|
|
22
|
+
let retrySeconds = 5;
|
|
23
|
+
let disabledTimeout = 0;
|
|
24
|
+
|
|
25
|
+
setInterval(() => {
|
|
26
|
+
if (disabledTimeout === 0) {
|
|
27
|
+
if (count > maxPerSecond) {
|
|
28
|
+
retrySeconds *= 2;
|
|
29
|
+
disable(retrySeconds);
|
|
30
|
+
|
|
31
|
+
// Cap at one day
|
|
32
|
+
if (retrySeconds > 86400) {
|
|
33
|
+
retrySeconds = 86400;
|
|
34
|
+
}
|
|
35
|
+
disabledTimeout = retrySeconds;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
disabledTimeout -= 1;
|
|
39
|
+
|
|
40
|
+
if (disabledTimeout === 0) {
|
|
41
|
+
enable();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
count = 0;
|
|
46
|
+
}, 1000).unref();
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
count += 1;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Add types for the exception event data
|
|
54
|
+
|
|
55
|
+
/** Could this be an anonymous function? */
|
|
56
|
+
function isAnonymous(name) {
|
|
57
|
+
return name !== undefined && (name.length === 0 || name === '?' || name === '<anonymous>');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Do the function names appear to match? */
|
|
61
|
+
function functionNamesMatch(a, b) {
|
|
62
|
+
return a === b || `Object.${a}` === b || a === `Object.${b}` || (isAnonymous(a) && isAnonymous(b));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.LOCAL_VARIABLES_KEY = LOCAL_VARIABLES_KEY;
|
|
66
|
+
exports.createRateLimiter = createRateLimiter;
|
|
67
|
+
exports.functionNamesMatch = functionNamesMatch;
|
|
68
|
+
exports.isAnonymous = isAnonymous;
|
|
69
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sources":["../../../../src/integrations/local-variables/common.ts"],"sourcesContent":["import type { Debugger } from 'node:inspector';\n\nexport type Variables = Record<string, unknown>;\n\nexport type RateLimitIncrement = () => void;\n\n/**\n * The key used to store the local variables on the error object.\n */\nexport const LOCAL_VARIABLES_KEY = '__SENTRY_ERROR_LOCAL_VARIABLES__';\n\n/**\n * Creates a rate limiter that will call the disable callback when the rate limit is reached and the enable callback\n * when a timeout has occurred.\n * @param maxPerSecond Maximum number of calls per second\n * @param enable Callback to enable capture\n * @param disable Callback to disable capture\n * @returns A function to call to increment the rate limiter count\n */\nexport function createRateLimiter(\n maxPerSecond: number,\n enable: () => void,\n disable: (seconds: number) => void,\n): RateLimitIncrement {\n let count = 0;\n let retrySeconds = 5;\n let disabledTimeout = 0;\n\n setInterval(() => {\n if (disabledTimeout === 0) {\n if (count > maxPerSecond) {\n retrySeconds *= 2;\n disable(retrySeconds);\n\n // Cap at one day\n if (retrySeconds > 86400) {\n retrySeconds = 86400;\n }\n disabledTimeout = retrySeconds;\n }\n } else {\n disabledTimeout -= 1;\n\n if (disabledTimeout === 0) {\n enable();\n }\n }\n\n count = 0;\n }, 1_000).unref();\n\n return () => {\n count += 1;\n };\n}\n\n// Add types for the exception event data\nexport type PausedExceptionEvent = Debugger.PausedEventDataType & {\n data: {\n // This contains error.stack\n description: string;\n objectId?: string;\n };\n};\n\n/** Could this be an anonymous function? */\nexport function isAnonymous(name: string | undefined): boolean {\n return name !== undefined && (name.length === 0 || name === '?' || name === '<anonymous>');\n}\n\n/** Do the function names appear to match? */\nexport function functionNamesMatch(a: string | undefined, b: string | undefined): boolean {\n return a === b || `Object.${a}` === b || a === `Object.${b}` || (isAnonymous(a) && isAnonymous(b));\n}\n\nexport interface FrameVariables {\n function: string;\n vars?: Variables;\n}\n\nexport interface LocalVariablesIntegrationOptions {\n /**\n * Capture local variables for both caught and uncaught exceptions\n *\n * - When false, only uncaught exceptions will have local variables\n * - When true, both caught and uncaught exceptions will have local variables.\n *\n * Defaults to `true`.\n *\n * Capturing local variables for all exceptions can be expensive since the debugger pauses for every throw to collect\n * local variables.\n *\n * To reduce the likelihood of this feature impacting app performance or throughput, this feature is rate-limited.\n * Once the rate limit is reached, local variables will only be captured for uncaught exceptions until a timeout has\n * been reached.\n */\n captureAllExceptions?: boolean;\n /**\n * Maximum number of exceptions to capture local variables for per second before rate limiting is triggered.\n */\n maxExceptionsPerSecond?: number;\n}\n\nexport interface LocalVariablesWorkerArgs extends LocalVariablesIntegrationOptions {\n /**\n * Whether to enable debug logging.\n */\n debug: boolean;\n /**\n * Base path used to calculate module name.\n *\n * Defaults to `dirname(process.argv[1])` and falls back to `process.cwd()`\n */\n basePath?: string;\n}\n"],"names":[],"mappings":";;AAMA;AACA;AACA;AACO,MAAM,mBAAoB,GAAE;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB;AACjC,EAAE,YAAY;AACd,EAAE,MAAM;AACR,EAAE,OAAO;AACT,EAAsB;AACtB,EAAE,IAAI,KAAM,GAAE,CAAC;AACf,EAAE,IAAI,YAAa,GAAE,CAAC;AACtB,EAAE,IAAI,eAAgB,GAAE,CAAC;;AAEzB,EAAE,WAAW,CAAC,MAAM;AACpB,IAAI,IAAI,eAAgB,KAAI,CAAC,EAAE;AAC/B,MAAM,IAAI,KAAM,GAAE,YAAY,EAAE;AAChC,QAAQ,YAAA,IAAgB,CAAC;AACzB,QAAQ,OAAO,CAAC,YAAY,CAAC;;AAE7B;AACA,QAAQ,IAAI,YAAa,GAAE,KAAK,EAAE;AAClC,UAAU,YAAA,GAAe,KAAK;AAC9B;AACA,QAAQ,eAAA,GAAkB,YAAY;AACtC;AACA,WAAW;AACX,MAAM,eAAA,IAAmB,CAAC;;AAE1B,MAAM,IAAI,eAAgB,KAAI,CAAC,EAAE;AACjC,QAAQ,MAAM,EAAE;AAChB;AACA;;AAEA,IAAI,KAAA,GAAQ,CAAC;AACb,GAAG,EAAE,IAAK,CAAC,CAAC,KAAK,EAAE;;AAEnB,EAAE,OAAO,MAAM;AACf,IAAI,KAAA,IAAS,CAAC;AACd,GAAG;AACH;;AAEA;;AASA;AACO,SAAS,WAAW,CAAC,IAAI,EAA+B;AAC/D,EAAE,OAAO,IAAK,KAAI,cAAc,IAAI,CAAC,MAAA,KAAW,CAAE,IAAG,SAAS,GAAA,IAAO,IAAK,KAAI,aAAa,CAAC;AAC5F;;AAEA;AACO,SAAS,kBAAkB,CAAC,CAAC,EAAsB,CAAC,EAA+B;AAC1F,EAAE,OAAO,CAAE,KAAI,CAAE,IAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA,KAAA,CAAA,IAAA,CAAA,KAAA,CAAA,OAAA,EAAA,CAAA,CAAA,CAAA,KAAA,WAAA,CAAA,CAAA,CAAA,IAAA,WAAA,CAAA,CAAA,CAAA,CAAA;AACA;;;;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const nodeVersion = require('../../nodeVersion.js');
|
|
4
|
+
const localVariablesAsync = require('./local-variables-async.js');
|
|
5
|
+
const localVariablesSync = require('./local-variables-sync.js');
|
|
6
|
+
|
|
7
|
+
const localVariablesIntegration = (options = {}) => {
|
|
8
|
+
return nodeVersion.NODE_VERSION.major < 19 ? localVariablesSync.localVariablesSyncIntegration(options) : localVariablesAsync.localVariablesAsyncIntegration(options);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.localVariablesIntegration = localVariablesIntegration;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/local-variables/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { NODE_VERSION } from '../../nodeVersion';\nimport type { LocalVariablesIntegrationOptions } from './common';\nimport { localVariablesAsyncIntegration } from './local-variables-async';\nimport { localVariablesSyncIntegration } from './local-variables-sync';\n\nexport const localVariablesIntegration = (options: LocalVariablesIntegrationOptions = {}): Integration => {\n return NODE_VERSION.major < 19 ? localVariablesSyncIntegration(options) : localVariablesAsyncIntegration(options);\n};\n"],"names":["NODE_VERSION","localVariablesSyncIntegration","localVariablesAsyncIntegration"],"mappings":";;;;;;AAMO,MAAM,4BAA4B,CAAC,OAAO,GAAqC,EAAE,KAAkB;AAC1G,EAAE,OAAOA,wBAAY,CAAC,KAAA,GAAQ,EAAG,GAAEC,gDAA6B,CAAC,OAAO,CAAE,GAAEC,kDAA8B,CAAC,OAAO,CAAC;AACnH;;;;"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const node_worker_threads = require('node:worker_threads');
|
|
4
|
+
const core = require('@sentry/core');
|
|
5
|
+
const debug = require('../../utils/debug.js');
|
|
6
|
+
const common = require('./common.js');
|
|
7
|
+
|
|
8
|
+
// This string is a placeholder that gets overwritten with the worker code.
|
|
9
|
+
const base64WorkerScript = 'LyohIEBzZW50cnkvbm9kZSA5LjM1LjAgKDhkNTA4ZWYpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPSJ1bmRlZmluZWQiPT10eXBlb2YgX19TRU5UUllfREVCVUdfX3x8X19TRU5UUllfREVCVUdfXyxvPWdsb2JhbFRoaXMsaT0iOS4zNS4wIjtjb25zdCBhPVsiZGVidWciLCJpbmZvIiwid2FybiIsImVycm9yIiwibG9nIiwiYXNzZXJ0IiwidHJhY2UiXSxzPXt9O2Z1bmN0aW9uIGMoZSl7aWYoISgiY29uc29sZSJpbiBvKSlyZXR1cm4gZSgpO2NvbnN0IHQ9by5jb25zb2xlLG49e30saT1PYmplY3Qua2V5cyhzKTtpLmZvckVhY2goKGU9Pntjb25zdCBvPXNbZV07bltlXT10W2VdLHRbZV09b30pKTt0cnl7cmV0dXJuIGUoKX1maW5hbGx5e2kuZm9yRWFjaCgoZT0+e3RbZV09bltlXX0pKX19IWZ1bmN0aW9uKGUsdCxuPW8pe2NvbnN0IGE9bi5fX1NFTlRSWV9fPW4uX19TRU5UUllfX3x8e30scz1hW2ldPWFbaV18fHt9O3NbZV18fChzW2VdPX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bz0hMSE9PXUuY2FwdHVyZUFsbEV4Y2VwdGlvbnM7aWYoYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOm8/ImFsbCI6InVuY2F1Z2h0In0pLG8pe2NvbnN0IGU9dS5tYXhFeGNlcHRpb25zUGVyU2Vjb25kfHw1MDtwPWZ1bmN0aW9uKGUsdCxuKXtsZXQgbz0wLGk9NSxhPTA7cmV0dXJuIHNldEludGVydmFsKCgoKT0+ezA9PT1hP28+ZSYmKGkqPTIsbihpKSxpPjg2NDAwJiYoaT04NjQwMCksYT1pKTooYS09MSwwPT09YSYmdCgpKSxvPTB9KSwxZTMpLnVucmVmKCksKCk9PntvKz0xfX0oZSwoYXN5bmMoKT0+e2woIlJhdGUtbGltaXQgbGlmdGVkLiIpLGF3YWl0IHQucG9zdCgiRGVidWdnZXIuc2V0UGF1c2VPbkV4Y2VwdGlvbnMiLHtzdGF0ZToiYWxsIn0pfSksKGFzeW5jIGU9PntsKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pKX19KSgpLmNhdGNoKChlPT57bCgiRmFpbGVkIHRvIHN0YXJ0IGRlYnVnZ2VyIixlKX0pKSxzZXRJbnRlcnZhbCgoKCk9Pnt9KSwxZTQpOw==';
|
|
10
|
+
|
|
11
|
+
function log(...args) {
|
|
12
|
+
core.logger.log('[LocalVariables]', ...args);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Adds local variables to exception frames
|
|
17
|
+
*/
|
|
18
|
+
const localVariablesAsyncIntegration = core.defineIntegration(((
|
|
19
|
+
integrationOptions = {},
|
|
20
|
+
) => {
|
|
21
|
+
function addLocalVariablesToException(exception, localVariables) {
|
|
22
|
+
// Filter out frames where the function name is `new Promise` since these are in the error.stack frames
|
|
23
|
+
// but do not appear in the debugger call frames
|
|
24
|
+
const frames = (exception.stacktrace?.frames || []).filter(frame => frame.function !== 'new Promise');
|
|
25
|
+
|
|
26
|
+
for (let i = 0; i < frames.length; i++) {
|
|
27
|
+
// Sentry frames are in reverse order
|
|
28
|
+
const frameIndex = frames.length - i - 1;
|
|
29
|
+
|
|
30
|
+
const frameLocalVariables = localVariables[i];
|
|
31
|
+
const frame = frames[frameIndex];
|
|
32
|
+
|
|
33
|
+
if (!frame || !frameLocalVariables) {
|
|
34
|
+
// Drop out if we run out of frames to match up
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (
|
|
39
|
+
// We need to have vars to add
|
|
40
|
+
frameLocalVariables.vars === undefined ||
|
|
41
|
+
// We're not interested in frames that are not in_app because the vars are not relevant
|
|
42
|
+
frame.in_app === false ||
|
|
43
|
+
// The function names need to match
|
|
44
|
+
!common.functionNamesMatch(frame.function, frameLocalVariables.function)
|
|
45
|
+
) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
frame.vars = frameLocalVariables.vars;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function addLocalVariablesToEvent(event, hint) {
|
|
54
|
+
if (
|
|
55
|
+
hint.originalException &&
|
|
56
|
+
typeof hint.originalException === 'object' &&
|
|
57
|
+
common.LOCAL_VARIABLES_KEY in hint.originalException &&
|
|
58
|
+
Array.isArray(hint.originalException[common.LOCAL_VARIABLES_KEY])
|
|
59
|
+
) {
|
|
60
|
+
for (const exception of event.exception?.values || []) {
|
|
61
|
+
addLocalVariablesToException(exception, hint.originalException[common.LOCAL_VARIABLES_KEY]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
hint.originalException[common.LOCAL_VARIABLES_KEY] = undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return event;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function startInspector() {
|
|
71
|
+
// We load inspector dynamically because on some platforms Node is built without inspector support
|
|
72
|
+
const inspector = await import('node:inspector');
|
|
73
|
+
if (!inspector.url()) {
|
|
74
|
+
inspector.open(0);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function startWorker(options) {
|
|
79
|
+
const worker = new node_worker_threads.Worker(new URL(`data:application/javascript;base64,${base64WorkerScript}`), {
|
|
80
|
+
workerData: options,
|
|
81
|
+
// We don't want any Node args to be passed to the worker
|
|
82
|
+
execArgv: [],
|
|
83
|
+
env: { ...process.env, NODE_OPTIONS: undefined },
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
process.on('exit', () => {
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
88
|
+
worker.terminate();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
worker.once('error', (err) => {
|
|
92
|
+
log('Worker error', err);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
worker.once('exit', (code) => {
|
|
96
|
+
log('Worker exit', code);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Ensure this thread can't block app exit
|
|
100
|
+
worker.unref();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
name: 'LocalVariablesAsync',
|
|
105
|
+
async setup(client) {
|
|
106
|
+
const clientOptions = client.getOptions();
|
|
107
|
+
|
|
108
|
+
if (!clientOptions.includeLocalVariables) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (await debug.isDebuggerEnabled()) {
|
|
113
|
+
core.logger.warn('Local variables capture has been disabled because the debugger was already enabled');
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const options = {
|
|
118
|
+
...integrationOptions,
|
|
119
|
+
debug: core.logger.isEnabled(),
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
startInspector().then(
|
|
123
|
+
() => {
|
|
124
|
+
try {
|
|
125
|
+
startWorker(options);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
core.logger.error('Failed to start worker', e);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
e => {
|
|
131
|
+
core.logger.error('Failed to start inspector', e);
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
processEvent(event, hint) {
|
|
136
|
+
return addLocalVariablesToEvent(event, hint);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}) );
|
|
140
|
+
|
|
141
|
+
exports.base64WorkerScript = base64WorkerScript;
|
|
142
|
+
exports.localVariablesAsyncIntegration = localVariablesAsyncIntegration;
|
|
143
|
+
//# sourceMappingURL=local-variables-async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-variables-async.js","sources":["../../../../src/integrations/local-variables/local-variables-async.ts"],"sourcesContent":["import { Worker } from 'node:worker_threads';\nimport type { Event, EventHint, Exception, IntegrationFn } from '@sentry/core';\nimport { defineIntegration, logger } from '@sentry/core';\nimport type { NodeClient } from '../../sdk/client';\nimport { isDebuggerEnabled } from '../../utils/debug';\nimport type { FrameVariables, LocalVariablesIntegrationOptions, LocalVariablesWorkerArgs } from './common';\nimport { functionNamesMatch, LOCAL_VARIABLES_KEY } from './common';\n\n// This string is a placeholder that gets overwritten with the worker code.\nexport const base64WorkerScript = '###LocalVariablesWorkerScript###';\n\nfunction log(...args: unknown[]): void {\n logger.log('[LocalVariables]', ...args);\n}\n\n/**\n * Adds local variables to exception frames\n */\nexport const localVariablesAsyncIntegration = defineIntegration(((\n integrationOptions: LocalVariablesIntegrationOptions = {},\n) => {\n function addLocalVariablesToException(exception: Exception, localVariables: FrameVariables[]): void {\n // Filter out frames where the function name is `new Promise` since these are in the error.stack frames\n // but do not appear in the debugger call frames\n const frames = (exception.stacktrace?.frames || []).filter(frame => frame.function !== 'new Promise');\n\n for (let i = 0; i < frames.length; i++) {\n // Sentry frames are in reverse order\n const frameIndex = frames.length - i - 1;\n\n const frameLocalVariables = localVariables[i];\n const frame = frames[frameIndex];\n\n if (!frame || !frameLocalVariables) {\n // Drop out if we run out of frames to match up\n break;\n }\n\n if (\n // We need to have vars to add\n frameLocalVariables.vars === undefined ||\n // We're not interested in frames that are not in_app because the vars are not relevant\n frame.in_app === false ||\n // The function names need to match\n !functionNamesMatch(frame.function, frameLocalVariables.function)\n ) {\n continue;\n }\n\n frame.vars = frameLocalVariables.vars;\n }\n }\n\n function addLocalVariablesToEvent(event: Event, hint: EventHint): Event {\n if (\n hint.originalException &&\n typeof hint.originalException === 'object' &&\n LOCAL_VARIABLES_KEY in hint.originalException &&\n Array.isArray(hint.originalException[LOCAL_VARIABLES_KEY])\n ) {\n for (const exception of event.exception?.values || []) {\n addLocalVariablesToException(exception, hint.originalException[LOCAL_VARIABLES_KEY]);\n }\n\n hint.originalException[LOCAL_VARIABLES_KEY] = undefined;\n }\n\n return event;\n }\n\n async function startInspector(): Promise<void> {\n // We load inspector dynamically because on some platforms Node is built without inspector support\n const inspector = await import('node:inspector');\n if (!inspector.url()) {\n inspector.open(0);\n }\n }\n\n function startWorker(options: LocalVariablesWorkerArgs): void {\n const worker = new Worker(new URL(`data:application/javascript;base64,${base64WorkerScript}`), {\n workerData: options,\n // We don't want any Node args to be passed to the worker\n execArgv: [],\n env: { ...process.env, NODE_OPTIONS: undefined },\n });\n\n process.on('exit', () => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n worker.terminate();\n });\n\n worker.once('error', (err: Error) => {\n log('Worker error', err);\n });\n\n worker.once('exit', (code: number) => {\n log('Worker exit', code);\n });\n\n // Ensure this thread can't block app exit\n worker.unref();\n }\n\n return {\n name: 'LocalVariablesAsync',\n async setup(client: NodeClient) {\n const clientOptions = client.getOptions();\n\n if (!clientOptions.includeLocalVariables) {\n return;\n }\n\n if (await isDebuggerEnabled()) {\n logger.warn('Local variables capture has been disabled because the debugger was already enabled');\n return;\n }\n\n const options: LocalVariablesWorkerArgs = {\n ...integrationOptions,\n debug: logger.isEnabled(),\n };\n\n startInspector().then(\n () => {\n try {\n startWorker(options);\n } catch (e) {\n logger.error('Failed to start worker', e);\n }\n },\n e => {\n logger.error('Failed to start inspector', e);\n },\n );\n },\n processEvent(event: Event, hint: EventHint): Event {\n return addLocalVariablesToEvent(event, hint);\n },\n };\n}) satisfies IntegrationFn);\n"],"names":["logger","defineIntegration","functionNamesMatch","LOCAL_VARIABLES_KEY","Worker","isDebuggerEnabled"],"mappings":";;;;;;;AAQA;AACO,MAAM,kBAAmB,GAAE;;AAElC,SAAS,GAAG,CAAC,GAAG,IAAI,EAAmB;AACvC,EAAEA,WAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC;AACzC;;AAEA;AACA;AACA;AACa,MAAA,8BAAA,GAAiCC,sBAAiB,EAAE;AACjE,EAAE,kBAAkB,GAAqC,EAAE;AAC3D,KAAK;AACL,EAAE,SAAS,4BAA4B,CAAC,SAAS,EAAa,cAAc,EAA0B;AACtG;AACA;AACA,IAAI,MAAM,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,MAAA,IAAU,EAAE,EAAE,MAAM,CAAC,KAAM,IAAG,KAAK,CAAC,QAAA,KAAa,aAAa,CAAC;;AAEzG,IAAI,KAAK,IAAI,CAAA,GAAI,CAAC,EAAE,CAAE,GAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC5C;AACA,MAAM,MAAM,aAAa,MAAM,CAAC,MAAO,GAAE,CAAE,GAAE,CAAC;;AAE9C,MAAM,MAAM,mBAAoB,GAAE,cAAc,CAAC,CAAC,CAAC;AACnD,MAAM,MAAM,KAAM,GAAE,MAAM,CAAC,UAAU,CAAC;;AAEtC,MAAM,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE;AAC1C;AACA,QAAQ;AACR;;AAEA,MA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