@depup/sentry__node 10.44.0-depup.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/LICENSE +21 -0
- package/README.md +31 -0
- package/build/cjs/debug-build.js +11 -0
- package/build/cjs/debug-build.js.map +1 -0
- package/build/cjs/index.js +216 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/init.js +10 -0
- package/build/cjs/init.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/growthbook.js +12 -0
- package/build/cjs/integrations/featureFlagShims/growthbook.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/launchDarkly.js +43 -0
- package/build/cjs/integrations/featureFlagShims/launchDarkly.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/openFeature.js +55 -0
- package/build/cjs/integrations/featureFlagShims/openFeature.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/statsig.js +23 -0
- package/build/cjs/integrations/featureFlagShims/statsig.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/unleash.js +23 -0
- package/build/cjs/integrations/featureFlagShims/unleash.js.map +1 -0
- package/build/cjs/integrations/fs.js +142 -0
- package/build/cjs/integrations/fs.js.map +1 -0
- package/build/cjs/integrations/http.js +224 -0
- package/build/cjs/integrations/http.js.map +1 -0
- package/build/cjs/integrations/node-fetch.js +108 -0
- package/build/cjs/integrations/node-fetch.js.map +1 -0
- package/build/cjs/integrations/tracing/amqplib.js +47 -0
- package/build/cjs/integrations/tracing/amqplib.js.map +1 -0
- package/build/cjs/integrations/tracing/anthropic-ai/index.js +79 -0
- package/build/cjs/integrations/tracing/anthropic-ai/index.js.map +1 -0
- package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js +95 -0
- package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/connect.js +110 -0
- package/build/cjs/integrations/tracing/connect.js.map +1 -0
- package/build/cjs/integrations/tracing/dataloader.js +72 -0
- package/build/cjs/integrations/tracing/dataloader.js.map +1 -0
- package/build/cjs/integrations/tracing/express.js +166 -0
- package/build/cjs/integrations/tracing/express.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/index.js +270 -0
- package/build/cjs/integrations/tracing/fastify/index.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/v3/constants.js +23 -0
- package/build/cjs/integrations/tracing/fastify/v3/constants.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
- package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js +304 -0
- package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/v3/utils.js +135 -0
- package/build/cjs/integrations/tracing/fastify/v3/utils.js.map +1 -0
- package/build/cjs/integrations/tracing/firebase/firebase.js +50 -0
- package/build/cjs/integrations/tracing/firebase/firebase.js.map +1 -0
- package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js +44 -0
- package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js +297 -0
- package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -0
- package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js +265 -0
- package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js.map +1 -0
- package/build/cjs/integrations/tracing/genericPool.js +59 -0
- package/build/cjs/integrations/tracing/genericPool.js.map +1 -0
- package/build/cjs/integrations/tracing/google-genai/index.js +78 -0
- package/build/cjs/integrations/tracing/google-genai/index.js.map +1 -0
- package/build/cjs/integrations/tracing/google-genai/instrumentation.js +88 -0
- package/build/cjs/integrations/tracing/google-genai/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/graphql.js +127 -0
- package/build/cjs/integrations/tracing/graphql.js.map +1 -0
- package/build/cjs/integrations/tracing/hapi/index.js +135 -0
- package/build/cjs/integrations/tracing/hapi/index.js.map +1 -0
- package/build/cjs/integrations/tracing/hono/constants.js +15 -0
- package/build/cjs/integrations/tracing/hono/constants.js.map +1 -0
- package/build/cjs/integrations/tracing/hono/index.js +137 -0
- package/build/cjs/integrations/tracing/hono/index.js.map +1 -0
- package/build/cjs/integrations/tracing/hono/instrumentation.js +236 -0
- package/build/cjs/integrations/tracing/hono/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/index.js +110 -0
- package/build/cjs/integrations/tracing/index.js.map +1 -0
- package/build/cjs/integrations/tracing/kafka.js +48 -0
- package/build/cjs/integrations/tracing/kafka.js.map +1 -0
- package/build/cjs/integrations/tracing/knex.js +57 -0
- package/build/cjs/integrations/tracing/knex.js.map +1 -0
- package/build/cjs/integrations/tracing/koa.js +138 -0
- package/build/cjs/integrations/tracing/koa.js.map +1 -0
- package/build/cjs/integrations/tracing/langchain/index.js +116 -0
- package/build/cjs/integrations/tracing/langchain/index.js.map +1 -0
- package/build/cjs/integrations/tracing/langchain/instrumentation.js +220 -0
- package/build/cjs/integrations/tracing/langchain/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/langgraph/index.js +93 -0
- package/build/cjs/integrations/tracing/langgraph/index.js.map +1 -0
- package/build/cjs/integrations/tracing/langgraph/instrumentation.js +60 -0
- package/build/cjs/integrations/tracing/langgraph/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/lrumemoizer.js +37 -0
- package/build/cjs/integrations/tracing/lrumemoizer.js.map +1 -0
- package/build/cjs/integrations/tracing/mongo.js +93 -0
- package/build/cjs/integrations/tracing/mongo.js.map +1 -0
- package/build/cjs/integrations/tracing/mongoose.js +46 -0
- package/build/cjs/integrations/tracing/mongoose.js.map +1 -0
- package/build/cjs/integrations/tracing/mysql.js +38 -0
- package/build/cjs/integrations/tracing/mysql.js.map +1 -0
- package/build/cjs/integrations/tracing/mysql2.js +46 -0
- package/build/cjs/integrations/tracing/mysql2.js.map +1 -0
- package/build/cjs/integrations/tracing/openai/index.js +78 -0
- package/build/cjs/integrations/tracing/openai/index.js.map +1 -0
- package/build/cjs/integrations/tracing/openai/instrumentation.js +104 -0
- package/build/cjs/integrations/tracing/openai/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/postgres.js +48 -0
- package/build/cjs/integrations/tracing/postgres.js.map +1 -0
- package/build/cjs/integrations/tracing/postgresjs.js +378 -0
- package/build/cjs/integrations/tracing/postgresjs.js.map +1 -0
- package/build/cjs/integrations/tracing/prisma.js +203 -0
- package/build/cjs/integrations/tracing/prisma.js.map +1 -0
- package/build/cjs/integrations/tracing/redis.js +121 -0
- package/build/cjs/integrations/tracing/redis.js.map +1 -0
- package/build/cjs/integrations/tracing/tedious.js +67 -0
- package/build/cjs/integrations/tracing/tedious.js.map +1 -0
- package/build/cjs/integrations/tracing/vercelai/constants.js +6 -0
- package/build/cjs/integrations/tracing/vercelai/constants.js.map +1 -0
- package/build/cjs/integrations/tracing/vercelai/index.js +82 -0
- package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -0
- package/build/cjs/integrations/tracing/vercelai/instrumentation.js +274 -0
- package/build/cjs/integrations/tracing/vercelai/instrumentation.js.map +1 -0
- package/build/cjs/preload.js +21 -0
- package/build/cjs/preload.js.map +1 -0
- package/build/cjs/sdk/index.js +78 -0
- package/build/cjs/sdk/index.js.map +1 -0
- package/build/cjs/sdk/initOtel.js +126 -0
- package/build/cjs/sdk/initOtel.js.map +1 -0
- package/build/cjs/utils/redisCache.js +122 -0
- package/build/cjs/utils/redisCache.js.map +1 -0
- package/build/esm/debug-build.js +9 -0
- package/build/esm/debug-build.js.map +1 -0
- package/build/esm/index.js +44 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/init.js +10 -0
- package/build/esm/init.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/growthbook.js +10 -0
- package/build/esm/integrations/featureFlagShims/growthbook.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/launchDarkly.js +40 -0
- package/build/esm/integrations/featureFlagShims/launchDarkly.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/openFeature.js +52 -0
- package/build/esm/integrations/featureFlagShims/openFeature.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/statsig.js +21 -0
- package/build/esm/integrations/featureFlagShims/statsig.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/unleash.js +21 -0
- package/build/esm/integrations/featureFlagShims/unleash.js.map +1 -0
- package/build/esm/integrations/fs.js +140 -0
- package/build/esm/integrations/fs.js.map +1 -0
- package/build/esm/integrations/http.js +219 -0
- package/build/esm/integrations/http.js.map +1 -0
- package/build/esm/integrations/node-fetch.js +105 -0
- package/build/esm/integrations/node-fetch.js.map +1 -0
- package/build/esm/integrations/tracing/amqplib.js +44 -0
- package/build/esm/integrations/tracing/amqplib.js.map +1 -0
- package/build/esm/integrations/tracing/anthropic-ai/index.js +76 -0
- package/build/esm/integrations/tracing/anthropic-ai/index.js.map +1 -0
- package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js +93 -0
- package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/connect.js +106 -0
- package/build/esm/integrations/tracing/connect.js.map +1 -0
- package/build/esm/integrations/tracing/dataloader.js +69 -0
- package/build/esm/integrations/tracing/dataloader.js.map +1 -0
- package/build/esm/integrations/tracing/express.js +161 -0
- package/build/esm/integrations/tracing/express.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/index.js +265 -0
- package/build/esm/integrations/tracing/fastify/index.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/v3/constants.js +21 -0
- package/build/esm/integrations/tracing/fastify/v3/constants.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
- package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/v3/instrumentation.js +302 -0
- package/build/esm/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/v3/utils.js +131 -0
- package/build/esm/integrations/tracing/fastify/v3/utils.js.map +1 -0
- package/build/esm/integrations/tracing/firebase/firebase.js +47 -0
- package/build/esm/integrations/tracing/firebase/firebase.js.map +1 -0
- package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js +42 -0
- package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js +294 -0
- package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -0
- package/build/esm/integrations/tracing/firebase/otel/patches/functions.js +262 -0
- package/build/esm/integrations/tracing/firebase/otel/patches/functions.js.map +1 -0
- package/build/esm/integrations/tracing/genericPool.js +56 -0
- package/build/esm/integrations/tracing/genericPool.js.map +1 -0
- package/build/esm/integrations/tracing/google-genai/index.js +75 -0
- package/build/esm/integrations/tracing/google-genai/index.js.map +1 -0
- package/build/esm/integrations/tracing/google-genai/instrumentation.js +86 -0
- package/build/esm/integrations/tracing/google-genai/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/graphql.js +124 -0
- package/build/esm/integrations/tracing/graphql.js.map +1 -0
- package/build/esm/integrations/tracing/hapi/index.js +130 -0
- package/build/esm/integrations/tracing/hapi/index.js.map +1 -0
- package/build/esm/integrations/tracing/hono/constants.js +12 -0
- package/build/esm/integrations/tracing/hono/constants.js.map +1 -0
- package/build/esm/integrations/tracing/hono/index.js +133 -0
- package/build/esm/integrations/tracing/hono/index.js.map +1 -0
- package/build/esm/integrations/tracing/hono/instrumentation.js +234 -0
- package/build/esm/integrations/tracing/hono/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/index.js +107 -0
- package/build/esm/integrations/tracing/index.js.map +1 -0
- package/build/esm/integrations/tracing/kafka.js +45 -0
- package/build/esm/integrations/tracing/kafka.js.map +1 -0
- package/build/esm/integrations/tracing/knex.js +54 -0
- package/build/esm/integrations/tracing/knex.js.map +1 -0
- package/build/esm/integrations/tracing/koa.js +134 -0
- package/build/esm/integrations/tracing/koa.js.map +1 -0
- package/build/esm/integrations/tracing/langchain/index.js +113 -0
- package/build/esm/integrations/tracing/langchain/index.js.map +1 -0
- package/build/esm/integrations/tracing/langchain/instrumentation.js +218 -0
- package/build/esm/integrations/tracing/langchain/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/langgraph/index.js +90 -0
- package/build/esm/integrations/tracing/langgraph/index.js.map +1 -0
- package/build/esm/integrations/tracing/langgraph/instrumentation.js +58 -0
- package/build/esm/integrations/tracing/langgraph/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/lrumemoizer.js +34 -0
- package/build/esm/integrations/tracing/lrumemoizer.js.map +1 -0
- package/build/esm/integrations/tracing/mongo.js +89 -0
- package/build/esm/integrations/tracing/mongo.js.map +1 -0
- package/build/esm/integrations/tracing/mongoose.js +43 -0
- package/build/esm/integrations/tracing/mongoose.js.map +1 -0
- package/build/esm/integrations/tracing/mysql.js +35 -0
- package/build/esm/integrations/tracing/mysql.js.map +1 -0
- package/build/esm/integrations/tracing/mysql2.js +43 -0
- package/build/esm/integrations/tracing/mysql2.js.map +1 -0
- package/build/esm/integrations/tracing/openai/index.js +75 -0
- package/build/esm/integrations/tracing/openai/index.js.map +1 -0
- package/build/esm/integrations/tracing/openai/instrumentation.js +102 -0
- package/build/esm/integrations/tracing/openai/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/postgres.js +45 -0
- package/build/esm/integrations/tracing/postgres.js.map +1 -0
- package/build/esm/integrations/tracing/postgresjs.js +374 -0
- package/build/esm/integrations/tracing/postgresjs.js.map +1 -0
- package/build/esm/integrations/tracing/prisma.js +200 -0
- package/build/esm/integrations/tracing/prisma.js.map +1 -0
- package/build/esm/integrations/tracing/redis.js +117 -0
- package/build/esm/integrations/tracing/redis.js.map +1 -0
- package/build/esm/integrations/tracing/tedious.js +64 -0
- package/build/esm/integrations/tracing/tedious.js.map +1 -0
- package/build/esm/integrations/tracing/vercelai/constants.js +4 -0
- package/build/esm/integrations/tracing/vercelai/constants.js.map +1 -0
- package/build/esm/integrations/tracing/vercelai/index.js +79 -0
- package/build/esm/integrations/tracing/vercelai/index.js.map +1 -0
- package/build/esm/integrations/tracing/vercelai/instrumentation.js +269 -0
- package/build/esm/integrations/tracing/vercelai/instrumentation.js.map +1 -0
- package/build/esm/package.json +1 -0
- package/build/esm/preload.js +21 -0
- package/build/esm/preload.js.map +1 -0
- package/build/esm/sdk/index.js +73 -0
- package/build/esm/sdk/index.js.map +1 -0
- package/build/esm/sdk/initOtel.js +121 -0
- package/build/esm/sdk/initOtel.js.map +1 -0
- package/build/esm/utils/redisCache.js +114 -0
- package/build/esm/utils/redisCache.js.map +1 -0
- package/build/import-hook.mjs +5 -0
- package/build/loader-hook.mjs +1 -0
- package/build/types/debug-build.d.ts +7 -0
- package/build/types/debug-build.d.ts.map +1 -0
- package/build/types/index.d.ts +42 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/init.d.ts +2 -0
- package/build/types/init.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/growthbook.d.ts +6 -0
- package/build/types/integrations/featureFlagShims/growthbook.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/index.d.ts +6 -0
- package/build/types/integrations/featureFlagShims/index.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/launchDarkly.d.ts +10 -0
- package/build/types/integrations/featureFlagShims/launchDarkly.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/openFeature.d.ts +23 -0
- package/build/types/integrations/featureFlagShims/openFeature.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/statsig.d.ts +6 -0
- package/build/types/integrations/featureFlagShims/statsig.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/unleash.d.ts +6 -0
- package/build/types/integrations/featureFlagShims/unleash.d.ts.map +1 -0
- package/build/types/integrations/fs.d.ts +24 -0
- package/build/types/integrations/fs.d.ts.map +1 -0
- package/build/types/integrations/http.d.ts +136 -0
- package/build/types/integrations/http.d.ts.map +1 -0
- package/build/types/integrations/node-fetch.d.ts +36 -0
- package/build/types/integrations/node-fetch.d.ts.map +1 -0
- package/build/types/integrations/tracing/amqplib.d.ts +20 -0
- package/build/types/integrations/tracing/amqplib.d.ts.map +1 -0
- package/build/types/integrations/tracing/anthropic-ai/index.d.ts +59 -0
- package/build/types/integrations/tracing/anthropic-ai/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/anthropic-ai/instrumentation.d.ts +19 -0
- package/build/types/integrations/tracing/anthropic-ai/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/connect.d.ts +46 -0
- package/build/types/integrations/tracing/connect.d.ts.map +1 -0
- package/build/types/integrations/tracing/dataloader.d.ts +20 -0
- package/build/types/integrations/tracing/dataloader.d.ts.map +1 -0
- package/build/types/integrations/tracing/express.d.ts +72 -0
- package/build/types/integrations/tracing/express.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/index.d.ts +119 -0
- package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/types.d.ts +33 -0
- package/build/types/integrations/tracing/fastify/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/constants.d.ts +3 -0
- package/build/types/integrations/tracing/fastify/v3/constants.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
- package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
- package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
- package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/types.d.ts +21 -0
- package/build/types/integrations/tracing/fastify/v3/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/utils.d.ts +28 -0
- package/build/types/integrations/tracing/fastify/v3/utils.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/firebase.d.ts +6 -0
- package/build/types/integrations/tracing/firebase/firebase.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/index.d.ts +2 -0
- package/build/types/integrations/tracing/firebase/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +19 -0
- package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/index.d.ts +3 -0
- package/build/types/integrations/tracing/firebase/otel/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts +25 -0
- package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
- package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/types.d.ts +120 -0
- package/build/types/integrations/tracing/firebase/otel/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/genericPool.d.ts +20 -0
- package/build/types/integrations/tracing/genericPool.d.ts.map +1 -0
- package/build/types/integrations/tracing/google-genai/index.d.ts +59 -0
- package/build/types/integrations/tracing/google-genai/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/google-genai/instrumentation.d.ts +20 -0
- package/build/types/integrations/tracing/google-genai/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/graphql.d.ts +48 -0
- package/build/types/integrations/tracing/graphql.d.ts.map +1 -0
- package/build/types/integrations/tracing/hapi/index.d.ts +50 -0
- package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/hapi/types.d.ts +166 -0
- package/build/types/integrations/tracing/hapi/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/hono/constants.d.ts +11 -0
- package/build/types/integrations/tracing/hono/constants.d.ts.map +1 -0
- package/build/types/integrations/tracing/hono/index.d.ts +52 -0
- package/build/types/integrations/tracing/hono/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/hono/instrumentation.d.ts +55 -0
- package/build/types/integrations/tracing/hono/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/hono/types.d.ts +36 -0
- package/build/types/integrations/tracing/hono/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/index.d.ts +12 -0
- package/build/types/integrations/tracing/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/kafka.d.ts +19 -0
- package/build/types/integrations/tracing/kafka.d.ts.map +1 -0
- package/build/types/integrations/tracing/knex.d.ts +20 -0
- package/build/types/integrations/tracing/knex.d.ts.map +1 -0
- package/build/types/integrations/tracing/koa.d.ts +70 -0
- package/build/types/integrations/tracing/koa.d.ts.map +1 -0
- package/build/types/integrations/tracing/langchain/index.d.ts +97 -0
- package/build/types/integrations/tracing/langchain/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/langchain/instrumentation.d.ts +29 -0
- package/build/types/integrations/tracing/langchain/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/langgraph/index.d.ts +74 -0
- package/build/types/integrations/tracing/langgraph/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/langgraph/instrumentation.d.ts +19 -0
- package/build/types/integrations/tracing/langgraph/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/lrumemoizer.d.ts +19 -0
- package/build/types/integrations/tracing/lrumemoizer.d.ts.map +1 -0
- package/build/types/integrations/tracing/mongo.d.ts +24 -0
- package/build/types/integrations/tracing/mongo.d.ts.map +1 -0
- package/build/types/integrations/tracing/mongoose.d.ts +20 -0
- package/build/types/integrations/tracing/mongoose.d.ts.map +1 -0
- package/build/types/integrations/tracing/mysql.d.ts +20 -0
- package/build/types/integrations/tracing/mysql.d.ts.map +1 -0
- package/build/types/integrations/tracing/mysql2.d.ts +20 -0
- package/build/types/integrations/tracing/mysql2.d.ts.map +1 -0
- package/build/types/integrations/tracing/openai/index.d.ts +59 -0
- package/build/types/integrations/tracing/openai/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/openai/instrumentation.d.ts +26 -0
- package/build/types/integrations/tracing/openai/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/postgres.d.ts +24 -0
- package/build/types/integrations/tracing/postgres.d.ts.map +1 -0
- package/build/types/integrations/tracing/postgresjs.d.ts +101 -0
- package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -0
- package/build/types/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts +38 -0
- package/build/types/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts.map +1 -0
- package/build/types/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts +31 -0
- package/build/types/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts.map +1 -0
- package/build/types/integrations/tracing/prisma.d.ts +50 -0
- package/build/types/integrations/tracing/prisma.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis.d.ts +41 -0
- package/build/types/integrations/tracing/redis.d.ts.map +1 -0
- package/build/types/integrations/tracing/tedious.d.ts +20 -0
- package/build/types/integrations/tracing/tedious.d.ts.map +1 -0
- package/build/types/integrations/tracing/vercelai/constants.d.ts +2 -0
- package/build/types/integrations/tracing/vercelai/constants.d.ts.map +1 -0
- package/build/types/integrations/tracing/vercelai/index.d.ts +43 -0
- package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/vercelai/instrumentation.d.ts +56 -0
- package/build/types/integrations/tracing/vercelai/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/vercelai/types.d.ts +59 -0
- package/build/types/integrations/tracing/vercelai/types.d.ts.map +1 -0
- package/build/types/preload.d.ts +2 -0
- package/build/types/preload.d.ts.map +1 -0
- package/build/types/sdk/index.d.ts +18 -0
- package/build/types/sdk/index.d.ts.map +1 -0
- package/build/types/sdk/initOtel.d.ts +28 -0
- package/build/types/sdk/initOtel.d.ts.map +1 -0
- package/build/types/types.d.ts +89 -0
- package/build/types/types.d.ts.map +1 -0
- package/build/types/utils/redisCache.d.ts +16 -0
- package/build/types/utils/redisCache.d.ts.map +1 -0
- package/build/types-ts3.8/debug-build.d.ts +7 -0
- package/build/types-ts3.8/index.d.ts +42 -0
- package/build/types-ts3.8/init.d.ts +2 -0
- package/build/types-ts3.8/integrations/featureFlagShims/growthbook.d.ts +6 -0
- package/build/types-ts3.8/integrations/featureFlagShims/index.d.ts +6 -0
- package/build/types-ts3.8/integrations/featureFlagShims/launchDarkly.d.ts +10 -0
- package/build/types-ts3.8/integrations/featureFlagShims/openFeature.d.ts +23 -0
- package/build/types-ts3.8/integrations/featureFlagShims/statsig.d.ts +6 -0
- package/build/types-ts3.8/integrations/featureFlagShims/unleash.d.ts +6 -0
- package/build/types-ts3.8/integrations/fs.d.ts +24 -0
- package/build/types-ts3.8/integrations/http.d.ts +139 -0
- package/build/types-ts3.8/integrations/node-fetch.d.ts +36 -0
- package/build/types-ts3.8/integrations/tracing/amqplib.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/anthropic-ai/index.d.ts +59 -0
- package/build/types-ts3.8/integrations/tracing/anthropic-ai/instrumentation.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/connect.d.ts +46 -0
- package/build/types-ts3.8/integrations/tracing/dataloader.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/express.d.ts +72 -0
- package/build/types-ts3.8/integrations/tracing/fastify/index.d.ts +119 -0
- package/build/types-ts3.8/integrations/tracing/fastify/types.d.ts +33 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/constants.d.ts +3 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/types.d.ts +21 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/utils.d.ts +28 -0
- package/build/types-ts3.8/integrations/tracing/firebase/firebase.d.ts +6 -0
- package/build/types-ts3.8/integrations/tracing/firebase/index.d.ts +2 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/index.d.ts +3 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/firestore.d.ts +25 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/types.d.ts +120 -0
- package/build/types-ts3.8/integrations/tracing/genericPool.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/google-genai/index.d.ts +59 -0
- package/build/types-ts3.8/integrations/tracing/google-genai/instrumentation.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/graphql.d.ts +48 -0
- package/build/types-ts3.8/integrations/tracing/hapi/index.d.ts +50 -0
- package/build/types-ts3.8/integrations/tracing/hapi/types.d.ts +166 -0
- package/build/types-ts3.8/integrations/tracing/hono/constants.d.ts +11 -0
- package/build/types-ts3.8/integrations/tracing/hono/index.d.ts +52 -0
- package/build/types-ts3.8/integrations/tracing/hono/instrumentation.d.ts +55 -0
- package/build/types-ts3.8/integrations/tracing/hono/types.d.ts +36 -0
- package/build/types-ts3.8/integrations/tracing/index.d.ts +12 -0
- package/build/types-ts3.8/integrations/tracing/kafka.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/knex.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/koa.d.ts +70 -0
- package/build/types-ts3.8/integrations/tracing/langchain/index.d.ts +97 -0
- package/build/types-ts3.8/integrations/tracing/langchain/instrumentation.d.ts +29 -0
- package/build/types-ts3.8/integrations/tracing/langgraph/index.d.ts +74 -0
- package/build/types-ts3.8/integrations/tracing/langgraph/instrumentation.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/lrumemoizer.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/mongo.d.ts +24 -0
- package/build/types-ts3.8/integrations/tracing/mongoose.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/mysql.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/mysql2.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/openai/index.d.ts +59 -0
- package/build/types-ts3.8/integrations/tracing/openai/instrumentation.d.ts +26 -0
- package/build/types-ts3.8/integrations/tracing/postgres.d.ts +24 -0
- package/build/types-ts3.8/integrations/tracing/postgresjs.d.ts +101 -0
- package/build/types-ts3.8/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts +44 -0
- package/build/types-ts3.8/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts +34 -0
- package/build/types-ts3.8/integrations/tracing/prisma.d.ts +50 -0
- package/build/types-ts3.8/integrations/tracing/redis.d.ts +41 -0
- package/build/types-ts3.8/integrations/tracing/tedious.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/vercelai/constants.d.ts +2 -0
- package/build/types-ts3.8/integrations/tracing/vercelai/index.d.ts +43 -0
- package/build/types-ts3.8/integrations/tracing/vercelai/instrumentation.d.ts +56 -0
- package/build/types-ts3.8/integrations/tracing/vercelai/types.d.ts +59 -0
- package/build/types-ts3.8/preload.d.ts +2 -0
- package/build/types-ts3.8/sdk/index.d.ts +18 -0
- package/build/types-ts3.8/sdk/initOtel.d.ts +31 -0
- package/build/types-ts3.8/types.d.ts +89 -0
- package/build/types-ts3.8/utils/redisCache.d.ts +16 -0
- package/changes.json +10 -0
- package/package.json +150 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { MySQL2Instrumentation } from '@opentelemetry/instrumentation-mysql2';
|
|
2
|
+
import { defineIntegration } from '@sentry/core';
|
|
3
|
+
import { generateInstrumentOnce, addOriginToSpan } from '@sentry/node-core';
|
|
4
|
+
|
|
5
|
+
const INTEGRATION_NAME = 'Mysql2';
|
|
6
|
+
|
|
7
|
+
const instrumentMysql2 = generateInstrumentOnce(
|
|
8
|
+
INTEGRATION_NAME,
|
|
9
|
+
() =>
|
|
10
|
+
new MySQL2Instrumentation({
|
|
11
|
+
responseHook(span) {
|
|
12
|
+
addOriginToSpan(span, 'auto.db.otel.mysql2');
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const _mysql2Integration = (() => {
|
|
18
|
+
return {
|
|
19
|
+
name: INTEGRATION_NAME,
|
|
20
|
+
setupOnce() {
|
|
21
|
+
instrumentMysql2();
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}) ;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.
|
|
28
|
+
*
|
|
29
|
+
* For more information, see the [`mysql2Integration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```javascript
|
|
33
|
+
* const Sentry = require('@sentry/node');
|
|
34
|
+
*
|
|
35
|
+
* Sentry.init({
|
|
36
|
+
* integrations: [Sentry.mysqlIntegration()],
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
const mysql2Integration = defineIntegration(_mysql2Integration);
|
|
41
|
+
|
|
42
|
+
export { instrumentMysql2, mysql2Integration };
|
|
43
|
+
//# sourceMappingURL=mysql2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql2.js","sources":["../../../../src/integrations/tracing/mysql2.ts"],"sourcesContent":["import { MySQL2Instrumentation } from '@opentelemetry/instrumentation-mysql2';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Mysql2';\n\nexport const instrumentMysql2 = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n new MySQL2Instrumentation({\n responseHook(span) {\n addOriginToSpan(span, 'auto.db.otel.mysql2');\n },\n }),\n);\n\nconst _mysql2Integration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentMysql2();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.\n *\n * For more information, see the [`mysql2Integration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.mysqlIntegration()],\n * });\n * ```\n */\nexport const mysql2Integration = defineIntegration(_mysql2Integration);\n"],"names":[],"mappings":";;;;AAKA,MAAM,gBAAA,GAAmB,QAAQ;;AAE1B,MAAM,gBAAA,GAAmB,sBAAsB;AACtD,EAAE,gBAAgB;AAClB,EAAE;AACF,IAAI,IAAI,qBAAqB,CAAC;AAC9B,MAAM,YAAY,CAAC,IAAI,EAAE;AACzB,QAAQ,eAAe,CAAC,IAAI,EAAE,qBAAqB,CAAC;AACpD,MAAM,CAAC;AACP,KAAK,CAAC;AACN;;AAEA,MAAM,kBAAA,IAAsB,MAAM;AAClC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,gBAAgB,EAAE;AACxB,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,iBAAA,GAAoB,iBAAiB,CAAC,kBAAkB;;;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { OPENAI_INTEGRATION_NAME, defineIntegration } from '@sentry/core';
|
|
2
|
+
import { generateInstrumentOnce } from '@sentry/node-core';
|
|
3
|
+
import { SentryOpenAiInstrumentation } from './instrumentation.js';
|
|
4
|
+
|
|
5
|
+
const instrumentOpenAi = generateInstrumentOnce(
|
|
6
|
+
OPENAI_INTEGRATION_NAME,
|
|
7
|
+
options => new SentryOpenAiInstrumentation(options),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const _openAiIntegration = ((options = {}) => {
|
|
11
|
+
return {
|
|
12
|
+
name: OPENAI_INTEGRATION_NAME,
|
|
13
|
+
setupOnce() {
|
|
14
|
+
instrumentOpenAi(options);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}) ;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Adds Sentry tracing instrumentation for the OpenAI SDK.
|
|
21
|
+
*
|
|
22
|
+
* This integration is enabled by default.
|
|
23
|
+
*
|
|
24
|
+
* When configured, this integration automatically instruments OpenAI SDK client instances
|
|
25
|
+
* to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```javascript
|
|
29
|
+
* import * as Sentry from '@sentry/node';
|
|
30
|
+
*
|
|
31
|
+
* Sentry.init({
|
|
32
|
+
* integrations: [Sentry.openAIIntegration()],
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ## Options
|
|
37
|
+
*
|
|
38
|
+
* - `recordInputs`: Whether to record prompt messages (default: respects `sendDefaultPii` client option)
|
|
39
|
+
* - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)
|
|
40
|
+
*
|
|
41
|
+
* ### Default Behavior
|
|
42
|
+
*
|
|
43
|
+
* By default, the integration will:
|
|
44
|
+
* - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options
|
|
45
|
+
* - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```javascript
|
|
49
|
+
* // Record inputs and outputs when sendDefaultPii is false
|
|
50
|
+
* Sentry.init({
|
|
51
|
+
* integrations: [
|
|
52
|
+
* Sentry.openAIIntegration({
|
|
53
|
+
* recordInputs: true,
|
|
54
|
+
* recordOutputs: true
|
|
55
|
+
* })
|
|
56
|
+
* ],
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // Never record inputs/outputs regardless of sendDefaultPii
|
|
60
|
+
* Sentry.init({
|
|
61
|
+
* sendDefaultPii: true,
|
|
62
|
+
* integrations: [
|
|
63
|
+
* Sentry.openAIIntegration({
|
|
64
|
+
* recordInputs: false,
|
|
65
|
+
* recordOutputs: false
|
|
66
|
+
* })
|
|
67
|
+
* ],
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
const openAIIntegration = defineIntegration(_openAiIntegration);
|
|
73
|
+
|
|
74
|
+
export { instrumentOpenAi, openAIIntegration };
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/openai/index.ts"],"sourcesContent":["import type { IntegrationFn, OpenAiOptions } from '@sentry/core';\nimport { defineIntegration, OPENAI_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryOpenAiInstrumentation } from './instrumentation';\n\nexport const instrumentOpenAi = generateInstrumentOnce<OpenAiOptions>(\n OPENAI_INTEGRATION_NAME,\n options => new SentryOpenAiInstrumentation(options),\n);\n\nconst _openAiIntegration = ((options: OpenAiOptions = {}) => {\n return {\n name: OPENAI_INTEGRATION_NAME,\n setupOnce() {\n instrumentOpenAi(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the OpenAI SDK.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments OpenAI SDK client instances\n * to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.init({\n * integrations: [Sentry.openAIIntegration()],\n * });\n * ```\n *\n * ## Options\n *\n * - `recordInputs`: Whether to record prompt messages (default: respects `sendDefaultPii` client option)\n * - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)\n *\n * ### Default Behavior\n *\n * By default, the integration will:\n * - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options\n * - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled\n *\n * @example\n * ```javascript\n * // Record inputs and outputs when sendDefaultPii is false\n * Sentry.init({\n * integrations: [\n * Sentry.openAIIntegration({\n * recordInputs: true,\n * recordOutputs: true\n * })\n * ],\n * });\n *\n * // Never record inputs/outputs regardless of sendDefaultPii\n * Sentry.init({\n * sendDefaultPii: true,\n * integrations: [\n * Sentry.openAIIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n */\nexport const openAIIntegration = defineIntegration(_openAiIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,gBAAA,GAAmB,sBAAsB;AACtD,EAAE,uBAAuB;AACzB,EAAE,WAAW,IAAI,2BAA2B,CAAC,OAAO,CAAC;AACrD;;AAEA,MAAM,kBAAA,IAAsB,CAAC,OAAO,GAAkB,EAAE,KAAK;AAC7D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,uBAAuB;AACjC,IAAI,SAAS,GAAG;AAChB,MAAM,gBAAgB,CAAC,OAAO,CAAC;AAC/B,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,iBAAA,GAAoB,iBAAiB,CAAC,kBAAkB;;;;"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { SDK_VERSION, _INTERNAL_shouldSkipAiProviderWrapping, OPENAI_INTEGRATION_NAME, instrumentOpenAiClient } from '@sentry/core';
|
|
3
|
+
|
|
4
|
+
const supportedVersions = ['>=4.0.0 <7'];
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sentry OpenAI instrumentation using OpenTelemetry.
|
|
8
|
+
*/
|
|
9
|
+
class SentryOpenAiInstrumentation extends InstrumentationBase {
|
|
10
|
+
constructor(config = {}) {
|
|
11
|
+
super('@sentry/instrumentation-openai', SDK_VERSION, config);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Initializes the instrumentation by defining the modules to be patched.
|
|
16
|
+
*/
|
|
17
|
+
init() {
|
|
18
|
+
const module = new InstrumentationNodeModuleDefinition('openai', supportedVersions, this._patch.bind(this));
|
|
19
|
+
return module;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors.
|
|
24
|
+
*/
|
|
25
|
+
_patch(exports$1) {
|
|
26
|
+
let result = exports$1;
|
|
27
|
+
result = this._patchClient(result, 'OpenAI');
|
|
28
|
+
result = this._patchClient(result, 'AzureOpenAI');
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Patch logic applying instrumentation to the specified client constructor.
|
|
34
|
+
*/
|
|
35
|
+
_patchClient(exports$1, exportKey) {
|
|
36
|
+
const Original = exports$1[exportKey];
|
|
37
|
+
if (!Original) {
|
|
38
|
+
return exports$1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const config = this.getConfig();
|
|
42
|
+
|
|
43
|
+
const WrappedOpenAI = function ( ...args) {
|
|
44
|
+
// Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)
|
|
45
|
+
if (_INTERNAL_shouldSkipAiProviderWrapping(OPENAI_INTEGRATION_NAME)) {
|
|
46
|
+
return Reflect.construct(Original, args) ;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const instance = Reflect.construct(Original, args);
|
|
50
|
+
|
|
51
|
+
return instrumentOpenAiClient(instance , config);
|
|
52
|
+
} ;
|
|
53
|
+
|
|
54
|
+
// Preserve static and prototype chains
|
|
55
|
+
Object.setPrototypeOf(WrappedOpenAI, Original);
|
|
56
|
+
Object.setPrototypeOf(WrappedOpenAI.prototype, Original.prototype);
|
|
57
|
+
|
|
58
|
+
for (const key of Object.getOwnPropertyNames(Original)) {
|
|
59
|
+
if (!['length', 'name', 'prototype'].includes(key)) {
|
|
60
|
+
const descriptor = Object.getOwnPropertyDescriptor(Original, key);
|
|
61
|
+
if (descriptor) {
|
|
62
|
+
Object.defineProperty(WrappedOpenAI, key, descriptor);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Constructor replacement - handle read-only properties
|
|
68
|
+
// The OpenAI property might have only a getter, so use defineProperty
|
|
69
|
+
try {
|
|
70
|
+
exports$1[exportKey] = WrappedOpenAI;
|
|
71
|
+
} catch {
|
|
72
|
+
// If direct assignment fails, override the property descriptor
|
|
73
|
+
Object.defineProperty(exports$1, exportKey, {
|
|
74
|
+
value: WrappedOpenAI,
|
|
75
|
+
writable: true,
|
|
76
|
+
configurable: true,
|
|
77
|
+
enumerable: true,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Wrap the default export if it points to the original constructor
|
|
82
|
+
// Constructor replacement - handle read-only properties
|
|
83
|
+
// The OpenAI property might have only a getter, so use defineProperty
|
|
84
|
+
if (exports$1.default === Original) {
|
|
85
|
+
try {
|
|
86
|
+
exports$1.default = WrappedOpenAI;
|
|
87
|
+
} catch {
|
|
88
|
+
// If direct assignment fails, override the property descriptor
|
|
89
|
+
Object.defineProperty(exports$1, 'default', {
|
|
90
|
+
value: WrappedOpenAI,
|
|
91
|
+
writable: true,
|
|
92
|
+
configurable: true,
|
|
93
|
+
enumerable: true,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return exports$1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { SentryOpenAiInstrumentation };
|
|
102
|
+
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/openai/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport type { Integration, OpenAiClient, OpenAiOptions } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n instrumentOpenAiClient,\n OPENAI_INTEGRATION_NAME,\n SDK_VERSION,\n} from '@sentry/core';\n\nconst supportedVersions = ['>=4.0.0 <7'];\n\nexport interface OpenAiIntegration extends Integration {\n options: OpenAiOptions;\n}\n\ntype OpenAiInstrumentationOptions = InstrumentationConfig & OpenAiOptions;\n\n/**\n * Represents the patched shape of the OpenAI module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n OpenAI: abstract new (...args: unknown[]) => OpenAiClient;\n AzureOpenAI?: abstract new (...args: unknown[]) => OpenAiClient;\n}\n\n/**\n * Sentry OpenAI instrumentation using OpenTelemetry.\n */\nexport class SentryOpenAiInstrumentation extends InstrumentationBase<OpenAiInstrumentationOptions> {\n public constructor(config: OpenAiInstrumentationOptions = {}) {\n super('@sentry/instrumentation-openai', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n */\n public init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition('openai', supportedVersions, this._patch.bind(this));\n return module;\n }\n\n /**\n * Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors.\n */\n private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {\n let result = exports;\n result = this._patchClient(result, 'OpenAI');\n result = this._patchClient(result, 'AzureOpenAI');\n return result;\n }\n\n /**\n * Patch logic applying instrumentation to the specified client constructor.\n */\n private _patchClient(exports: PatchedModuleExports, exportKey: 'OpenAI' | 'AzureOpenAI'): PatchedModuleExports {\n const Original = exports[exportKey];\n if (!Original) {\n return exports;\n }\n\n const config = this.getConfig();\n\n const WrappedOpenAI = function (this: unknown, ...args: unknown[]) {\n // Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)\n if (_INTERNAL_shouldSkipAiProviderWrapping(OPENAI_INTEGRATION_NAME)) {\n return Reflect.construct(Original, args) as OpenAiClient;\n }\n\n const instance = Reflect.construct(Original, args);\n\n return instrumentOpenAiClient(instance as OpenAiClient, config);\n } as unknown as abstract new (...args: unknown[]) => OpenAiClient;\n\n // Preserve static and prototype chains\n Object.setPrototypeOf(WrappedOpenAI, Original);\n Object.setPrototypeOf(WrappedOpenAI.prototype, Original.prototype);\n\n for (const key of Object.getOwnPropertyNames(Original)) {\n if (!['length', 'name', 'prototype'].includes(key)) {\n const descriptor = Object.getOwnPropertyDescriptor(Original, key);\n if (descriptor) {\n Object.defineProperty(WrappedOpenAI, key, descriptor);\n }\n }\n }\n\n // Constructor replacement - handle read-only properties\n // The OpenAI property might have only a getter, so use defineProperty\n try {\n exports[exportKey] = WrappedOpenAI;\n } catch {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, exportKey, {\n value: WrappedOpenAI,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n\n // Wrap the default export if it points to the original constructor\n // Constructor replacement - handle read-only properties\n // The OpenAI property might have only a getter, so use defineProperty\n if (exports.default === Original) {\n try {\n exports.default = WrappedOpenAI;\n } catch {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, 'default', {\n value: WrappedOpenAI,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n }\n return exports;\n }\n}\n"],"names":["exports"],"mappings":";;;AAcA,MAAM,iBAAA,GAAoB,CAAC,YAAY,CAAC;;AAiBxC;AACA;AACA;AACO,MAAM,2BAAA,SAAoC,mBAAmB,CAA+B;AACnG,GAAS,WAAW,CAAC,MAAM,GAAiC,EAAE,EAAE;AAChE,IAAI,KAAK,CAAC,gCAAgC,EAAE,WAAW,EAAE,MAAM,CAAC;AAChE,EAAE;;AAEF;AACA;AACA;AACA,GAAS,IAAI,GAAoC;AACjD,IAAI,MAAM,MAAA,GAAS,IAAI,mCAAmC,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/G,IAAI,OAAO,MAAM;AACjB,EAAE;;AAEF;AACA;AACA;AACA,GAAU,MAAM,CAACA,SAAO,EAAqD;AAC7E,IAAI,IAAI,MAAA,GAASA,SAAO;AACxB,IAAI,MAAA,GAAS,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC;AAChD,IAAI,MAAA,GAAS,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC;AACrD,IAAI,OAAO,MAAM;AACjB,EAAE;;AAEF;AACA;AACA;AACA,GAAU,YAAY,CAACA,SAAO,EAAwB,SAAS,EAAkD;AACjH,IAAI,MAAM,QAAA,GAAWA,SAAO,CAAC,SAAS,CAAC;AACvC,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,MAAM,OAAOA,SAAO;AACpB,IAAI;;AAEJ,IAAI,MAAM,MAAA,GAAS,IAAI,CAAC,SAAS,EAAE;;AAEnC,IAAI,MAAM,gBAAgB,WAAyB,GAAG,IAAI,EAAa;AACvE;AACA,MAAM,IAAI,sCAAsC,CAAC,uBAAuB,CAAC,EAAE;AAC3E,QAAQ,OAAO,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAA;AAC/C,MAAM;;AAEN,MAAM,MAAM,QAAA,GAAW,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC;;AAExD,MAAM,OAAO,sBAAsB,CAAC,QAAA,GAA0B,MAAM,CAAC;AACrE,IAAI,CAAA;;AAEJ;AACA,IAAI,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,QAAQ,CAAC;AAClD,IAAI,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC;;AAEtE,IAAI,KAAK,MAAM,GAAA,IAAO,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE;AAC5D,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAC1D,QAAQ,MAAM,UAAA,GAAa,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,GAAG,CAAC;AACzE,QAAQ,IAAI,UAAU,EAAE;AACxB,UAAU,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,GAAG,EAAE,UAAU,CAAC;AAC/D,QAAQ;AACR,MAAM;AACN,IAAI;;AAEJ;AACA;AACA,IAAI,IAAI;AACR,MAAMA,SAAO,CAAC,SAAS,CAAA,GAAI,aAAa;AACxC,IAAI,EAAE,MAAM;AACZ;AACA,MAAM,MAAM,CAAC,cAAc,CAACA,SAAO,EAAE,SAAS,EAAE;AAChD,QAAQ,KAAK,EAAE,aAAa;AAC5B,QAAQ,QAAQ,EAAE,IAAI;AACtB,QAAQ,YAAY,EAAE,IAAI;AAC1B,QAAQ,UAAU,EAAE,IAAI;AACxB,OAAO,CAAC;AACR,IAAI;;AAEJ;AACA;AACA;AACA,IAAI,IAAIA,SAAO,CAAC,OAAA,KAAY,QAAQ,EAAE;AACtC,MAAM,IAAI;AACV,QAAQA,SAAO,CAAC,OAAA,GAAU,aAAa;AACvC,MAAM,EAAE,MAAM;AACd;AACA,QAAQ,MAAM,CAAC,cAAc,CAACA,SAAO,EAAE,SAAS,EAAE;AAClD,UAAU,KAAK,EAAE,aAAa;AAC9B,UAAU,QAAQ,EAAE,IAAI;AACxB,UAAU,YAAY,EAAE,IAAI;AAC5B,UAAU,UAAU,EAAE,IAAI;AAC1B,SAAS,CAAC;AACV,MAAM;AACN,IAAI;AACJ,IAAI,OAAOA,SAAO;AAClB,EAAE;AACF;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';
|
|
2
|
+
import { defineIntegration } from '@sentry/core';
|
|
3
|
+
import { generateInstrumentOnce, addOriginToSpan } from '@sentry/node-core';
|
|
4
|
+
|
|
5
|
+
const INTEGRATION_NAME = 'Postgres';
|
|
6
|
+
|
|
7
|
+
const instrumentPostgres = generateInstrumentOnce(
|
|
8
|
+
INTEGRATION_NAME,
|
|
9
|
+
PgInstrumentation,
|
|
10
|
+
(options) => ({
|
|
11
|
+
requireParentSpan: true,
|
|
12
|
+
requestHook(span) {
|
|
13
|
+
addOriginToSpan(span, 'auto.db.otel.postgres');
|
|
14
|
+
},
|
|
15
|
+
ignoreConnectSpans: options?.ignoreConnectSpans ?? false,
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const _postgresIntegration = ((options) => {
|
|
20
|
+
return {
|
|
21
|
+
name: INTEGRATION_NAME,
|
|
22
|
+
setupOnce() {
|
|
23
|
+
instrumentPostgres(options);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}) ;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Adds Sentry tracing instrumentation for the [pg](https://www.npmjs.com/package/pg) library.
|
|
30
|
+
*
|
|
31
|
+
* For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```javascript
|
|
35
|
+
* const Sentry = require('@sentry/node');
|
|
36
|
+
*
|
|
37
|
+
* Sentry.init({
|
|
38
|
+
* integrations: [Sentry.postgresIntegration()],
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
const postgresIntegration = defineIntegration(_postgresIntegration);
|
|
43
|
+
|
|
44
|
+
export { instrumentPostgres, postgresIntegration };
|
|
45
|
+
//# sourceMappingURL=postgres.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.js","sources":["../../../../src/integrations/tracing/postgres.ts"],"sourcesContent":["import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\n\ninterface PostgresIntegrationOptions {\n ignoreConnectSpans?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Postgres';\n\nexport const instrumentPostgres = generateInstrumentOnce(\n INTEGRATION_NAME,\n PgInstrumentation,\n (options?: PostgresIntegrationOptions) => ({\n requireParentSpan: true,\n requestHook(span) {\n addOriginToSpan(span, 'auto.db.otel.postgres');\n },\n ignoreConnectSpans: options?.ignoreConnectSpans ?? false,\n }),\n);\n\nconst _postgresIntegration = ((options?: PostgresIntegrationOptions) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgres(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [pg](https://www.npmjs.com/package/pg) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresIntegration()],\n * });\n * ```\n */\nexport const postgresIntegration = defineIntegration(_postgresIntegration);\n"],"names":[],"mappings":";;;;AASA,MAAM,gBAAA,GAAmB,UAAU;;AAE5B,MAAM,kBAAA,GAAqB,sBAAsB;AACxD,EAAE,gBAAgB;AAClB,EAAE,iBAAiB;AACnB,EAAE,CAAC,OAAO,MAAmC;AAC7C,IAAI,iBAAiB,EAAE,IAAI;AAC3B,IAAI,WAAW,CAAC,IAAI,EAAE;AACtB,MAAM,eAAe,CAAC,IAAI,EAAE,uBAAuB,CAAC;AACpD,IAAI,CAAC;AACL,IAAI,kBAAkB,EAAE,OAAO,EAAE,kBAAA,IAAsB,KAAK;AAC5D,GAAG,CAAC;AACJ;;AAEA,MAAM,wBAAwB,CAAC,OAAO,KAAkC;AACxE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,kBAAkB,CAAC,OAAO,CAAC;AACjC,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,mBAAA,GAAsB,iBAAiB,CAAC,oBAAoB;;;;"}
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { trace, context } from '@opentelemetry/api';
|
|
2
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition, InstrumentationNodeModuleFile, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { ATTR_DB_OPERATION_NAME, ATTR_DB_QUERY_TEXT, ATTR_DB_SYSTEM_NAME, ATTR_DB_RESPONSE_STATUS_CODE, ATTR_ERROR_TYPE } from '@opentelemetry/semantic-conventions';
|
|
4
|
+
import { SDK_VERSION, debug, replaceExports, startSpanManual, SPAN_STATUS_ERROR, defineIntegration, instrumentPostgresJsSql } from '@sentry/core';
|
|
5
|
+
import { generateInstrumentOnce, addOriginToSpan } from '@sentry/node-core';
|
|
6
|
+
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
7
|
+
|
|
8
|
+
// Instrumentation for https://github.com/porsager/postgres
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const INTEGRATION_NAME = 'PostgresJs';
|
|
12
|
+
const SUPPORTED_VERSIONS = ['>=3.0.0 <4'];
|
|
13
|
+
const SQL_OPERATION_REGEX = /^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i;
|
|
14
|
+
|
|
15
|
+
// Marker to track if a query was created from an instrumented sql instance
|
|
16
|
+
// This prevents double-spanning when both wrapper and prototype patches are active
|
|
17
|
+
const QUERY_FROM_INSTRUMENTED_SQL = Symbol.for('sentry.query.from.instrumented.sql');
|
|
18
|
+
|
|
19
|
+
const instrumentPostgresJs = generateInstrumentOnce(
|
|
20
|
+
INTEGRATION_NAME,
|
|
21
|
+
(options) =>
|
|
22
|
+
new PostgresJsInstrumentation({
|
|
23
|
+
requireParentSpan: options?.requireParentSpan ?? true,
|
|
24
|
+
requestHook: options?.requestHook,
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.
|
|
30
|
+
* This instrumentation captures postgresjs queries and their attributes.
|
|
31
|
+
*
|
|
32
|
+
* Uses internal Sentry patching patterns to support both CommonJS and ESM environments.
|
|
33
|
+
*/
|
|
34
|
+
class PostgresJsInstrumentation extends InstrumentationBase {
|
|
35
|
+
constructor(config) {
|
|
36
|
+
super('sentry-postgres-js', SDK_VERSION, config);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Initializes the instrumentation by patching the postgres module.
|
|
41
|
+
* Uses two complementary approaches:
|
|
42
|
+
* 1. Main function wrapper: instruments sql instances created AFTER instrumentation is set up (CJS + ESM)
|
|
43
|
+
* 2. Query.prototype patch: fallback for sql instances created BEFORE instrumentation (CJS only)
|
|
44
|
+
*/
|
|
45
|
+
init() {
|
|
46
|
+
const module = new InstrumentationNodeModuleDefinition(
|
|
47
|
+
'postgres',
|
|
48
|
+
SUPPORTED_VERSIONS,
|
|
49
|
+
exports$1 => {
|
|
50
|
+
try {
|
|
51
|
+
return this._patchPostgres(exports$1);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
DEBUG_BUILD && debug.error('Failed to patch postgres module:', e);
|
|
54
|
+
return exports$1;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
exports$1 => exports$1,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Add fallback Query.prototype patching for pre-existing sql instances (CJS only)
|
|
61
|
+
// This catches queries from sql instances created before Sentry was initialized
|
|
62
|
+
['src', 'cf/src', 'cjs/src'].forEach(path => {
|
|
63
|
+
module.files.push(
|
|
64
|
+
new InstrumentationNodeModuleFile(
|
|
65
|
+
`postgres/${path}/query.js`,
|
|
66
|
+
SUPPORTED_VERSIONS,
|
|
67
|
+
this._patchQueryPrototype.bind(this),
|
|
68
|
+
this._unpatchQueryPrototype.bind(this),
|
|
69
|
+
),
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return module;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Patches the postgres module by wrapping the main export function.
|
|
78
|
+
* This intercepts the creation of sql instances and instruments them.
|
|
79
|
+
*/
|
|
80
|
+
_patchPostgres(exports$1) {
|
|
81
|
+
// In CJS: exports is the function itself
|
|
82
|
+
// In ESM: exports.default is the function
|
|
83
|
+
const isFunction = typeof exports$1 === 'function';
|
|
84
|
+
const Original = isFunction ? exports$1 : exports$1.default;
|
|
85
|
+
|
|
86
|
+
if (typeof Original !== 'function') {
|
|
87
|
+
DEBUG_BUILD && debug.warn('postgres module does not export a function. Skipping instrumentation.');
|
|
88
|
+
return exports$1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
92
|
+
const self = this;
|
|
93
|
+
|
|
94
|
+
const WrappedPostgres = function ( ...args) {
|
|
95
|
+
const sql = Reflect.construct(Original , args);
|
|
96
|
+
|
|
97
|
+
// Validate that construction succeeded and returned a valid function object
|
|
98
|
+
if (!sql || typeof sql !== 'function') {
|
|
99
|
+
DEBUG_BUILD && debug.warn('postgres() did not return a valid instance');
|
|
100
|
+
return sql;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Delegate to the portable instrumentation from @sentry/core
|
|
104
|
+
const config = self.getConfig();
|
|
105
|
+
return instrumentPostgresJsSql(sql, {
|
|
106
|
+
requireParentSpan: config.requireParentSpan,
|
|
107
|
+
requestHook: config.requestHook,
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
Object.setPrototypeOf(WrappedPostgres, Original);
|
|
112
|
+
Object.setPrototypeOf(WrappedPostgres.prototype, (Original ).prototype);
|
|
113
|
+
|
|
114
|
+
for (const key of Object.getOwnPropertyNames(Original)) {
|
|
115
|
+
if (!['length', 'name', 'prototype'].includes(key)) {
|
|
116
|
+
const descriptor = Object.getOwnPropertyDescriptor(Original, key);
|
|
117
|
+
if (descriptor) {
|
|
118
|
+
Object.defineProperty(WrappedPostgres, key, descriptor);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// For CJS: the exports object IS the function, so return the wrapped function
|
|
124
|
+
// For ESM: replace the default export
|
|
125
|
+
if (isFunction) {
|
|
126
|
+
return WrappedPostgres ;
|
|
127
|
+
} else {
|
|
128
|
+
replaceExports(exports$1, 'default', WrappedPostgres);
|
|
129
|
+
return exports$1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Determines whether a span should be created based on the current context.
|
|
135
|
+
* If `requireParentSpan` is set to true in the configuration, a span will
|
|
136
|
+
* only be created if there is a parent span available.
|
|
137
|
+
*/
|
|
138
|
+
_shouldCreateSpans() {
|
|
139
|
+
const config = this.getConfig();
|
|
140
|
+
const hasParentSpan = trace.getSpan(context.active()) !== undefined;
|
|
141
|
+
return hasParentSpan || !config.requireParentSpan;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Extracts DB operation name from SQL query and sets it on the span.
|
|
146
|
+
*/
|
|
147
|
+
_setOperationName(span, sanitizedQuery, command) {
|
|
148
|
+
if (command) {
|
|
149
|
+
span.setAttribute(ATTR_DB_OPERATION_NAME, command);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// Fallback: extract operation from the SQL query
|
|
153
|
+
const operationMatch = sanitizedQuery?.match(SQL_OPERATION_REGEX);
|
|
154
|
+
if (operationMatch?.[1]) {
|
|
155
|
+
span.setAttribute(ATTR_DB_OPERATION_NAME, operationMatch[1].toUpperCase());
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Reconstructs the full SQL query from template strings with PostgreSQL placeholders.
|
|
161
|
+
*
|
|
162
|
+
* For sql`SELECT * FROM users WHERE id = ${123} AND name = ${'foo'}`:
|
|
163
|
+
* strings = ["SELECT * FROM users WHERE id = ", " AND name = ", ""]
|
|
164
|
+
* returns: "SELECT * FROM users WHERE id = $1 AND name = $2"
|
|
165
|
+
*/
|
|
166
|
+
_reconstructQuery(strings) {
|
|
167
|
+
if (!strings?.length) {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
if (strings.length === 1) {
|
|
171
|
+
return strings[0] || undefined;
|
|
172
|
+
}
|
|
173
|
+
// Join template parts with PostgreSQL placeholders ($1, $2, etc.)
|
|
174
|
+
return strings.reduce((acc, str, i) => (i === 0 ? str : `${acc}$${i}${str}`), '');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Sanitize SQL query as per the OTEL semantic conventions
|
|
179
|
+
* https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext
|
|
180
|
+
*
|
|
181
|
+
* PostgreSQL $n placeholders are preserved per OTEL spec - they're parameterized queries,
|
|
182
|
+
* not sensitive literals. Only actual values (strings, numbers, booleans) are sanitized.
|
|
183
|
+
*/
|
|
184
|
+
_sanitizeSqlQuery(sqlQuery) {
|
|
185
|
+
if (!sqlQuery) {
|
|
186
|
+
return 'Unknown SQL Query';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
sqlQuery
|
|
191
|
+
// Remove comments first (they may contain newlines and extra spaces)
|
|
192
|
+
.replace(/--.*$/gm, '') // Single line comments (multiline mode)
|
|
193
|
+
.replace(/\/\*[\s\S]*?\*\//g, '') // Multi-line comments
|
|
194
|
+
.replace(/;\s*$/, '') // Remove trailing semicolons
|
|
195
|
+
// Collapse whitespace to a single space (after removing comments)
|
|
196
|
+
.replace(/\s+/g, ' ')
|
|
197
|
+
.trim() // Remove extra spaces and trim
|
|
198
|
+
// Sanitize hex/binary literals before string literals
|
|
199
|
+
.replace(/\bX'[0-9A-Fa-f]*'/gi, '?') // Hex string literals
|
|
200
|
+
.replace(/\bB'[01]*'/gi, '?') // Binary string literals
|
|
201
|
+
// Sanitize string literals (handles escaped quotes)
|
|
202
|
+
.replace(/'(?:[^']|'')*'/g, '?')
|
|
203
|
+
// Sanitize hex numbers
|
|
204
|
+
.replace(/\b0x[0-9A-Fa-f]+/gi, '?')
|
|
205
|
+
// Sanitize boolean literals
|
|
206
|
+
.replace(/\b(?:TRUE|FALSE)\b/gi, '?')
|
|
207
|
+
// Sanitize numeric literals (preserve $n placeholders via negative lookbehind)
|
|
208
|
+
.replace(/-?\b\d+\.?\d*[eE][+-]?\d+\b/g, '?') // Scientific notation
|
|
209
|
+
.replace(/-?\b\d+\.\d+\b/g, '?') // Decimals
|
|
210
|
+
.replace(/-?\.\d+\b/g, '?') // Decimals starting with dot
|
|
211
|
+
.replace(/(?<!\$)-?\b\d+\b/g, '?') // Integers (NOT $n placeholders)
|
|
212
|
+
// Collapse IN clauses for cardinality (both ? and $n variants)
|
|
213
|
+
.replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/gi, 'IN (?)')
|
|
214
|
+
.replace(/\bIN\b\s*\(\s*\$\d+(?:\s*,\s*\$\d+)*\s*\)/gi, 'IN ($?)')
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Fallback patch for Query.prototype.handle to instrument queries from pre-existing sql instances.
|
|
220
|
+
* This catches queries from sql instances created BEFORE Sentry was initialized (CJS only).
|
|
221
|
+
*
|
|
222
|
+
* Note: Queries from pre-existing instances won't have connection context (database, host, port)
|
|
223
|
+
* because the sql instance wasn't created through our instrumented wrapper.
|
|
224
|
+
*/
|
|
225
|
+
_patchQueryPrototype(moduleExports
|
|
226
|
+
|
|
227
|
+
) {
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
229
|
+
const self = this;
|
|
230
|
+
const originalHandle = moduleExports.Query.prototype.handle;
|
|
231
|
+
|
|
232
|
+
moduleExports.Query.prototype.handle = async function (
|
|
233
|
+
|
|
234
|
+
...args
|
|
235
|
+
) {
|
|
236
|
+
// Skip if this query came from an instrumented sql instance (already handled by wrapper)
|
|
237
|
+
if ((this )[QUERY_FROM_INSTRUMENTED_SQL]) {
|
|
238
|
+
return originalHandle.apply(this, args);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Skip if we shouldn't create spans
|
|
242
|
+
if (!self._shouldCreateSpans()) {
|
|
243
|
+
return originalHandle.apply(this, args);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const fullQuery = self._reconstructQuery(this.strings);
|
|
247
|
+
const sanitizedSqlQuery = self._sanitizeSqlQuery(fullQuery);
|
|
248
|
+
|
|
249
|
+
return startSpanManual(
|
|
250
|
+
{
|
|
251
|
+
name: sanitizedSqlQuery || 'postgresjs.query',
|
|
252
|
+
op: 'db',
|
|
253
|
+
},
|
|
254
|
+
(span) => {
|
|
255
|
+
addOriginToSpan(span, 'auto.db.postgresjs');
|
|
256
|
+
|
|
257
|
+
span.setAttributes({
|
|
258
|
+
[ATTR_DB_SYSTEM_NAME]: 'postgres',
|
|
259
|
+
[ATTR_DB_QUERY_TEXT]: sanitizedSqlQuery,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// Note: No connection context available for pre-existing instances
|
|
263
|
+
// because the sql instance wasn't created through our instrumented wrapper
|
|
264
|
+
|
|
265
|
+
const config = self.getConfig();
|
|
266
|
+
const { requestHook } = config;
|
|
267
|
+
if (requestHook) {
|
|
268
|
+
safeExecuteInTheMiddle(
|
|
269
|
+
() => requestHook(span, sanitizedSqlQuery, undefined),
|
|
270
|
+
e => {
|
|
271
|
+
if (e) {
|
|
272
|
+
span.setAttribute('sentry.hook.error', 'requestHook failed');
|
|
273
|
+
DEBUG_BUILD && debug.error(`Error in requestHook for ${INTEGRATION_NAME} integration:`, e);
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
true,
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Wrap resolve to end span on success
|
|
281
|
+
const originalResolve = this.resolve;
|
|
282
|
+
this.resolve = new Proxy(originalResolve , {
|
|
283
|
+
apply: (resolveTarget, resolveThisArg, resolveArgs) => {
|
|
284
|
+
try {
|
|
285
|
+
self._setOperationName(span, sanitizedSqlQuery, resolveArgs?.[0]?.command);
|
|
286
|
+
span.end();
|
|
287
|
+
} catch (e) {
|
|
288
|
+
DEBUG_BUILD && debug.error('Error ending span in resolve callback:', e);
|
|
289
|
+
}
|
|
290
|
+
return Reflect.apply(resolveTarget, resolveThisArg, resolveArgs);
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// Wrap reject to end span on error
|
|
295
|
+
const originalReject = this.reject;
|
|
296
|
+
this.reject = new Proxy(originalReject , {
|
|
297
|
+
apply: (rejectTarget, rejectThisArg, rejectArgs) => {
|
|
298
|
+
try {
|
|
299
|
+
span.setStatus({
|
|
300
|
+
code: SPAN_STATUS_ERROR,
|
|
301
|
+
message: rejectArgs?.[0]?.message || 'unknown_error',
|
|
302
|
+
});
|
|
303
|
+
span.setAttribute(ATTR_DB_RESPONSE_STATUS_CODE, rejectArgs?.[0]?.code || 'unknown');
|
|
304
|
+
span.setAttribute(ATTR_ERROR_TYPE, rejectArgs?.[0]?.name || 'unknown');
|
|
305
|
+
self._setOperationName(span, sanitizedSqlQuery);
|
|
306
|
+
span.end();
|
|
307
|
+
} catch (e) {
|
|
308
|
+
DEBUG_BUILD && debug.error('Error ending span in reject callback:', e);
|
|
309
|
+
}
|
|
310
|
+
return Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
try {
|
|
315
|
+
return originalHandle.apply(this, args);
|
|
316
|
+
} catch (e) {
|
|
317
|
+
span.setStatus({
|
|
318
|
+
code: SPAN_STATUS_ERROR,
|
|
319
|
+
message: e instanceof Error ? e.message : 'unknown_error',
|
|
320
|
+
});
|
|
321
|
+
span.end();
|
|
322
|
+
throw e;
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// Store original for unpatch - must be set on the NEW patched function
|
|
329
|
+
moduleExports.Query.prototype.handle.__sentry_original__ = originalHandle;
|
|
330
|
+
|
|
331
|
+
return moduleExports;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Restores the original Query.prototype.handle method.
|
|
336
|
+
*/
|
|
337
|
+
_unpatchQueryPrototype(moduleExports
|
|
338
|
+
|
|
339
|
+
) {
|
|
340
|
+
if (moduleExports.Query.prototype.handle.__sentry_original__) {
|
|
341
|
+
moduleExports.Query.prototype.handle = moduleExports.Query.prototype.handle.__sentry_original__;
|
|
342
|
+
}
|
|
343
|
+
return moduleExports;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const _postgresJsIntegration = ((options) => {
|
|
348
|
+
return {
|
|
349
|
+
name: INTEGRATION_NAME,
|
|
350
|
+
setupOnce() {
|
|
351
|
+
instrumentPostgresJs(options);
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
}) ;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.
|
|
358
|
+
*
|
|
359
|
+
* For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```javascript
|
|
363
|
+
* const Sentry = require('@sentry/node');
|
|
364
|
+
*
|
|
365
|
+
* Sentry.init({
|
|
366
|
+
* integrations: [Sentry.postgresJsIntegration()],
|
|
367
|
+
* });
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
|
|
371
|
+
const postgresJsIntegration = defineIntegration(_postgresJsIntegration);
|
|
372
|
+
|
|
373
|
+
export { PostgresJsInstrumentation, instrumentPostgresJs, postgresJsIntegration };
|
|
374
|
+
//# sourceMappingURL=postgresjs.js.map
|