@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,262 @@
|
|
|
1
|
+
import { SpanKind, context, trace, diag } from '@opentelemetry/api';
|
|
2
|
+
import { InstrumentationNodeModuleDefinition, InstrumentationNodeModuleFile, isWrapped, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Patches Firebase Functions v2 to add OpenTelemetry instrumentation
|
|
6
|
+
* @param tracer - Opentelemetry Tracer
|
|
7
|
+
* @param functionsSupportedVersions - supported versions of firebase-functions
|
|
8
|
+
* @param wrap - reference to native instrumentation wrap function
|
|
9
|
+
* @param unwrap - reference to native instrumentation unwrap function
|
|
10
|
+
* @param config - Firebase instrumentation config
|
|
11
|
+
*/
|
|
12
|
+
function patchFunctions(
|
|
13
|
+
tracer,
|
|
14
|
+
functionsSupportedVersions,
|
|
15
|
+
wrap,
|
|
16
|
+
unwrap,
|
|
17
|
+
config,
|
|
18
|
+
) {
|
|
19
|
+
let requestHook = () => {};
|
|
20
|
+
let responseHook = () => {};
|
|
21
|
+
const errorHook = config.functions?.errorHook;
|
|
22
|
+
const configRequestHook = config.functions?.requestHook;
|
|
23
|
+
const configResponseHook = config.functions?.responseHook;
|
|
24
|
+
|
|
25
|
+
if (typeof configResponseHook === 'function') {
|
|
26
|
+
responseHook = (span, err) => {
|
|
27
|
+
safeExecuteInTheMiddle(
|
|
28
|
+
() => configResponseHook(span, err),
|
|
29
|
+
error => {
|
|
30
|
+
if (!error) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
diag.error(error?.message);
|
|
34
|
+
},
|
|
35
|
+
true,
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (typeof configRequestHook === 'function') {
|
|
40
|
+
requestHook = (span) => {
|
|
41
|
+
safeExecuteInTheMiddle(
|
|
42
|
+
() => configRequestHook(span),
|
|
43
|
+
error => {
|
|
44
|
+
if (!error) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
diag.error(error?.message);
|
|
48
|
+
},
|
|
49
|
+
true,
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const moduleFunctionsCJS = new InstrumentationNodeModuleDefinition('firebase-functions', functionsSupportedVersions);
|
|
55
|
+
const modulesToInstrument = [
|
|
56
|
+
{ name: 'firebase-functions/lib/v2/providers/https.js', triggerType: 'function' },
|
|
57
|
+
{ name: 'firebase-functions/lib/v2/providers/firestore.js', triggerType: 'firestore' },
|
|
58
|
+
{ name: 'firebase-functions/lib/v2/providers/scheduler.js', triggerType: 'scheduler' },
|
|
59
|
+
{ name: 'firebase-functions/lib/v2/storage.js', triggerType: 'storage' },
|
|
60
|
+
] ;
|
|
61
|
+
|
|
62
|
+
modulesToInstrument.forEach(({ name, triggerType }) => {
|
|
63
|
+
moduleFunctionsCJS.files.push(
|
|
64
|
+
new InstrumentationNodeModuleFile(
|
|
65
|
+
name,
|
|
66
|
+
functionsSupportedVersions,
|
|
67
|
+
moduleExports =>
|
|
68
|
+
wrapCommonFunctions(
|
|
69
|
+
moduleExports,
|
|
70
|
+
wrap,
|
|
71
|
+
unwrap,
|
|
72
|
+
tracer,
|
|
73
|
+
{ requestHook, responseHook, errorHook },
|
|
74
|
+
triggerType,
|
|
75
|
+
),
|
|
76
|
+
moduleExports => unwrapCommonFunctions(moduleExports, unwrap),
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return moduleFunctionsCJS;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Patches Cloud Functions for Firebase (v2) to add OpenTelemetry instrumentation
|
|
86
|
+
*
|
|
87
|
+
* @param tracer - Opentelemetry Tracer
|
|
88
|
+
* @param functionsConfig - Firebase instrumentation config
|
|
89
|
+
* @param triggerType - Type of trigger
|
|
90
|
+
* @returns A function that patches the function
|
|
91
|
+
*/
|
|
92
|
+
function patchV2Functions(
|
|
93
|
+
tracer,
|
|
94
|
+
functionsConfig,
|
|
95
|
+
triggerType,
|
|
96
|
+
) {
|
|
97
|
+
return function v2FunctionsWrapper(original) {
|
|
98
|
+
return function ( ...args) {
|
|
99
|
+
const handler = typeof args[0] === 'function' ? args[0] : args[1];
|
|
100
|
+
const documentOrOptions = typeof args[0] === 'function' ? undefined : args[0];
|
|
101
|
+
|
|
102
|
+
if (!handler) {
|
|
103
|
+
return original.call(this, ...args);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const wrappedHandler = async function ( ...handlerArgs) {
|
|
107
|
+
const functionName = process.env.FUNCTION_TARGET || process.env.K_SERVICE || 'unknown';
|
|
108
|
+
const span = tracer.startSpan(`firebase.function.${triggerType}`, {
|
|
109
|
+
kind: SpanKind.SERVER,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const attributes = {
|
|
113
|
+
'faas.name': functionName,
|
|
114
|
+
'faas.trigger': triggerType,
|
|
115
|
+
'faas.provider': 'firebase',
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
if (process.env.GCLOUD_PROJECT) {
|
|
119
|
+
attributes['cloud.project_id'] = process.env.GCLOUD_PROJECT;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (process.env.EVENTARC_CLOUD_EVENT_SOURCE) {
|
|
123
|
+
attributes['cloud.event_source'] = process.env.EVENTARC_CLOUD_EVENT_SOURCE;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
span.setAttributes(attributes);
|
|
127
|
+
functionsConfig?.requestHook?.(span);
|
|
128
|
+
|
|
129
|
+
// Can be changed to safeExecuteInTheMiddleAsync once following is merged and released
|
|
130
|
+
// https://github.com/open-telemetry/opentelemetry-js/pull/6032
|
|
131
|
+
return context.with(trace.setSpan(context.active(), span), async () => {
|
|
132
|
+
let error;
|
|
133
|
+
let result;
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
result = await handler.apply(this, handlerArgs);
|
|
137
|
+
} catch (e) {
|
|
138
|
+
error = e ;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
functionsConfig?.responseHook?.(span, error);
|
|
142
|
+
|
|
143
|
+
if (error) {
|
|
144
|
+
span.recordException(error);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
span.end();
|
|
148
|
+
|
|
149
|
+
if (error) {
|
|
150
|
+
await functionsConfig?.errorHook?.(span, error);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return result;
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
if (documentOrOptions) {
|
|
159
|
+
return original.call(this, documentOrOptions, wrappedHandler);
|
|
160
|
+
} else {
|
|
161
|
+
return original.call(this, wrappedHandler);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function wrapCommonFunctions(
|
|
168
|
+
moduleExports,
|
|
169
|
+
wrap,
|
|
170
|
+
unwrap,
|
|
171
|
+
tracer,
|
|
172
|
+
functionsConfig,
|
|
173
|
+
triggerType,
|
|
174
|
+
) {
|
|
175
|
+
unwrapCommonFunctions(moduleExports, unwrap);
|
|
176
|
+
|
|
177
|
+
switch (triggerType) {
|
|
178
|
+
case 'function':
|
|
179
|
+
wrap(moduleExports, 'onRequest', patchV2Functions(tracer, functionsConfig, 'http.request'));
|
|
180
|
+
wrap(moduleExports, 'onCall', patchV2Functions(tracer, functionsConfig, 'http.call'));
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case 'firestore':
|
|
184
|
+
wrap(moduleExports, 'onDocumentCreated', patchV2Functions(tracer, functionsConfig, 'firestore.document.created'));
|
|
185
|
+
wrap(moduleExports, 'onDocumentUpdated', patchV2Functions(tracer, functionsConfig, 'firestore.document.updated'));
|
|
186
|
+
wrap(moduleExports, 'onDocumentDeleted', patchV2Functions(tracer, functionsConfig, 'firestore.document.deleted'));
|
|
187
|
+
wrap(moduleExports, 'onDocumentWritten', patchV2Functions(tracer, functionsConfig, 'firestore.document.written'));
|
|
188
|
+
wrap(
|
|
189
|
+
moduleExports,
|
|
190
|
+
'onDocumentCreatedWithAuthContext',
|
|
191
|
+
patchV2Functions(tracer, functionsConfig, 'firestore.document.created'),
|
|
192
|
+
);
|
|
193
|
+
wrap(
|
|
194
|
+
moduleExports,
|
|
195
|
+
'onDocumentUpdatedWithAuthContext',
|
|
196
|
+
patchV2Functions(tracer, functionsConfig, 'firestore.document.updated'),
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
wrap(
|
|
200
|
+
moduleExports,
|
|
201
|
+
'onDocumentDeletedWithAuthContext',
|
|
202
|
+
patchV2Functions(tracer, functionsConfig, 'firestore.document.deleted'),
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
wrap(
|
|
206
|
+
moduleExports,
|
|
207
|
+
'onDocumentWrittenWithAuthContext',
|
|
208
|
+
patchV2Functions(tracer, functionsConfig, 'firestore.document.written'),
|
|
209
|
+
);
|
|
210
|
+
break;
|
|
211
|
+
|
|
212
|
+
case 'scheduler':
|
|
213
|
+
wrap(moduleExports, 'onSchedule', patchV2Functions(tracer, functionsConfig, 'scheduler.scheduled'));
|
|
214
|
+
break;
|
|
215
|
+
|
|
216
|
+
case 'storage':
|
|
217
|
+
wrap(moduleExports, 'onObjectFinalized', patchV2Functions(tracer, functionsConfig, 'storage.object.finalized'));
|
|
218
|
+
wrap(moduleExports, 'onObjectArchived', patchV2Functions(tracer, functionsConfig, 'storage.object.archived'));
|
|
219
|
+
wrap(moduleExports, 'onObjectDeleted', patchV2Functions(tracer, functionsConfig, 'storage.object.deleted'));
|
|
220
|
+
wrap(
|
|
221
|
+
moduleExports,
|
|
222
|
+
'onObjectMetadataUpdated',
|
|
223
|
+
patchV2Functions(tracer, functionsConfig, 'storage.object.metadataUpdated'),
|
|
224
|
+
);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return moduleExports;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function unwrapCommonFunctions(
|
|
232
|
+
moduleExports,
|
|
233
|
+
unwrap,
|
|
234
|
+
) {
|
|
235
|
+
const methods = [
|
|
236
|
+
'onSchedule',
|
|
237
|
+
'onRequest',
|
|
238
|
+
'onCall',
|
|
239
|
+
'onObjectFinalized',
|
|
240
|
+
'onObjectArchived',
|
|
241
|
+
'onObjectDeleted',
|
|
242
|
+
'onObjectMetadataUpdated',
|
|
243
|
+
'onDocumentCreated',
|
|
244
|
+
'onDocumentUpdated',
|
|
245
|
+
'onDocumentDeleted',
|
|
246
|
+
'onDocumentWritten',
|
|
247
|
+
'onDocumentCreatedWithAuthContext',
|
|
248
|
+
'onDocumentUpdatedWithAuthContext',
|
|
249
|
+
'onDocumentDeletedWithAuthContext',
|
|
250
|
+
'onDocumentWrittenWithAuthContext',
|
|
251
|
+
];
|
|
252
|
+
|
|
253
|
+
for (const method of methods) {
|
|
254
|
+
if (isWrapped(moduleExports[method])) {
|
|
255
|
+
unwrap(moduleExports, method);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return moduleExports;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export { patchFunctions, patchV2Functions };
|
|
262
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sources":["../../../../../../../src/integrations/tracing/firebase/otel/patches/functions.ts"],"sourcesContent":["import type { Span, Tracer } from '@opentelemetry/api';\nimport { context, diag, SpanKind, trace } from '@opentelemetry/api';\nimport type { InstrumentationBase } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport type { SpanAttributes } from '@sentry/core';\nimport type { FirebaseInstrumentation } from '../firebaseInstrumentation';\nimport type {\n AvailableFirebaseFunctions,\n FirebaseFunctions,\n FirebaseInstrumentationConfig,\n OverloadedParameters,\n RequestHook,\n ResponseHook,\n} from '../types';\n\n/**\n * Patches Firebase Functions v2 to add OpenTelemetry instrumentation\n * @param tracer - Opentelemetry Tracer\n * @param functionsSupportedVersions - supported versions of firebase-functions\n * @param wrap - reference to native instrumentation wrap function\n * @param unwrap - reference to native instrumentation unwrap function\n * @param config - Firebase instrumentation config\n */\nexport function patchFunctions(\n tracer: Tracer,\n functionsSupportedVersions: string[],\n wrap: InstrumentationBase['_wrap'],\n unwrap: InstrumentationBase['_unwrap'],\n config: FirebaseInstrumentationConfig,\n): InstrumentationNodeModuleDefinition {\n let requestHook: RequestHook = () => {};\n let responseHook: ResponseHook = () => {};\n const errorHook = config.functions?.errorHook;\n const configRequestHook = config.functions?.requestHook;\n const configResponseHook = config.functions?.responseHook;\n\n if (typeof configResponseHook === 'function') {\n responseHook = (span: Span, err: unknown) => {\n safeExecuteInTheMiddle(\n () => configResponseHook(span, err),\n error => {\n if (!error) {\n return;\n }\n diag.error(error?.message);\n },\n true,\n );\n };\n }\n if (typeof configRequestHook === 'function') {\n requestHook = (span: Span) => {\n safeExecuteInTheMiddle(\n () => configRequestHook(span),\n error => {\n if (!error) {\n return;\n }\n diag.error(error?.message);\n },\n true,\n );\n };\n }\n\n const moduleFunctionsCJS = new InstrumentationNodeModuleDefinition('firebase-functions', functionsSupportedVersions);\n const modulesToInstrument = [\n { name: 'firebase-functions/lib/v2/providers/https.js', triggerType: 'function' },\n { name: 'firebase-functions/lib/v2/providers/firestore.js', triggerType: 'firestore' },\n { name: 'firebase-functions/lib/v2/providers/scheduler.js', triggerType: 'scheduler' },\n { name: 'firebase-functions/lib/v2/storage.js', triggerType: 'storage' },\n ] as const;\n\n modulesToInstrument.forEach(({ name, triggerType }) => {\n moduleFunctionsCJS.files.push(\n new InstrumentationNodeModuleFile(\n name,\n functionsSupportedVersions,\n moduleExports =>\n wrapCommonFunctions(\n moduleExports,\n wrap,\n unwrap,\n tracer,\n { requestHook, responseHook, errorHook },\n triggerType,\n ),\n moduleExports => unwrapCommonFunctions(moduleExports, unwrap),\n ),\n );\n });\n\n return moduleFunctionsCJS;\n}\n\n/**\n * Patches Cloud Functions for Firebase (v2) to add OpenTelemetry instrumentation\n *\n * @param tracer - Opentelemetry Tracer\n * @param functionsConfig - Firebase instrumentation config\n * @param triggerType - Type of trigger\n * @returns A function that patches the function\n */\nexport function patchV2Functions<T extends FirebaseFunctions = FirebaseFunctions>(\n tracer: Tracer,\n functionsConfig: FirebaseInstrumentationConfig['functions'],\n triggerType: string,\n): (original: T) => (...args: OverloadedParameters<T>) => ReturnType<T> {\n return function v2FunctionsWrapper(original: T): (...args: OverloadedParameters<T>) => ReturnType<T> {\n return function (this: FirebaseInstrumentation, ...args: OverloadedParameters<T>): ReturnType<T> {\n const handler = typeof args[0] === 'function' ? args[0] : args[1];\n const documentOrOptions = typeof args[0] === 'function' ? undefined : args[0];\n\n if (!handler) {\n return original.call(this, ...args);\n }\n\n const wrappedHandler = async function (this: unknown, ...handlerArgs: unknown[]): Promise<unknown> {\n const functionName = process.env.FUNCTION_TARGET || process.env.K_SERVICE || 'unknown';\n const span = tracer.startSpan(`firebase.function.${triggerType}`, {\n kind: SpanKind.SERVER,\n });\n\n const attributes: SpanAttributes = {\n 'faas.name': functionName,\n 'faas.trigger': triggerType,\n 'faas.provider': 'firebase',\n };\n\n if (process.env.GCLOUD_PROJECT) {\n attributes['cloud.project_id'] = process.env.GCLOUD_PROJECT;\n }\n\n if (process.env.EVENTARC_CLOUD_EVENT_SOURCE) {\n attributes['cloud.event_source'] = process.env.EVENTARC_CLOUD_EVENT_SOURCE;\n }\n\n span.setAttributes(attributes);\n functionsConfig?.requestHook?.(span);\n\n // Can be changed to safeExecuteInTheMiddleAsync once following is merged and released\n // https://github.com/open-telemetry/opentelemetry-js/pull/6032\n return context.with(trace.setSpan(context.active(), span), async () => {\n let error: Error | undefined;\n let result: T | undefined;\n\n try {\n result = await handler.apply(this, handlerArgs);\n } catch (e) {\n error = e as Error;\n }\n\n functionsConfig?.responseHook?.(span, error);\n\n if (error) {\n span.recordException(error);\n }\n\n span.end();\n\n if (error) {\n await functionsConfig?.errorHook?.(span, error);\n throw error;\n }\n\n return result;\n });\n };\n\n if (documentOrOptions) {\n return original.call(this, documentOrOptions, wrappedHandler);\n } else {\n return original.call(this, wrappedHandler);\n }\n };\n };\n}\n\nfunction wrapCommonFunctions(\n moduleExports: AvailableFirebaseFunctions,\n wrap: InstrumentationBase<FirebaseInstrumentationConfig>['_wrap'],\n unwrap: InstrumentationBase<FirebaseInstrumentationConfig>['_unwrap'],\n tracer: Tracer,\n functionsConfig: FirebaseInstrumentationConfig['functions'],\n triggerType: 'function' | 'firestore' | 'scheduler' | 'storage',\n): AvailableFirebaseFunctions {\n unwrapCommonFunctions(moduleExports, unwrap);\n\n switch (triggerType) {\n case 'function':\n wrap(moduleExports, 'onRequest', patchV2Functions(tracer, functionsConfig, 'http.request'));\n wrap(moduleExports, 'onCall', patchV2Functions(tracer, functionsConfig, 'http.call'));\n break;\n\n case 'firestore':\n wrap(moduleExports, 'onDocumentCreated', patchV2Functions(tracer, functionsConfig, 'firestore.document.created'));\n wrap(moduleExports, 'onDocumentUpdated', patchV2Functions(tracer, functionsConfig, 'firestore.document.updated'));\n wrap(moduleExports, 'onDocumentDeleted', patchV2Functions(tracer, functionsConfig, 'firestore.document.deleted'));\n wrap(moduleExports, 'onDocumentWritten', patchV2Functions(tracer, functionsConfig, 'firestore.document.written'));\n wrap(\n moduleExports,\n 'onDocumentCreatedWithAuthContext',\n patchV2Functions(tracer, functionsConfig, 'firestore.document.created'),\n );\n wrap(\n moduleExports,\n 'onDocumentUpdatedWithAuthContext',\n patchV2Functions(tracer, functionsConfig, 'firestore.document.updated'),\n );\n\n wrap(\n moduleExports,\n 'onDocumentDeletedWithAuthContext',\n patchV2Functions(tracer, functionsConfig, 'firestore.document.deleted'),\n );\n\n wrap(\n moduleExports,\n 'onDocumentWrittenWithAuthContext',\n patchV2Functions(tracer, functionsConfig, 'firestore.document.written'),\n );\n break;\n\n case 'scheduler':\n wrap(moduleExports, 'onSchedule', patchV2Functions(tracer, functionsConfig, 'scheduler.scheduled'));\n break;\n\n case 'storage':\n wrap(moduleExports, 'onObjectFinalized', patchV2Functions(tracer, functionsConfig, 'storage.object.finalized'));\n wrap(moduleExports, 'onObjectArchived', patchV2Functions(tracer, functionsConfig, 'storage.object.archived'));\n wrap(moduleExports, 'onObjectDeleted', patchV2Functions(tracer, functionsConfig, 'storage.object.deleted'));\n wrap(\n moduleExports,\n 'onObjectMetadataUpdated',\n patchV2Functions(tracer, functionsConfig, 'storage.object.metadataUpdated'),\n );\n break;\n }\n\n return moduleExports;\n}\n\nfunction unwrapCommonFunctions(\n moduleExports: AvailableFirebaseFunctions,\n unwrap: InstrumentationBase<FirebaseInstrumentationConfig>['_unwrap'],\n): AvailableFirebaseFunctions {\n const methods: (keyof AvailableFirebaseFunctions)[] = [\n 'onSchedule',\n 'onRequest',\n 'onCall',\n 'onObjectFinalized',\n 'onObjectArchived',\n 'onObjectDeleted',\n 'onObjectMetadataUpdated',\n 'onDocumentCreated',\n 'onDocumentUpdated',\n 'onDocumentDeleted',\n 'onDocumentWritten',\n 'onDocumentCreatedWithAuthContext',\n 'onDocumentUpdatedWithAuthContext',\n 'onDocumentDeletedWithAuthContext',\n 'onDocumentWrittenWithAuthContext',\n ];\n\n for (const method of methods) {\n if (isWrapped(moduleExports[method])) {\n unwrap(moduleExports, method);\n }\n }\n return moduleExports;\n}\n"],"names":[],"mappings":";;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc;AAC9B,EAAE,MAAM;AACR,EAAE,0BAA0B;AAC5B,EAAE,IAAI;AACN,EAAE,MAAM;AACR,EAAE,MAAM;AACR,EAAuC;AACvC,EAAE,IAAI,WAAW,GAAgB,MAAM,CAAC,CAAC;AACzC,EAAE,IAAI,YAAY,GAAiB,MAAM,CAAC,CAAC;AAC3C,EAAE,MAAM,SAAA,GAAY,MAAM,CAAC,SAAS,EAAE,SAAS;AAC/C,EAAE,MAAM,iBAAA,GAAoB,MAAM,CAAC,SAAS,EAAE,WAAW;AACzD,EAAE,MAAM,kBAAA,GAAqB,MAAM,CAAC,SAAS,EAAE,YAAY;;AAE3D,EAAE,IAAI,OAAO,kBAAA,KAAuB,UAAU,EAAE;AAChD,IAAI,eAAe,CAAC,IAAI,EAAQ,GAAG,KAAc;AACjD,MAAM,sBAAsB;AAC5B,QAAQ,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A,kBAAA;AACA,IAAA,iBAAA;AACA,IAAA,yBAAA;AACA,IAAA,mBAAA;AACA,IAAA,mBAAA;AACA,IAAA,mBAAA;AACA,IAAA,mBAAA;AACA,IAAA,kCAAA;AACA,IAAA,kCAAA;AACA,IAAA,kCAAA;AACA,IAAA,kCAAA;AACA,GAAA;;AAEA,EAAA,KAAA,MAAA,MAAA,IAAA,OAAA,EAAA;AACA,IAAA,IAAA,SAAA,CAAA,aAAA,CAAA,MAAA,CAAA,CAAA,EAAA;AACA,MAAA,MAAA,CAAA,aAAA,EAAA,MAAA,CAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA,OAAA,aAAA;AACA;;;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { GenericPoolInstrumentation } from '@opentelemetry/instrumentation-generic-pool';
|
|
2
|
+
import { defineIntegration, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
3
|
+
import { generateInstrumentOnce, instrumentWhenWrapped } from '@sentry/node-core';
|
|
4
|
+
|
|
5
|
+
const INTEGRATION_NAME = 'GenericPool';
|
|
6
|
+
|
|
7
|
+
const instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME, () => new GenericPoolInstrumentation({}));
|
|
8
|
+
|
|
9
|
+
const _genericPoolIntegration = (() => {
|
|
10
|
+
let instrumentationWrappedCallback;
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
name: INTEGRATION_NAME,
|
|
14
|
+
setupOnce() {
|
|
15
|
+
const instrumentation = instrumentGenericPool();
|
|
16
|
+
instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
setup(client) {
|
|
20
|
+
instrumentationWrappedCallback?.(() =>
|
|
21
|
+
client.on('spanStart', span => {
|
|
22
|
+
const spanJSON = spanToJSON(span);
|
|
23
|
+
|
|
24
|
+
const spanDescription = spanJSON.description;
|
|
25
|
+
|
|
26
|
+
// typo in emitted span for version <= 0.38.0 of @opentelemetry/instrumentation-generic-pool
|
|
27
|
+
const isGenericPoolSpan =
|
|
28
|
+
spanDescription === 'generic-pool.aquire' || spanDescription === 'generic-pool.acquire';
|
|
29
|
+
|
|
30
|
+
if (isGenericPoolSpan) {
|
|
31
|
+
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.generic_pool');
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}) ;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Adds Sentry tracing instrumentation for the [generic-pool](https://www.npmjs.com/package/generic-pool) library.
|
|
41
|
+
*
|
|
42
|
+
* For more information, see the [`genericPoolIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/genericpool/).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```javascript
|
|
46
|
+
* const Sentry = require('@sentry/node');
|
|
47
|
+
*
|
|
48
|
+
* Sentry.init({
|
|
49
|
+
* integrations: [Sentry.genericPoolIntegration()],
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
const genericPoolIntegration = defineIntegration(_genericPoolIntegration);
|
|
54
|
+
|
|
55
|
+
export { genericPoolIntegration, instrumentGenericPool };
|
|
56
|
+
//# sourceMappingURL=genericPool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genericPool.js","sources":["../../../../src/integrations/tracing/genericPool.ts"],"sourcesContent":["import { GenericPoolInstrumentation } from '@opentelemetry/instrumentation-generic-pool';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce, instrumentWhenWrapped } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'GenericPool';\n\nexport const instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME, () => new GenericPoolInstrumentation({}));\n\nconst _genericPoolIntegration = (() => {\n let instrumentationWrappedCallback: undefined | ((callback: () => void) => void);\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const instrumentation = instrumentGenericPool();\n instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);\n },\n\n setup(client) {\n instrumentationWrappedCallback?.(() =>\n client.on('spanStart', span => {\n const spanJSON = spanToJSON(span);\n\n const spanDescription = spanJSON.description;\n\n // typo in emitted span for version <= 0.38.0 of @opentelemetry/instrumentation-generic-pool\n const isGenericPoolSpan =\n spanDescription === 'generic-pool.aquire' || spanDescription === 'generic-pool.acquire';\n\n if (isGenericPoolSpan) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.generic_pool');\n }\n }),\n );\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [generic-pool](https://www.npmjs.com/package/generic-pool) library.\n *\n * For more information, see the [`genericPoolIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/genericpool/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.genericPoolIntegration()],\n * });\n * ```\n */\nexport const genericPoolIntegration = defineIntegration(_genericPoolIntegration);\n"],"names":[],"mappings":";;;;AAKA,MAAM,gBAAA,GAAmB,aAAa;;MAEzB,qBAAA,GAAwB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,IAAI,0BAA0B,CAAC,EAAE,CAAC;;AAEtH,MAAM,uBAAA,IAA2B,MAAM;AACvC,EAAE,IAAI,8BAA8B;;AAEpC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,MAAM,eAAA,GAAkB,qBAAqB,EAAE;AACrD,MAAM,8BAAA,GAAiC,qBAAqB,CAAC,eAAe,CAAC;AAC7E,IAAI,CAAC;;AAEL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,8BAA8B,GAAG;AACvC,QAAQ,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ;AACvC,UAAU,MAAM,QAAA,GAAW,UAAU,CAAC,IAAI,CAAC;;AAE3C,UAAU,MAAM,eAAA,GAAkB,QAAQ,CAAC,WAAW;;AAEtD;AACA,UAAU,MAAM,iBAAA;AAChB,YAAY,oBAAoB,qBAAA,IAAyB,eAAA,KAAoB,sBAAsB;;AAEnG,UAAU,IAAI,iBAAiB,EAAE;AACjC,YAAY,IAAI,CAAC,YAAY,CAAC,gCAAgC,EAAE,2BAA2B,CAAC;AAC5F,UAAU;AACV,QAAQ,CAAC,CAAC;AACV,OAAO;AACP,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,sBAAA,GAAyB,iBAAiB,CAAC,uBAAuB;;;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { GOOGLE_GENAI_INTEGRATION_NAME, defineIntegration } from '@sentry/core';
|
|
2
|
+
import { generateInstrumentOnce } from '@sentry/node-core';
|
|
3
|
+
import { SentryGoogleGenAiInstrumentation } from './instrumentation.js';
|
|
4
|
+
|
|
5
|
+
const instrumentGoogleGenAI = generateInstrumentOnce(
|
|
6
|
+
GOOGLE_GENAI_INTEGRATION_NAME,
|
|
7
|
+
options => new SentryGoogleGenAiInstrumentation(options),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const _googleGenAIIntegration = ((options = {}) => {
|
|
11
|
+
return {
|
|
12
|
+
name: GOOGLE_GENAI_INTEGRATION_NAME,
|
|
13
|
+
setupOnce() {
|
|
14
|
+
instrumentGoogleGenAI(options);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}) ;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Adds Sentry tracing instrumentation for the Google Generative AI SDK.
|
|
21
|
+
*
|
|
22
|
+
* This integration is enabled by default.
|
|
23
|
+
*
|
|
24
|
+
* When configured, this integration automatically instruments Google GenAI 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.googleGenAiIntegration()],
|
|
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.googleGenAiIntegration({
|
|
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.googleGenAiIntegration({
|
|
64
|
+
* recordInputs: false,
|
|
65
|
+
* recordOutputs: false
|
|
66
|
+
* })
|
|
67
|
+
* ],
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
const googleGenAIIntegration = defineIntegration(_googleGenAIIntegration);
|
|
73
|
+
|
|
74
|
+
export { googleGenAIIntegration, instrumentGoogleGenAI };
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/google-genai/index.ts"],"sourcesContent":["import type { GoogleGenAIOptions, IntegrationFn } from '@sentry/core';\nimport { defineIntegration, GOOGLE_GENAI_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryGoogleGenAiInstrumentation } from './instrumentation';\n\nexport const instrumentGoogleGenAI = generateInstrumentOnce<GoogleGenAIOptions>(\n GOOGLE_GENAI_INTEGRATION_NAME,\n options => new SentryGoogleGenAiInstrumentation(options),\n);\n\nconst _googleGenAIIntegration = ((options: GoogleGenAIOptions = {}) => {\n return {\n name: GOOGLE_GENAI_INTEGRATION_NAME,\n setupOnce() {\n instrumentGoogleGenAI(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the Google Generative AI SDK.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments Google GenAI 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.googleGenAiIntegration()],\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.googleGenAiIntegration({\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.googleGenAiIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n */\nexport const googleGenAIIntegration = defineIntegration(_googleGenAIIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,qBAAA,GAAwB,sBAAsB;AAC3D,EAAE,6BAA6B;AAC/B,EAAE,WAAW,IAAI,gCAAgC,CAAC,OAAO,CAAC;AAC1D;;AAEA,MAAM,uBAAA,IAA2B,CAAC,OAAO,GAAuB,EAAE,KAAK;AACvE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,6BAA6B;AACvC,IAAI,SAAS,GAAG;AAChB,MAAM,qBAAqB,CAAC,OAAO,CAAC;AACpC,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,sBAAA,GAAyB,iBAAiB,CAAC,uBAAuB;;;;"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition, InstrumentationNodeModuleFile } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { SDK_VERSION, replaceExports, _INTERNAL_shouldSkipAiProviderWrapping, GOOGLE_GENAI_INTEGRATION_NAME, instrumentGoogleGenAIClient } from '@sentry/core';
|
|
3
|
+
|
|
4
|
+
const supportedVersions = ['>=0.10.0 <2'];
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents the patched shape of the Google GenAI module export.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Sentry Google GenAI instrumentation using OpenTelemetry.
|
|
12
|
+
*/
|
|
13
|
+
class SentryGoogleGenAiInstrumentation extends InstrumentationBase {
|
|
14
|
+
constructor(config = {}) {
|
|
15
|
+
super('@sentry/instrumentation-google-genai', SDK_VERSION, config);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Initializes the instrumentation by defining the modules to be patched.
|
|
20
|
+
*/
|
|
21
|
+
init() {
|
|
22
|
+
const module = new InstrumentationNodeModuleDefinition(
|
|
23
|
+
'@google/genai',
|
|
24
|
+
supportedVersions,
|
|
25
|
+
exports$1 => this._patch(exports$1),
|
|
26
|
+
exports$1 => exports$1,
|
|
27
|
+
// In CJS, @google/genai re-exports from (dist/node/index.cjs) file.
|
|
28
|
+
// Patching only the root module sometimes misses the real implementation or
|
|
29
|
+
// gets overwritten when that file is loaded. We add a file-level patch so that
|
|
30
|
+
// _patch runs again on the concrete implementation
|
|
31
|
+
[
|
|
32
|
+
new InstrumentationNodeModuleFile(
|
|
33
|
+
'@google/genai/dist/node/index.cjs',
|
|
34
|
+
supportedVersions,
|
|
35
|
+
exports$1 => this._patch(exports$1),
|
|
36
|
+
exports$1 => exports$1,
|
|
37
|
+
),
|
|
38
|
+
],
|
|
39
|
+
);
|
|
40
|
+
return module;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Core patch logic applying instrumentation to the Google GenAI client constructor.
|
|
45
|
+
*/
|
|
46
|
+
_patch(exports$1) {
|
|
47
|
+
const Original = exports$1.GoogleGenAI;
|
|
48
|
+
const config = this.getConfig();
|
|
49
|
+
|
|
50
|
+
if (typeof Original !== 'function') {
|
|
51
|
+
return exports$1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const WrappedGoogleGenAI = function ( ...args) {
|
|
55
|
+
// Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)
|
|
56
|
+
if (_INTERNAL_shouldSkipAiProviderWrapping(GOOGLE_GENAI_INTEGRATION_NAME)) {
|
|
57
|
+
return Reflect.construct(Original, args) ;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const instance = Reflect.construct(Original, args);
|
|
61
|
+
|
|
62
|
+
return instrumentGoogleGenAIClient(instance, config);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Preserve static and prototype chains
|
|
66
|
+
Object.setPrototypeOf(WrappedGoogleGenAI, Original);
|
|
67
|
+
Object.setPrototypeOf(WrappedGoogleGenAI.prototype, Original.prototype);
|
|
68
|
+
|
|
69
|
+
for (const key of Object.getOwnPropertyNames(Original)) {
|
|
70
|
+
if (!['length', 'name', 'prototype'].includes(key)) {
|
|
71
|
+
const descriptor = Object.getOwnPropertyDescriptor(Original, key);
|
|
72
|
+
if (descriptor) {
|
|
73
|
+
Object.defineProperty(WrappedGoogleGenAI, key, descriptor);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Replace google genai exports with the wrapped constructor
|
|
79
|
+
replaceExports(exports$1, 'GoogleGenAI', WrappedGoogleGenAI);
|
|
80
|
+
|
|
81
|
+
return exports$1;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { SentryGoogleGenAiInstrumentation };
|
|
86
|
+
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/google-genai/instrumentation.ts"],"sourcesContent":["import type { InstrumentationConfig, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n} from '@opentelemetry/instrumentation';\nimport type { GoogleGenAIClient, GoogleGenAIOptions } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n GOOGLE_GENAI_INTEGRATION_NAME,\n instrumentGoogleGenAIClient,\n replaceExports,\n SDK_VERSION,\n} from '@sentry/core';\n\nconst supportedVersions = ['>=0.10.0 <2'];\n\n/**\n * Represents the patched shape of the Google GenAI module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n GoogleGenAI?: unknown;\n}\n\ntype GoogleGenAIInstrumentationOptions = GoogleGenAIOptions & InstrumentationConfig;\n\n/**\n * Sentry Google GenAI instrumentation using OpenTelemetry.\n */\nexport class SentryGoogleGenAiInstrumentation extends InstrumentationBase<GoogleGenAIInstrumentationOptions> {\n public constructor(config: GoogleGenAIInstrumentationOptions = {}) {\n super('@sentry/instrumentation-google-genai', 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(\n '@google/genai',\n supportedVersions,\n exports => this._patch(exports),\n exports => exports,\n // In CJS, @google/genai re-exports from (dist/node/index.cjs) file.\n // Patching only the root module sometimes misses the real implementation or\n // gets overwritten when that file is loaded. We add a file-level patch so that\n // _patch runs again on the concrete implementation\n [\n new InstrumentationNodeModuleFile(\n '@google/genai/dist/node/index.cjs',\n supportedVersions,\n exports => this._patch(exports),\n exports => exports,\n ),\n ],\n );\n return module;\n }\n\n /**\n * Core patch logic applying instrumentation to the Google GenAI client constructor.\n */\n private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {\n const Original = exports.GoogleGenAI;\n const config = this.getConfig();\n\n if (typeof Original !== 'function') {\n return exports;\n }\n\n const WrappedGoogleGenAI = function (this: unknown, ...args: unknown[]): GoogleGenAIClient {\n // Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)\n if (_INTERNAL_shouldSkipAiProviderWrapping(GOOGLE_GENAI_INTEGRATION_NAME)) {\n return Reflect.construct(Original, args) as GoogleGenAIClient;\n }\n\n const instance = Reflect.construct(Original, args);\n\n return instrumentGoogleGenAIClient(instance, config);\n };\n\n // Preserve static and prototype chains\n Object.setPrototypeOf(WrappedGoogleGenAI, Original);\n Object.setPrototypeOf(WrappedGoogleGenAI.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(WrappedGoogleGenAI, key, descriptor);\n }\n }\n }\n\n // Replace google genai exports with the wrapped constructor\n replaceExports(exports, 'GoogleGenAI', WrappedGoogleGenAI);\n\n return exports;\n }\n}\n"],"names":["exports"],"mappings":";;;AAeA,MAAM,iBAAA,GAAoB,CAAC,aAAa,CAAC;;AAEzC;AACA;AACA;;AAQA;AACA;AACA;AACO,MAAM,gCAAA,SAAyC,mBAAmB,CAAoC;AAC7G,GAAS,WAAW,CAAC,MAAM,GAAsC,EAAE,EAAE;AACrE,IAAI,KAAK,CAAC,sCAAsC,EAAE,WAAW,EAAE,MAAM,CAAC;AACtE,EAAE;;AAEF;AACA;AACA;AACA,GAAS,IAAI,GAAoC;AACjD,IAAI,MAAM,MAAA,GAAS,IAAI,mCAAmC;AAC1D,MAAM,eAAe;AACrB,MAAM,iBAAiB;AACvB,MAAMA,aAAW,IAAI,CAAC,MAAM,CAACA,SAAO,CAAC;AACrC,MAAMA,SAAA,IAAWA,SAAO;AACxB;AACA;AACA;AACA;AACA,MAAM;AACN,QAAQ,IAAI,6BAA6B;AACzC,UAAU,mCAAmC;AAC7C,UAAU,iBAAiB;AAC3B,UAAUA,aAAW,IAAI,CAAC,MAAM,CAACA,SAAO,CAAC;AACzC,UAAUA,SAAA,IAAWA,SAAO;AAC5B,SAAS;AACT,OAAO;AACP,KAAK;AACL,IAAI,OAAO,MAAM;AACjB,EAAE;;AAEF;AACA;AACA;AACA,GAAU,MAAM,CAACA,SAAO,EAAqD;AAC7E,IAAI,MAAM,QAAA,GAAWA,SAAO,C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
1
|
+
import { SpanStatusCode } from '@opentelemetry/api';
|
|
2
|
+
import { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql';
|
|
3
|
+
import { spanToJSON, getRootSpan, defineIntegration } from '@sentry/core';
|
|
4
|
+
import { generateInstrumentOnce, addOriginToSpan } from '@sentry/node-core';
|
|
5
|
+
import { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';
|
|
6
|
+
|
|
7
|
+
const INTEGRATION_NAME = 'Graphql';
|
|
8
|
+
|
|
9
|
+
const instrumentGraphql = generateInstrumentOnce(
|
|
10
|
+
INTEGRATION_NAME,
|
|
11
|
+
GraphQLInstrumentation,
|
|
12
|
+
(_options) => {
|
|
13
|
+
const options = getOptionsWithDefaults(_options);
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
...options,
|
|
17
|
+
responseHook(span, result) {
|
|
18
|
+
addOriginToSpan(span, 'auto.graphql.otel.graphql');
|
|
19
|
+
|
|
20
|
+
// We want to ensure spans are marked as errored if there are errors in the result
|
|
21
|
+
// We only do that if the span is not already marked with a status
|
|
22
|
+
const resultWithMaybeError = result ;
|
|
23
|
+
if (resultWithMaybeError.errors?.length && !spanToJSON(span).status) {
|
|
24
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const attributes = spanToJSON(span).data;
|
|
28
|
+
|
|
29
|
+
// If operation.name is not set, we fall back to use operation.type only
|
|
30
|
+
const operationType = attributes['graphql.operation.type'];
|
|
31
|
+
const operationName = attributes['graphql.operation.name'];
|
|
32
|
+
|
|
33
|
+
if (options.useOperationNameForRootSpan && operationType) {
|
|
34
|
+
const rootSpan = getRootSpan(span);
|
|
35
|
+
const rootSpanAttributes = spanToJSON(rootSpan).data;
|
|
36
|
+
|
|
37
|
+
const existingOperations = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION] || [];
|
|
38
|
+
|
|
39
|
+
const newOperation = operationName ? `${operationType} ${operationName}` : `${operationType}`;
|
|
40
|
+
|
|
41
|
+
// We keep track of each operation on the root span
|
|
42
|
+
// This can either be a string, or an array of strings (if there are multiple operations)
|
|
43
|
+
if (Array.isArray(existingOperations)) {
|
|
44
|
+
(existingOperations ).push(newOperation);
|
|
45
|
+
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, existingOperations);
|
|
46
|
+
} else if (typeof existingOperations === 'string') {
|
|
47
|
+
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);
|
|
48
|
+
} else {
|
|
49
|
+
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, newOperation);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!spanToJSON(rootSpan).data['original-description']) {
|
|
53
|
+
rootSpan.setAttribute('original-description', spanToJSON(rootSpan).description);
|
|
54
|
+
}
|
|
55
|
+
// Important for e.g. @sentry/aws-serverless because this would otherwise overwrite the name again
|
|
56
|
+
rootSpan.updateName(
|
|
57
|
+
`${spanToJSON(rootSpan).data['original-description']} (${getGraphqlOperationNamesFromAttribute(
|
|
58
|
+
existingOperations,
|
|
59
|
+
)})`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const _graphqlIntegration = ((options = {}) => {
|
|
68
|
+
return {
|
|
69
|
+
name: INTEGRATION_NAME,
|
|
70
|
+
setupOnce() {
|
|
71
|
+
// We set defaults here, too, because otherwise we'd update the instrumentation config
|
|
72
|
+
// to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`
|
|
73
|
+
// when being called the second time
|
|
74
|
+
instrumentGraphql(getOptionsWithDefaults(options));
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}) ;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.
|
|
81
|
+
*
|
|
82
|
+
* For more information, see the [`graphqlIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).
|
|
83
|
+
*
|
|
84
|
+
* @param {GraphqlOptions} options Configuration options for the GraphQL integration.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```javascript
|
|
88
|
+
* const Sentry = require('@sentry/node');
|
|
89
|
+
*
|
|
90
|
+
* Sentry.init({
|
|
91
|
+
* integrations: [Sentry.graphqlIntegration()],
|
|
92
|
+
* });
|
|
93
|
+
*/
|
|
94
|
+
const graphqlIntegration = defineIntegration(_graphqlIntegration);
|
|
95
|
+
|
|
96
|
+
function getOptionsWithDefaults(options) {
|
|
97
|
+
return {
|
|
98
|
+
ignoreResolveSpans: true,
|
|
99
|
+
ignoreTrivialResolveSpans: true,
|
|
100
|
+
useOperationNameForRootSpan: true,
|
|
101
|
+
...options,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// copy from packages/opentelemetry/utils
|
|
106
|
+
function getGraphqlOperationNamesFromAttribute(attr) {
|
|
107
|
+
if (Array.isArray(attr)) {
|
|
108
|
+
// oxlint-disable-next-line typescript/require-array-sort-compare
|
|
109
|
+
const sorted = attr.slice().sort();
|
|
110
|
+
|
|
111
|
+
// Up to 5 items, we just add all of them
|
|
112
|
+
if (sorted.length <= 5) {
|
|
113
|
+
return sorted.join(', ');
|
|
114
|
+
} else {
|
|
115
|
+
// Else, we add the first 5 and the diff of other operations
|
|
116
|
+
return `${sorted.slice(0, 5).join(', ')}, +${sorted.length - 5}`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return `${attr}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { graphqlIntegration, instrumentGraphql };
|
|
124
|
+
//# sourceMappingURL=graphql.js.map
|