@sentry/node 10.61.0 → 10.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/integrations/featureFlagShims/launchDarkly.js.map +1 -1
- package/build/cjs/integrations/featureFlagShims/openFeature.js.map +1 -1
- package/build/cjs/integrations/featureFlagShims/statsig.js.map +1 -1
- package/build/cjs/integrations/featureFlagShims/unleash.js.map +1 -1
- package/build/cjs/integrations/fs/index.js.map +1 -1
- package/build/cjs/integrations/http.js.map +1 -1
- package/build/cjs/integrations/node-fetch/index.js +7 -49
- package/build/cjs/integrations/node-fetch/index.js.map +1 -1
- package/build/cjs/integrations/node-fetch/undici-instrumentation.js +266 -0
- package/build/cjs/integrations/node-fetch/undici-instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/amqplib/index.js +2 -10
- package/build/cjs/integrations/tracing/amqplib/index.js.map +1 -1
- package/build/cjs/integrations/tracing/amqplib/vendored/instrumentation.js +117 -0
- package/build/cjs/integrations/tracing/amqplib/vendored/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/amqplib/vendored/patches.js +185 -0
- package/build/cjs/integrations/tracing/amqplib/vendored/patches.js.map +1 -0
- package/build/cjs/integrations/tracing/amqplib/vendored/semconv.js +21 -1
- package/build/cjs/integrations/tracing/amqplib/vendored/semconv.js.map +1 -1
- package/build/cjs/integrations/tracing/amqplib/vendored/types.js +0 -6
- package/build/cjs/integrations/tracing/amqplib/vendored/types.js.map +1 -1
- package/build/cjs/integrations/tracing/amqplib/vendored/utils.js +71 -80
- package/build/cjs/integrations/tracing/amqplib/vendored/utils.js.map +1 -1
- package/build/cjs/integrations/tracing/connect/index.js.map +1 -1
- package/build/cjs/integrations/tracing/dataloader/index.js.map +1 -1
- package/build/cjs/integrations/tracing/express.js.map +1 -1
- package/build/cjs/integrations/tracing/fastify/index.js +7 -103
- package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
- package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js +2 -3
- package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/firebase/firebase.js +1 -24
- package/build/cjs/integrations/tracing/firebase/firebase.js.map +1 -1
- package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js +3 -11
- package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js +33 -72
- package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -1
- package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js +46 -105
- package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js.map +1 -1
- package/build/cjs/integrations/tracing/genericPool/index.js.map +1 -1
- package/build/cjs/integrations/tracing/graphql/index.js.map +1 -1
- package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
- package/build/cjs/integrations/tracing/hono/index.js.map +1 -1
- package/build/cjs/integrations/tracing/index.js +0 -1
- package/build/cjs/integrations/tracing/index.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka/index.js.map +1 -1
- package/build/cjs/integrations/tracing/knex/index.js.map +1 -1
- package/build/cjs/integrations/tracing/koa/index.js.map +1 -1
- package/build/cjs/integrations/tracing/lrumemoizer/index.js.map +1 -1
- package/build/cjs/integrations/tracing/lrumemoizer/vendored/instrumentation.js +4 -2
- package/build/cjs/integrations/tracing/lrumemoizer/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/mongo/index.js.map +1 -1
- package/build/cjs/integrations/tracing/mongoose/index.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql/index.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql/vendored/instrumentation.js +34 -128
- package/build/cjs/integrations/tracing/mysql/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql/vendored/semconv.js +0 -2
- package/build/cjs/integrations/tracing/mysql/vendored/semconv.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql/vendored/utils.js +2 -27
- package/build/cjs/integrations/tracing/mysql/vendored/utils.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql2/index.js.map +1 -1
- package/build/cjs/integrations/tracing/postgres/index.js.map +1 -1
- package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma/index.js +1 -10
- package/build/cjs/integrations/tracing/prisma/index.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma/vendored/active-tracing-helper.js +83 -57
- package/build/cjs/integrations/tracing/prisma/vendored/active-tracing-helper.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma/vendored/constants.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma/vendored/global.js +2 -2
- package/build/cjs/integrations/tracing/prisma/vendored/global.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma/vendored/instrumentation.js +1 -6
- package/build/cjs/integrations/tracing/prisma/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/redis/index.js +5 -3
- package/build/cjs/integrations/tracing/redis/index.js.map +1 -1
- package/build/cjs/integrations/tracing/tedious/index.js.map +1 -1
- package/build/cjs/integrations/tracing/vercelai/constants.js.map +1 -1
- package/build/cjs/integrations/tracing/vercelai/index.js +4 -3
- package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -1
- package/build/cjs/sdk/diagnosticsChannelInjection.js.map +1 -1
- package/build/cjs/sdk/experimentalUseDiagnosticsChannelInjection.js +8 -6
- package/build/cjs/sdk/experimentalUseDiagnosticsChannelInjection.js.map +1 -1
- package/build/esm/integrations/featureFlagShims/launchDarkly.js.map +1 -1
- package/build/esm/integrations/featureFlagShims/openFeature.js.map +1 -1
- package/build/esm/integrations/featureFlagShims/statsig.js.map +1 -1
- package/build/esm/integrations/featureFlagShims/unleash.js.map +1 -1
- package/build/esm/integrations/fs/index.js.map +1 -1
- package/build/esm/integrations/http.js.map +1 -1
- package/build/esm/integrations/node-fetch/index.js +9 -50
- package/build/esm/integrations/node-fetch/index.js.map +1 -1
- package/build/esm/integrations/node-fetch/undici-instrumentation.js +264 -0
- package/build/esm/integrations/node-fetch/undici-instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/amqplib/index.js +3 -11
- package/build/esm/integrations/tracing/amqplib/index.js.map +1 -1
- package/build/esm/integrations/tracing/amqplib/vendored/instrumentation.js +115 -0
- package/build/esm/integrations/tracing/amqplib/vendored/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/amqplib/vendored/patches.js +177 -0
- package/build/esm/integrations/tracing/amqplib/vendored/patches.js.map +1 -0
- package/build/esm/integrations/tracing/amqplib/vendored/semconv.js +12 -2
- package/build/esm/integrations/tracing/amqplib/vendored/semconv.js.map +1 -1
- package/build/esm/integrations/tracing/amqplib/vendored/types.js +1 -6
- package/build/esm/integrations/tracing/amqplib/vendored/types.js.map +1 -1
- package/build/esm/integrations/tracing/amqplib/vendored/utils.js +68 -78
- package/build/esm/integrations/tracing/amqplib/vendored/utils.js.map +1 -1
- package/build/esm/integrations/tracing/connect/index.js.map +1 -1
- package/build/esm/integrations/tracing/dataloader/index.js.map +1 -1
- package/build/esm/integrations/tracing/express.js.map +1 -1
- package/build/esm/integrations/tracing/fastify/index.js +8 -103
- package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
- package/build/esm/integrations/tracing/fastify/v3/instrumentation.js +3 -4
- package/build/esm/integrations/tracing/fastify/v3/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/firebase/firebase.js +3 -26
- package/build/esm/integrations/tracing/firebase/firebase.js.map +1 -1
- package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js +3 -11
- package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js +34 -73
- package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -1
- package/build/esm/integrations/tracing/firebase/otel/patches/functions.js +47 -106
- package/build/esm/integrations/tracing/firebase/otel/patches/functions.js.map +1 -1
- package/build/esm/integrations/tracing/genericPool/index.js.map +1 -1
- package/build/esm/integrations/tracing/graphql/index.js.map +1 -1
- package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
- package/build/esm/integrations/tracing/hono/index.js.map +1 -1
- package/build/esm/integrations/tracing/index.js +1 -2
- package/build/esm/integrations/tracing/index.js.map +1 -1
- package/build/esm/integrations/tracing/kafka/index.js.map +1 -1
- package/build/esm/integrations/tracing/knex/index.js.map +1 -1
- package/build/esm/integrations/tracing/koa/index.js.map +1 -1
- package/build/esm/integrations/tracing/lrumemoizer/index.js.map +1 -1
- package/build/esm/integrations/tracing/lrumemoizer/vendored/instrumentation.js +5 -3
- package/build/esm/integrations/tracing/lrumemoizer/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/mongo/index.js.map +1 -1
- package/build/esm/integrations/tracing/mongoose/index.js.map +1 -1
- package/build/esm/integrations/tracing/mysql/index.js.map +1 -1
- package/build/esm/integrations/tracing/mysql/vendored/instrumentation.js +37 -131
- package/build/esm/integrations/tracing/mysql/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/mysql/vendored/semconv.js +1 -2
- package/build/esm/integrations/tracing/mysql/vendored/semconv.js.map +1 -1
- package/build/esm/integrations/tracing/mysql/vendored/utils.js +3 -25
- package/build/esm/integrations/tracing/mysql/vendored/utils.js.map +1 -1
- package/build/esm/integrations/tracing/mysql2/index.js.map +1 -1
- package/build/esm/integrations/tracing/postgres/index.js.map +1 -1
- package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
- package/build/esm/integrations/tracing/prisma/index.js +2 -11
- package/build/esm/integrations/tracing/prisma/index.js.map +1 -1
- package/build/esm/integrations/tracing/prisma/vendored/active-tracing-helper.js +83 -57
- package/build/esm/integrations/tracing/prisma/vendored/active-tracing-helper.js.map +1 -1
- package/build/esm/integrations/tracing/prisma/vendored/constants.js.map +1 -1
- package/build/esm/integrations/tracing/prisma/vendored/global.js +2 -2
- package/build/esm/integrations/tracing/prisma/vendored/global.js.map +1 -1
- package/build/esm/integrations/tracing/prisma/vendored/instrumentation.js +1 -6
- package/build/esm/integrations/tracing/prisma/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/redis/index.js +7 -5
- package/build/esm/integrations/tracing/redis/index.js.map +1 -1
- package/build/esm/integrations/tracing/tedious/index.js.map +1 -1
- package/build/esm/integrations/tracing/vercelai/constants.js.map +1 -1
- package/build/esm/integrations/tracing/vercelai/index.js +5 -4
- package/build/esm/integrations/tracing/vercelai/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/sdk/diagnosticsChannelInjection.js.map +1 -1
- package/build/esm/sdk/experimentalUseDiagnosticsChannelInjection.js +9 -7
- package/build/esm/sdk/experimentalUseDiagnosticsChannelInjection.js.map +1 -1
- package/build/types/integrations/featureFlagShims/launchDarkly.d.ts +3 -1
- package/build/types/integrations/featureFlagShims/launchDarkly.d.ts.map +1 -1
- package/build/types/integrations/featureFlagShims/openFeature.d.ts +3 -1
- package/build/types/integrations/featureFlagShims/openFeature.d.ts.map +1 -1
- package/build/types/integrations/featureFlagShims/statsig.d.ts +3 -1
- package/build/types/integrations/featureFlagShims/statsig.d.ts.map +1 -1
- package/build/types/integrations/featureFlagShims/unleash.d.ts +3 -1
- package/build/types/integrations/featureFlagShims/unleash.d.ts.map +1 -1
- package/build/types/integrations/fs/index.d.ts +3 -1
- package/build/types/integrations/fs/index.d.ts.map +1 -1
- package/build/types/integrations/http.d.ts +3 -1
- package/build/types/integrations/http.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/index.d.ts +4 -35
- package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/types.d.ts +96 -0
- package/build/types/integrations/node-fetch/types.d.ts.map +1 -0
- package/build/types/integrations/node-fetch/undici-instrumentation.d.ts +14 -0
- package/build/types/integrations/node-fetch/undici-instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/amqplib/index.d.ts +4 -2
- package/build/types/integrations/tracing/amqplib/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/amqplib/vendored/instrumentation.d.ts +11 -0
- package/build/types/integrations/tracing/amqplib/vendored/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/amqplib/vendored/patches.d.ts +11 -0
- package/build/types/integrations/tracing/amqplib/vendored/patches.d.ts.map +1 -0
- package/build/types/integrations/tracing/amqplib/vendored/semconv.d.ts +25 -37
- package/build/types/integrations/tracing/amqplib/vendored/semconv.d.ts.map +1 -1
- package/build/types/integrations/tracing/amqplib/vendored/types.d.ts +0 -81
- package/build/types/integrations/tracing/amqplib/vendored/types.d.ts.map +1 -1
- package/build/types/integrations/tracing/amqplib/vendored/utils.d.ts +16 -9
- package/build/types/integrations/tracing/amqplib/vendored/utils.d.ts.map +1 -1
- package/build/types/integrations/tracing/anthropic-ai/index.d.ts +3 -1
- package/build/types/integrations/tracing/anthropic-ai/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/connect/index.d.ts +3 -1
- package/build/types/integrations/tracing/connect/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/dataloader/index.d.ts +3 -1
- package/build/types/integrations/tracing/dataloader/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/express.d.ts +3 -1
- package/build/types/integrations/tracing/express.d.ts.map +1 -1
- package/build/types/integrations/tracing/fastify/index.d.ts +6 -6
- package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/firebase/firebase.d.ts +3 -1
- package/build/types/integrations/tracing/firebase/firebase.d.ts.map +1 -1
- package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +4 -9
- package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts +2 -5
- package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts.map +1 -1
- package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts +3 -8
- package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts.map +1 -1
- package/build/types/integrations/tracing/firebase/otel/types.d.ts +0 -20
- package/build/types/integrations/tracing/firebase/otel/types.d.ts.map +1 -1
- package/build/types/integrations/tracing/genericPool/index.d.ts +3 -1
- package/build/types/integrations/tracing/genericPool/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/google-genai/index.d.ts +3 -1
- package/build/types/integrations/tracing/google-genai/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/graphql/index.d.ts +3 -1
- package/build/types/integrations/tracing/graphql/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/hapi/index.d.ts +3 -1
- package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/hono/index.d.ts +3 -1
- package/build/types/integrations/tracing/hono/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/index.d.ts +3 -1
- package/build/types/integrations/tracing/kafka/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/knex/index.d.ts +3 -1
- package/build/types/integrations/tracing/knex/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/koa/index.d.ts +3 -1
- package/build/types/integrations/tracing/koa/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/langchain/index.d.ts +3 -1
- package/build/types/integrations/tracing/langchain/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/langgraph/index.d.ts +3 -1
- package/build/types/integrations/tracing/langgraph/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/lrumemoizer/index.d.ts +3 -1
- package/build/types/integrations/tracing/lrumemoizer/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/lrumemoizer/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongo/index.d.ts +3 -1
- package/build/types/integrations/tracing/mongo/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongoose/index.d.ts +3 -1
- package/build/types/integrations/tracing/mongoose/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql/index.d.ts +3 -1
- package/build/types/integrations/tracing/mysql/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql/vendored/instrumentation.d.ts +3 -17
- package/build/types/integrations/tracing/mysql/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql/vendored/mysql-types.d.ts +16 -16
- package/build/types/integrations/tracing/mysql/vendored/mysql-types.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql/vendored/semconv.d.ts +0 -8
- package/build/types/integrations/tracing/mysql/vendored/semconv.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql/vendored/utils.d.ts +6 -9
- package/build/types/integrations/tracing/mysql/vendored/utils.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql2/index.d.ts +3 -1
- package/build/types/integrations/tracing/mysql2/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/openai/index.d.ts +3 -1
- package/build/types/integrations/tracing/openai/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgres/index.d.ts +3 -1
- package/build/types/integrations/tracing/postgres/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgresjs.d.ts +3 -1
- package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma/index.d.ts +5 -21
- package/build/types/integrations/tracing/prisma/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma/vendored/active-tracing-helper.d.ts +5 -7
- package/build/types/integrations/tracing/prisma/vendored/active-tracing-helper.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma/vendored/constants.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma/vendored/global.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma/vendored/instrumentation.d.ts +2 -4
- package/build/types/integrations/tracing/prisma/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma/vendored/types.d.ts +5 -23
- package/build/types/integrations/tracing/prisma/vendored/types.d.ts.map +1 -1
- package/build/types/integrations/tracing/redis/index.d.ts +4 -2
- package/build/types/integrations/tracing/redis/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/tedious/index.d.ts +3 -1
- package/build/types/integrations/tracing/tedious/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/vercelai/constants.d.ts +1 -1
- package/build/types/integrations/tracing/vercelai/constants.d.ts.map +1 -1
- package/build/types/integrations/tracing/vercelai/index.d.ts +3 -2
- package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -1
- package/build/types/sdk/diagnosticsChannelInjection.d.ts +1 -1
- package/build/types/sdk/diagnosticsChannelInjection.d.ts.map +1 -1
- package/build/types/sdk/experimentalUseDiagnosticsChannelInjection.d.ts.map +1 -1
- package/build/types-ts3.8/integrations/featureFlagShims/launchDarkly.d.ts +3 -1
- package/build/types-ts3.8/integrations/featureFlagShims/openFeature.d.ts +3 -1
- package/build/types-ts3.8/integrations/featureFlagShims/statsig.d.ts +3 -1
- package/build/types-ts3.8/integrations/featureFlagShims/unleash.d.ts +3 -1
- package/build/types-ts3.8/integrations/fs/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/http.d.ts +3 -1
- package/build/types-ts3.8/integrations/node-fetch/index.d.ts +4 -35
- package/build/types-ts3.8/integrations/node-fetch/types.d.ts +96 -0
- package/build/types-ts3.8/integrations/node-fetch/undici-instrumentation.d.ts +14 -0
- package/build/types-ts3.8/integrations/tracing/amqplib/index.d.ts +4 -2
- package/build/types-ts3.8/integrations/tracing/amqplib/vendored/instrumentation.d.ts +11 -0
- package/build/types-ts3.8/integrations/tracing/amqplib/vendored/patches.d.ts +11 -0
- package/build/types-ts3.8/integrations/tracing/amqplib/vendored/semconv.d.ts +25 -37
- package/build/types-ts3.8/integrations/tracing/amqplib/vendored/types.d.ts +0 -81
- package/build/types-ts3.8/integrations/tracing/amqplib/vendored/utils.d.ts +16 -9
- package/build/types-ts3.8/integrations/tracing/anthropic-ai/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/connect/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/dataloader/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/express.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/fastify/index.d.ts +6 -6
- package/build/types-ts3.8/integrations/tracing/firebase/firebase.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +4 -9
- package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/firestore.d.ts +2 -5
- package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/functions.d.ts +3 -8
- package/build/types-ts3.8/integrations/tracing/firebase/otel/types.d.ts +0 -20
- package/build/types-ts3.8/integrations/tracing/genericPool/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/google-genai/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/graphql/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/hapi/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/hono/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/kafka/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/knex/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/koa/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/langchain/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/langgraph/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/lrumemoizer/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/mongo/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/mongoose/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/mysql/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/mysql/vendored/instrumentation.d.ts +3 -17
- package/build/types-ts3.8/integrations/tracing/mysql/vendored/mysql-types.d.ts +16 -16
- package/build/types-ts3.8/integrations/tracing/mysql/vendored/semconv.d.ts +0 -8
- package/build/types-ts3.8/integrations/tracing/mysql/vendored/utils.d.ts +6 -9
- package/build/types-ts3.8/integrations/tracing/mysql2/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/openai/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/postgres/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/postgresjs.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/prisma/index.d.ts +5 -21
- package/build/types-ts3.8/integrations/tracing/prisma/vendored/active-tracing-helper.d.ts +5 -7
- package/build/types-ts3.8/integrations/tracing/prisma/vendored/instrumentation.d.ts +2 -4
- package/build/types-ts3.8/integrations/tracing/prisma/vendored/types.d.ts +5 -23
- package/build/types-ts3.8/integrations/tracing/redis/index.d.ts +4 -2
- package/build/types-ts3.8/integrations/tracing/tedious/index.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing/vercelai/constants.d.ts +1 -1
- package/build/types-ts3.8/integrations/tracing/vercelai/index.d.ts +3 -2
- package/build/types-ts3.8/sdk/diagnosticsChannelInjection.d.ts +1 -1
- package/package.json +6 -5
- package/build/cjs/integrations/node-fetch/vendored/semconv.js +0 -28
- package/build/cjs/integrations/node-fetch/vendored/semconv.js.map +0 -1
- package/build/cjs/integrations/node-fetch/vendored/undici.js +0 -302
- package/build/cjs/integrations/node-fetch/vendored/undici.js.map +0 -1
- package/build/cjs/integrations/tracing/amqplib/vendored/amqplib.js +0 -452
- package/build/cjs/integrations/tracing/amqplib/vendored/amqplib.js.map +0 -1
- package/build/cjs/integrations/tracing/amqplib/vendored/semconv-obsolete.js +0 -24
- package/build/cjs/integrations/tracing/amqplib/vendored/semconv-obsolete.js.map +0 -1
- package/build/cjs/integrations/tracing/fastify/vendored/instrumentation.js +0 -387
- package/build/cjs/integrations/tracing/fastify/vendored/instrumentation.js.map +0 -1
- package/build/cjs/integrations/tracing/mysql/vendored/AttributeNames.js +0 -9
- package/build/cjs/integrations/tracing/mysql/vendored/AttributeNames.js.map +0 -1
- package/build/esm/integrations/node-fetch/vendored/semconv.js +0 -15
- package/build/esm/integrations/node-fetch/vendored/semconv.js.map +0 -1
- package/build/esm/integrations/node-fetch/vendored/undici.js +0 -300
- package/build/esm/integrations/node-fetch/vendored/undici.js.map +0 -1
- package/build/esm/integrations/tracing/amqplib/vendored/amqplib.js +0 -450
- package/build/esm/integrations/tracing/amqplib/vendored/amqplib.js.map +0 -1
- package/build/esm/integrations/tracing/amqplib/vendored/semconv-obsolete.js +0 -13
- package/build/esm/integrations/tracing/amqplib/vendored/semconv-obsolete.js.map +0 -1
- package/build/esm/integrations/tracing/fastify/vendored/instrumentation.js +0 -385
- package/build/esm/integrations/tracing/fastify/vendored/instrumentation.js.map +0 -1
- package/build/esm/integrations/tracing/mysql/vendored/AttributeNames.js +0 -7
- package/build/esm/integrations/tracing/mysql/vendored/AttributeNames.js.map +0 -1
- package/build/types/integrations/node-fetch/vendored/internal-types.d.ts +0 -25
- package/build/types/integrations/node-fetch/vendored/internal-types.d.ts.map +0 -1
- package/build/types/integrations/node-fetch/vendored/semconv.d.ts +0 -13
- package/build/types/integrations/node-fetch/vendored/semconv.d.ts.map +0 -1
- package/build/types/integrations/node-fetch/vendored/types.d.ts +0 -60
- package/build/types/integrations/node-fetch/vendored/types.d.ts.map +0 -1
- package/build/types/integrations/node-fetch/vendored/undici.d.ts +0 -21
- package/build/types/integrations/node-fetch/vendored/undici.d.ts.map +0 -1
- package/build/types/integrations/tracing/amqplib/vendored/amqplib.d.ts +0 -26
- package/build/types/integrations/tracing/amqplib/vendored/amqplib.d.ts.map +0 -1
- package/build/types/integrations/tracing/amqplib/vendored/semconv-obsolete.d.ts +0 -63
- package/build/types/integrations/tracing/amqplib/vendored/semconv-obsolete.d.ts.map +0 -1
- package/build/types/integrations/tracing/fastify/vendored/instrumentation.d.ts +0 -27
- package/build/types/integrations/tracing/fastify/vendored/instrumentation.d.ts.map +0 -1
- package/build/types/integrations/tracing/mysql/vendored/AttributeNames.d.ts +0 -4
- package/build/types/integrations/tracing/mysql/vendored/AttributeNames.d.ts.map +0 -1
- package/build/types/integrations/tracing/mysql/vendored/types.d.ts +0 -9
- package/build/types/integrations/tracing/mysql/vendored/types.d.ts.map +0 -1
- package/build/types-ts3.8/integrations/node-fetch/vendored/internal-types.d.ts +0 -25
- package/build/types-ts3.8/integrations/node-fetch/vendored/semconv.d.ts +0 -13
- package/build/types-ts3.8/integrations/node-fetch/vendored/types.d.ts +0 -60
- package/build/types-ts3.8/integrations/node-fetch/vendored/undici.d.ts +0 -21
- package/build/types-ts3.8/integrations/tracing/amqplib/vendored/amqplib.d.ts +0 -26
- package/build/types-ts3.8/integrations/tracing/amqplib/vendored/semconv-obsolete.d.ts +0 -63
- package/build/types-ts3.8/integrations/tracing/fastify/vendored/instrumentation.d.ts +0 -27
- package/build/types-ts3.8/integrations/tracing/mysql/vendored/AttributeNames.d.ts +0 -4
- package/build/types-ts3.8/integrations/tracing/mysql/vendored/types.d.ts +0 -9
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
import * as net from 'node:net';
|
|
2
|
-
import {
|
|
3
|
-
import { InstrumentationNodeModuleDefinition, isWrapped, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';
|
|
4
3
|
import { InstrumentationNodeModuleFile } from '../../../InstrumentationNodeModuleFile.js';
|
|
5
4
|
import { ATTR_DB_OPERATION_NAME, ATTR_DB_NAMESPACE, ATTR_DB_COLLECTION_NAME, ATTR_DB_SYSTEM_NAME, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT } from '@opentelemetry/semantic-conventions';
|
|
5
|
+
import { startSpan, SPAN_KIND, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
6
6
|
|
|
7
|
-
function patchFirestore(
|
|
8
|
-
const defaultFirestoreSpanCreationHook = () => {
|
|
9
|
-
};
|
|
10
|
-
let firestoreSpanCreationHook = defaultFirestoreSpanCreationHook;
|
|
11
|
-
const configFirestoreSpanCreationHook = config.firestoreSpanCreationHook;
|
|
12
|
-
if (typeof configFirestoreSpanCreationHook === "function") {
|
|
13
|
-
firestoreSpanCreationHook = (span) => {
|
|
14
|
-
safeExecuteInTheMiddle(
|
|
15
|
-
() => configFirestoreSpanCreationHook(span),
|
|
16
|
-
(error) => {
|
|
17
|
-
if (!error) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
diag.error(error?.message);
|
|
21
|
-
},
|
|
22
|
-
true
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
7
|
+
function patchFirestore(firestoreSupportedVersions, wrap, unwrap) {
|
|
26
8
|
const moduleFirestoreCJS = new InstrumentationNodeModuleDefinition(
|
|
27
9
|
"@firebase/firestore",
|
|
28
10
|
firestoreSupportedVersions,
|
|
29
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
-
(moduleExports) => wrapMethods(moduleExports, wrap, unwrap
|
|
12
|
+
(moduleExports) => wrapMethods(moduleExports, wrap, unwrap)
|
|
31
13
|
);
|
|
32
14
|
const files = [
|
|
33
15
|
"@firebase/firestore/dist/lite/index.node.cjs.js",
|
|
@@ -40,19 +22,19 @@ function patchFirestore(tracer, firestoreSupportedVersions, wrap, unwrap, config
|
|
|
40
22
|
new InstrumentationNodeModuleFile(
|
|
41
23
|
file,
|
|
42
24
|
firestoreSupportedVersions,
|
|
43
|
-
(moduleExports) => wrapMethods(moduleExports, wrap, unwrap
|
|
25
|
+
(moduleExports) => wrapMethods(moduleExports, wrap, unwrap),
|
|
44
26
|
(moduleExports) => unwrapMethods(moduleExports, unwrap)
|
|
45
27
|
)
|
|
46
28
|
);
|
|
47
29
|
}
|
|
48
30
|
return moduleFirestoreCJS;
|
|
49
31
|
}
|
|
50
|
-
function wrapMethods(moduleExports, wrap, unwrap
|
|
32
|
+
function wrapMethods(moduleExports, wrap, unwrap) {
|
|
51
33
|
unwrapMethods(moduleExports, unwrap);
|
|
52
|
-
wrap(moduleExports, "addDoc", patchAddDoc(
|
|
53
|
-
wrap(moduleExports, "getDocs", patchGetDocs(
|
|
54
|
-
wrap(moduleExports, "setDoc", patchSetDoc(
|
|
55
|
-
wrap(moduleExports, "deleteDoc", patchDeleteDoc(
|
|
34
|
+
wrap(moduleExports, "addDoc", patchAddDoc());
|
|
35
|
+
wrap(moduleExports, "getDocs", patchGetDocs());
|
|
36
|
+
wrap(moduleExports, "setDoc", patchSetDoc());
|
|
37
|
+
wrap(moduleExports, "deleteDoc", patchDeleteDoc());
|
|
56
38
|
return moduleExports;
|
|
57
39
|
}
|
|
58
40
|
function unwrapMethods(moduleExports, unwrap) {
|
|
@@ -63,71 +45,50 @@ function unwrapMethods(moduleExports, unwrap) {
|
|
|
63
45
|
}
|
|
64
46
|
return moduleExports;
|
|
65
47
|
}
|
|
66
|
-
function patchAddDoc(
|
|
48
|
+
function patchAddDoc() {
|
|
67
49
|
return function addDoc(original) {
|
|
68
50
|
return function(reference, data) {
|
|
69
|
-
|
|
70
|
-
firestoreSpanCreationHook(span);
|
|
71
|
-
return executeContextWithSpan(span, () => {
|
|
72
|
-
return original(reference, data);
|
|
73
|
-
});
|
|
51
|
+
return startFirestoreSpan("addDoc", reference, () => original(reference, data));
|
|
74
52
|
};
|
|
75
53
|
};
|
|
76
54
|
}
|
|
77
|
-
function patchDeleteDoc(
|
|
55
|
+
function patchDeleteDoc() {
|
|
78
56
|
return function deleteDoc(original) {
|
|
79
57
|
return function(reference) {
|
|
80
|
-
|
|
81
|
-
firestoreSpanCreationHook(span);
|
|
82
|
-
return executeContextWithSpan(span, () => {
|
|
83
|
-
return original(reference);
|
|
84
|
-
});
|
|
58
|
+
return startFirestoreSpan("deleteDoc", reference.parent || reference, () => original(reference));
|
|
85
59
|
};
|
|
86
60
|
};
|
|
87
61
|
}
|
|
88
|
-
function patchGetDocs(
|
|
62
|
+
function patchGetDocs() {
|
|
89
63
|
return function getDocs(original) {
|
|
90
64
|
return function(reference) {
|
|
91
|
-
|
|
92
|
-
firestoreSpanCreationHook(span);
|
|
93
|
-
return executeContextWithSpan(span, () => {
|
|
94
|
-
return original(reference);
|
|
95
|
-
});
|
|
65
|
+
return startFirestoreSpan("getDocs", reference, () => original(reference));
|
|
96
66
|
};
|
|
97
67
|
};
|
|
98
68
|
}
|
|
99
|
-
function patchSetDoc(
|
|
69
|
+
function patchSetDoc() {
|
|
100
70
|
return function setDoc(original) {
|
|
101
71
|
return function(reference, data, options) {
|
|
102
|
-
|
|
103
|
-
firestoreSpanCreationHook(span);
|
|
104
|
-
return executeContextWithSpan(span, () => {
|
|
72
|
+
return startFirestoreSpan("setDoc", reference.parent || reference, () => {
|
|
105
73
|
return typeof options !== "undefined" ? original(reference, data, options) : original(reference, data);
|
|
106
74
|
});
|
|
107
75
|
};
|
|
108
76
|
};
|
|
109
77
|
}
|
|
110
|
-
function
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function startDBSpan(tracer, spanName, reference) {
|
|
127
|
-
const span = tracer.startSpan(`${spanName} ${reference.path}`, { kind: SpanKind.CLIENT });
|
|
128
|
-
addAttributes(span, reference);
|
|
129
|
-
span.setAttribute(ATTR_DB_OPERATION_NAME, spanName);
|
|
130
|
-
return span;
|
|
78
|
+
function startFirestoreSpan(spanName, reference, callback) {
|
|
79
|
+
return startSpan(
|
|
80
|
+
{
|
|
81
|
+
name: `${spanName} ${reference.path}`,
|
|
82
|
+
op: "db.query",
|
|
83
|
+
kind: SPAN_KIND.CLIENT,
|
|
84
|
+
attributes: {
|
|
85
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.firebase.otel.firestore",
|
|
86
|
+
[ATTR_DB_OPERATION_NAME]: spanName,
|
|
87
|
+
...buildAttributes(reference)
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
callback
|
|
91
|
+
);
|
|
131
92
|
}
|
|
132
93
|
function getPortAndAddress(settings) {
|
|
133
94
|
let address;
|
|
@@ -162,7 +123,7 @@ function getPortAndAddress(settings) {
|
|
|
162
123
|
port: port ? parseInt(port, 10) : void 0
|
|
163
124
|
};
|
|
164
125
|
}
|
|
165
|
-
function
|
|
126
|
+
function buildAttributes(reference) {
|
|
166
127
|
const firestoreApp = reference.firestore.app;
|
|
167
128
|
const firestoreOptions = firestoreApp.options;
|
|
168
129
|
const json = reference.firestore.toJSON() || {};
|
|
@@ -184,7 +145,7 @@ function addAttributes(span, reference) {
|
|
|
184
145
|
if (port) {
|
|
185
146
|
attributes[ATTR_SERVER_PORT] = port;
|
|
186
147
|
}
|
|
187
|
-
|
|
148
|
+
return attributes;
|
|
188
149
|
}
|
|
189
150
|
|
|
190
151
|
export { getPortAndAddress, patchFirestore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firestore.js","sources":["../../../../../../../src/integrations/tracing/firebase/otel/patches/firestore.ts"],"sourcesContent":["import * as net from 'node:net';\nimport type { Span, Tracer } from '@opentelemetry/api';\nimport { context, diag, SpanKind, trace } from '@opentelemetry/api';\nimport { InstrumentationNodeModuleDefinition, isWrapped, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleFile } from '../../../InstrumentationNodeModuleFile';\nimport {\n ATTR_DB_COLLECTION_NAME,\n ATTR_DB_NAMESPACE,\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_SYSTEM_NAME,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport type { SpanAttributes } from '@sentry/core';\nimport type { FirebaseInstrumentation } from '../firebaseInstrumentation';\nimport type {\n AddDocType,\n CollectionReference,\n DeleteDocType,\n DocumentData,\n DocumentReference,\n FirebaseApp,\n FirebaseInstrumentationConfig,\n FirebaseOptions,\n FirestoreSettings,\n FirestoreSpanCreationHook,\n GetDocsType,\n PartialWithFieldValue,\n QuerySnapshot,\n SetDocType,\n SetOptions,\n WithFieldValue,\n} from '../types';\n\n// Inline minimal types used from `shimmer` to avoid importing shimmer's types directly.\n// We only need the shape for `wrap` and `unwrap` used in this file.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ShimmerWrap = (target: any, name: string, wrapper: (...args: any[]) => any) => void;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ShimmerUnwrap = (target: any, name: string) => void;\n\n/**\n *\n * @param tracer - Opentelemetry Tracer\n * @param firestoreSupportedVersions - supported version of firebase/firestore\n * @param wrap - reference to native instrumentation wrap function\n * @param unwrap - reference to native instrumentation wrap function\n */\nexport function patchFirestore(\n tracer: Tracer,\n firestoreSupportedVersions: string[],\n wrap: ShimmerWrap,\n unwrap: ShimmerUnwrap,\n config: FirebaseInstrumentationConfig,\n): InstrumentationNodeModuleDefinition {\n const defaultFirestoreSpanCreationHook: FirestoreSpanCreationHook = () => {};\n\n let firestoreSpanCreationHook: FirestoreSpanCreationHook = defaultFirestoreSpanCreationHook;\n const configFirestoreSpanCreationHook = config.firestoreSpanCreationHook;\n\n if (typeof configFirestoreSpanCreationHook === 'function') {\n firestoreSpanCreationHook = (span: Span) => {\n safeExecuteInTheMiddle(\n () => configFirestoreSpanCreationHook(span),\n error => {\n if (!error) {\n return;\n }\n diag.error(error?.message);\n },\n true,\n );\n };\n }\n\n const moduleFirestoreCJS = new InstrumentationNodeModuleDefinition(\n '@firebase/firestore',\n firestoreSupportedVersions,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (moduleExports: any) => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook),\n );\n const files: string[] = [\n '@firebase/firestore/dist/lite/index.node.cjs.js',\n '@firebase/firestore/dist/lite/index.node.mjs.js',\n '@firebase/firestore/dist/lite/index.rn.esm2017.js',\n '@firebase/firestore/dist/lite/index.cjs.js',\n ];\n\n for (const file of files) {\n moduleFirestoreCJS.files.push(\n new InstrumentationNodeModuleFile(\n file,\n firestoreSupportedVersions,\n moduleExports => wrapMethods(moduleExports, wrap, unwrap, tracer, firestoreSpanCreationHook),\n moduleExports => unwrapMethods(moduleExports, unwrap),\n ),\n );\n }\n\n return moduleFirestoreCJS;\n}\n\nfunction wrapMethods(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n moduleExports: any,\n wrap: ShimmerWrap,\n unwrap: ShimmerUnwrap,\n tracer: Tracer,\n firestoreSpanCreationHook: FirestoreSpanCreationHook,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n unwrapMethods(moduleExports, unwrap);\n\n wrap(moduleExports, 'addDoc', patchAddDoc(tracer, firestoreSpanCreationHook));\n wrap(moduleExports, 'getDocs', patchGetDocs(tracer, firestoreSpanCreationHook));\n wrap(moduleExports, 'setDoc', patchSetDoc(tracer, firestoreSpanCreationHook));\n wrap(moduleExports, 'deleteDoc', patchDeleteDoc(tracer, firestoreSpanCreationHook));\n\n return moduleExports;\n}\n\nfunction unwrapMethods(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n moduleExports: any,\n unwrap: ShimmerUnwrap,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n for (const method of ['addDoc', 'getDocs', 'setDoc', 'deleteDoc']) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (isWrapped(moduleExports[method])) {\n unwrap(moduleExports, method);\n }\n }\n return moduleExports;\n}\n\nfunction patchAddDoc<AppModelType, DbModelType extends DocumentData>(\n tracer: Tracer,\n firestoreSpanCreationHook: FirestoreSpanCreationHook,\n): (\n original: AddDocType<AppModelType, DbModelType>,\n) => (\n this: FirebaseInstrumentation,\n reference: CollectionReference<AppModelType, DbModelType>,\n data: WithFieldValue<AppModelType>,\n) => Promise<DocumentReference<AppModelType, DbModelType>> {\n return function addDoc(original: AddDocType<AppModelType, DbModelType>) {\n return function (\n reference: CollectionReference<AppModelType, DbModelType>,\n data: WithFieldValue<AppModelType>,\n ): Promise<DocumentReference<AppModelType, DbModelType>> {\n const span = startDBSpan(tracer, 'addDoc', reference);\n firestoreSpanCreationHook(span);\n return executeContextWithSpan<Promise<DocumentReference<AppModelType, DbModelType>>>(span, () => {\n return original(reference, data);\n });\n };\n };\n}\n\nfunction patchDeleteDoc<AppModelType, DbModelType extends DocumentData>(\n tracer: Tracer,\n firestoreSpanCreationHook: FirestoreSpanCreationHook,\n): (\n original: DeleteDocType<AppModelType, DbModelType>,\n) => (this: FirebaseInstrumentation, reference: DocumentReference<AppModelType, DbModelType>) => Promise<void> {\n return function deleteDoc(original: DeleteDocType<AppModelType, DbModelType>) {\n return function (reference: DocumentReference<AppModelType, DbModelType>): Promise<void> {\n const span = startDBSpan(tracer, 'deleteDoc', reference.parent || reference);\n firestoreSpanCreationHook(span);\n return executeContextWithSpan<Promise<void>>(span, () => {\n return original(reference);\n });\n };\n };\n}\n\nfunction patchGetDocs<AppModelType, DbModelType extends DocumentData>(\n tracer: Tracer,\n firestoreSpanCreationHook: FirestoreSpanCreationHook,\n): (\n original: GetDocsType<AppModelType, DbModelType>,\n) => (\n this: FirebaseInstrumentation,\n reference: CollectionReference<AppModelType, DbModelType>,\n) => Promise<QuerySnapshot<AppModelType, DbModelType>> {\n return function getDocs(original: GetDocsType<AppModelType, DbModelType>) {\n return function (\n reference: CollectionReference<AppModelType, DbModelType>,\n ): Promise<QuerySnapshot<AppModelType, DbModelType>> {\n const span = startDBSpan(tracer, 'getDocs', reference);\n firestoreSpanCreationHook(span);\n return executeContextWithSpan<Promise<QuerySnapshot<AppModelType, DbModelType>>>(span, () => {\n return original(reference);\n });\n };\n };\n}\n\nfunction patchSetDoc<AppModelType, DbModelType extends DocumentData>(\n tracer: Tracer,\n firestoreSpanCreationHook: FirestoreSpanCreationHook,\n): (\n original: SetDocType<AppModelType, DbModelType>,\n) => (\n this: FirebaseInstrumentation,\n reference: DocumentReference<AppModelType, DbModelType>,\n data: WithFieldValue<AppModelType> & PartialWithFieldValue<AppModelType>,\n options?: SetOptions,\n) => Promise<void> {\n return function setDoc(original: SetDocType<AppModelType, DbModelType>) {\n return function (\n reference: DocumentReference<AppModelType, DbModelType>,\n data: WithFieldValue<AppModelType> & PartialWithFieldValue<AppModelType>,\n options?: SetOptions,\n ): Promise<void> {\n const span = startDBSpan(tracer, 'setDoc', reference.parent || reference);\n firestoreSpanCreationHook(span);\n\n return executeContextWithSpan<Promise<void>>(span, () => {\n return typeof options !== 'undefined' ? original(reference, data, options) : original(reference, data);\n });\n };\n };\n}\n\nfunction executeContextWithSpan<T>(span: Span, callback: () => T): T {\n return context.with(trace.setSpan(context.active(), span), () => {\n return safeExecuteInTheMiddle(\n (): T => {\n return callback();\n },\n err => {\n if (err) {\n span.recordException(err);\n }\n span.end();\n },\n true,\n );\n });\n}\n\nfunction startDBSpan<AppModelType, DbModelType extends DocumentData>(\n tracer: Tracer,\n spanName: string,\n reference: CollectionReference<AppModelType, DbModelType> | DocumentReference<AppModelType, DbModelType>,\n): Span {\n const span = tracer.startSpan(`${spanName} ${reference.path}`, { kind: SpanKind.CLIENT });\n addAttributes(span, reference);\n span.setAttribute(ATTR_DB_OPERATION_NAME, spanName);\n return span;\n}\n\n/**\n * Gets the server address and port attributes from the Firestore settings.\n * It's best effort to extract the address and port from the settings, especially for IPv6.\n * @param span - The span to set attributes on.\n * @param settings - The Firestore settings containing host information.\n */\nexport function getPortAndAddress(settings: FirestoreSettings): {\n address?: string;\n port?: number;\n} {\n let address: string | undefined;\n let port: string | undefined;\n\n if (typeof settings.host === 'string') {\n if (settings.host.startsWith('[')) {\n // IPv6 addresses can be enclosed in square brackets, e.g., [2001:db8::1]:8080\n if (settings.host.endsWith(']')) {\n // IPv6 with square brackets without port\n address = settings.host.replace(/^\\[|\\]$/g, '');\n } else if (settings.host.includes(']:')) {\n // IPv6 with square brackets with port\n const lastColonIndex = settings.host.lastIndexOf(':');\n if (lastColonIndex !== -1) {\n address = settings.host.slice(1, lastColonIndex).replace(/^\\[|\\]$/g, '');\n port = settings.host.slice(lastColonIndex + 1);\n }\n }\n } else {\n // IPv4 or IPv6 without square brackets\n // If it's an IPv6 address without square brackets, we assume it does not have a port.\n if (net.isIPv6(settings.host)) {\n address = settings.host;\n }\n // If it's an IPv4 address, we can extract the port if it exists.\n else {\n const lastColonIndex = settings.host.lastIndexOf(':');\n if (lastColonIndex !== -1) {\n address = settings.host.slice(0, lastColonIndex);\n port = settings.host.slice(lastColonIndex + 1);\n } else {\n address = settings.host;\n }\n }\n }\n }\n return {\n address: address,\n port: port ? parseInt(port, 10) : undefined,\n };\n}\n\nfunction addAttributes<AppModelType, DbModelType extends DocumentData>(\n span: Span,\n reference: CollectionReference<AppModelType, DbModelType> | DocumentReference<AppModelType, DbModelType>,\n): void {\n const firestoreApp: FirebaseApp = reference.firestore.app;\n const firestoreOptions: FirebaseOptions = firestoreApp.options;\n const json: { settings?: FirestoreSettings } = reference.firestore.toJSON() || {};\n const settings: FirestoreSettings = json.settings || {};\n\n const attributes: SpanAttributes = {\n [ATTR_DB_COLLECTION_NAME]: reference.path,\n [ATTR_DB_NAMESPACE]: firestoreApp.name,\n [ATTR_DB_SYSTEM_NAME]: 'firebase.firestore',\n 'firebase.firestore.type': reference.type,\n 'firebase.firestore.options.projectId': firestoreOptions.projectId,\n 'firebase.firestore.options.appId': firestoreOptions.appId,\n 'firebase.firestore.options.messagingSenderId': firestoreOptions.messagingSenderId,\n 'firebase.firestore.options.storageBucket': firestoreOptions.storageBucket,\n };\n\n const { address, port } = getPortAndAddress(settings);\n\n if (address) {\n attributes[ATTR_SERVER_ADDRESS] = address;\n }\n if (port) {\n attributes[ATTR_SERVER_PORT] = port;\n }\n\n span.setAttributes(attributes);\n}\n"],"names":[],"mappings":";;;;;;AAgDO,SAAS,cAAA,CACd,MAAA,EACA,0BAAA,EACA,IAAA,EACA,QACA,MAAA,EACqC;AACrC,EAAA,MAAM,mCAA8D,MAAM;AAA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AM,QAAA,GAA8B,IAAA,CAAK,QAAA,IAAY,EAAC;AAEtD,EAAA,MAAM,UAAA,GAA6B;AAAA,IACjC,CAAC,uBAAuB,GAAG,SAAA,CAAU,IAAA;AAAA,IACrC,CAAC,iBAAiB,GAAG,YAAA,CAAa,IAAA;AAAA,IAClC,CAAC,mBAAmB,GAAG,oBAAA;AAAA,IACvB,2BAA2B,SAAA,CAAU,IAAA;AAAA,IACrC,wCAAwC,gBAAA,CAAiB,SAAA;AAAA,IACzD,oCAAoC,gBAAA,CAAiB,KAAA;AAAA,IACrD,gDAAgD,gBAAA,CAAiB,iBAAA;AAAA,IACjE,4CAA4C,gBAAA,CAAiB;AAAA,GAC/D;AAEA,EAAA,MAAM,EAAE,OAAA,EAAS,IAAA,EAAK,GAAI,kBAAkB,QAAQ,CAAA;AAEpD,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,UAAA,CAAW,mBAAmB,CAAA,GAAI,OAAA;AAAA,EACpC;AACA,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,UAAA,CAAW,gBAAgB,CAAA,GAAI,IAAA;AAAA,EACjC;AAEA,EAAA,IAAA,CAAK,cAAc,UAAU,CAAA;AAC/B;;;;"}
|
|
1
|
+
{"version":3,"file":"firestore.js","sources":["../../../../../../../src/integrations/tracing/firebase/otel/patches/firestore.ts"],"sourcesContent":["import * as net from 'node:net';\nimport { InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleFile } from '../../../InstrumentationNodeModuleFile';\nimport {\n ATTR_DB_COLLECTION_NAME,\n ATTR_DB_NAMESPACE,\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_SYSTEM_NAME,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport type { SpanAttributes } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_KIND, startSpan } from '@sentry/core';\nimport type { FirebaseInstrumentation } from '../firebaseInstrumentation';\nimport type {\n AddDocType,\n CollectionReference,\n DeleteDocType,\n DocumentData,\n DocumentReference,\n FirebaseApp,\n FirebaseOptions,\n FirestoreSettings,\n GetDocsType,\n PartialWithFieldValue,\n QuerySnapshot,\n SetDocType,\n SetOptions,\n WithFieldValue,\n} from '../types';\n\n// Inline minimal types used from `shimmer` to avoid importing shimmer's types directly.\n// We only need the shape for `wrap` and `unwrap` used in this file.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ShimmerWrap = (target: any, name: string, wrapper: (...args: any[]) => any) => void;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ShimmerUnwrap = (target: any, name: string) => void;\n\n/**\n *\n * @param firestoreSupportedVersions - supported version of firebase/firestore\n * @param wrap - reference to native instrumentation wrap function\n * @param unwrap - reference to native instrumentation wrap function\n */\nexport function patchFirestore(\n firestoreSupportedVersions: string[],\n wrap: ShimmerWrap,\n unwrap: ShimmerUnwrap,\n): InstrumentationNodeModuleDefinition {\n const moduleFirestoreCJS = new InstrumentationNodeModuleDefinition(\n '@firebase/firestore',\n firestoreSupportedVersions,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (moduleExports: any) => wrapMethods(moduleExports, wrap, unwrap),\n );\n const files: string[] = [\n '@firebase/firestore/dist/lite/index.node.cjs.js',\n '@firebase/firestore/dist/lite/index.node.mjs.js',\n '@firebase/firestore/dist/lite/index.rn.esm2017.js',\n '@firebase/firestore/dist/lite/index.cjs.js',\n ];\n\n for (const file of files) {\n moduleFirestoreCJS.files.push(\n new InstrumentationNodeModuleFile(\n file,\n firestoreSupportedVersions,\n moduleExports => wrapMethods(moduleExports, wrap, unwrap),\n moduleExports => unwrapMethods(moduleExports, unwrap),\n ),\n );\n }\n\n return moduleFirestoreCJS;\n}\n\nfunction wrapMethods(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n moduleExports: any,\n wrap: ShimmerWrap,\n unwrap: ShimmerUnwrap,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n unwrapMethods(moduleExports, unwrap);\n\n wrap(moduleExports, 'addDoc', patchAddDoc());\n wrap(moduleExports, 'getDocs', patchGetDocs());\n wrap(moduleExports, 'setDoc', patchSetDoc());\n wrap(moduleExports, 'deleteDoc', patchDeleteDoc());\n\n return moduleExports;\n}\n\nfunction unwrapMethods(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n moduleExports: any,\n unwrap: ShimmerUnwrap,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n for (const method of ['addDoc', 'getDocs', 'setDoc', 'deleteDoc']) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (isWrapped(moduleExports[method])) {\n unwrap(moduleExports, method);\n }\n }\n return moduleExports;\n}\n\nfunction patchAddDoc<AppModelType, DbModelType extends DocumentData>(): (\n original: AddDocType<AppModelType, DbModelType>,\n) => (\n this: FirebaseInstrumentation,\n reference: CollectionReference<AppModelType, DbModelType>,\n data: WithFieldValue<AppModelType>,\n) => Promise<DocumentReference<AppModelType, DbModelType>> {\n return function addDoc(original: AddDocType<AppModelType, DbModelType>) {\n return function (\n reference: CollectionReference<AppModelType, DbModelType>,\n data: WithFieldValue<AppModelType>,\n ): Promise<DocumentReference<AppModelType, DbModelType>> {\n return startFirestoreSpan('addDoc', reference, () => original(reference, data));\n };\n };\n}\n\nfunction patchDeleteDoc<AppModelType, DbModelType extends DocumentData>(): (\n original: DeleteDocType<AppModelType, DbModelType>,\n) => (this: FirebaseInstrumentation, reference: DocumentReference<AppModelType, DbModelType>) => Promise<void> {\n return function deleteDoc(original: DeleteDocType<AppModelType, DbModelType>) {\n return function (reference: DocumentReference<AppModelType, DbModelType>): Promise<void> {\n return startFirestoreSpan('deleteDoc', reference.parent || reference, () => original(reference));\n };\n };\n}\n\nfunction patchGetDocs<AppModelType, DbModelType extends DocumentData>(): (\n original: GetDocsType<AppModelType, DbModelType>,\n) => (\n this: FirebaseInstrumentation,\n reference: CollectionReference<AppModelType, DbModelType>,\n) => Promise<QuerySnapshot<AppModelType, DbModelType>> {\n return function getDocs(original: GetDocsType<AppModelType, DbModelType>) {\n return function (\n reference: CollectionReference<AppModelType, DbModelType>,\n ): Promise<QuerySnapshot<AppModelType, DbModelType>> {\n return startFirestoreSpan('getDocs', reference, () => original(reference));\n };\n };\n}\n\nfunction patchSetDoc<AppModelType, DbModelType extends DocumentData>(): (\n original: SetDocType<AppModelType, DbModelType>,\n) => (\n this: FirebaseInstrumentation,\n reference: DocumentReference<AppModelType, DbModelType>,\n data: WithFieldValue<AppModelType> & PartialWithFieldValue<AppModelType>,\n options?: SetOptions,\n) => Promise<void> {\n return function setDoc(original: SetDocType<AppModelType, DbModelType>) {\n return function (\n reference: DocumentReference<AppModelType, DbModelType>,\n data: WithFieldValue<AppModelType> & PartialWithFieldValue<AppModelType>,\n options?: SetOptions,\n ): Promise<void> {\n return startFirestoreSpan('setDoc', reference.parent || reference, () => {\n return typeof options !== 'undefined' ? original(reference, data, options) : original(reference, data);\n });\n };\n };\n}\n\nfunction startFirestoreSpan<AppModelType, DbModelType extends DocumentData, T>(\n spanName: string,\n reference: CollectionReference<AppModelType, DbModelType> | DocumentReference<AppModelType, DbModelType>,\n callback: () => T,\n): T {\n return startSpan(\n {\n name: `${spanName} ${reference.path}`,\n op: 'db.query',\n kind: SPAN_KIND.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.firebase.otel.firestore',\n [ATTR_DB_OPERATION_NAME]: spanName,\n ...buildAttributes(reference),\n },\n },\n callback,\n );\n}\n\n/**\n * Gets the server address and port attributes from the Firestore settings.\n * It's best effort to extract the address and port from the settings, especially for IPv6.\n * @param settings - The Firestore settings containing host information.\n */\nexport function getPortAndAddress(settings: FirestoreSettings): {\n address?: string;\n port?: number;\n} {\n let address: string | undefined;\n let port: string | undefined;\n\n if (typeof settings.host === 'string') {\n if (settings.host.startsWith('[')) {\n // IPv6 addresses can be enclosed in square brackets, e.g., [2001:db8::1]:8080\n if (settings.host.endsWith(']')) {\n // IPv6 with square brackets without port\n address = settings.host.replace(/^\\[|\\]$/g, '');\n } else if (settings.host.includes(']:')) {\n // IPv6 with square brackets with port\n const lastColonIndex = settings.host.lastIndexOf(':');\n if (lastColonIndex !== -1) {\n address = settings.host.slice(1, lastColonIndex).replace(/^\\[|\\]$/g, '');\n port = settings.host.slice(lastColonIndex + 1);\n }\n }\n } else {\n // IPv4 or IPv6 without square brackets\n // If it's an IPv6 address without square brackets, we assume it does not have a port.\n if (net.isIPv6(settings.host)) {\n address = settings.host;\n }\n // If it's an IPv4 address, we can extract the port if it exists.\n else {\n const lastColonIndex = settings.host.lastIndexOf(':');\n if (lastColonIndex !== -1) {\n address = settings.host.slice(0, lastColonIndex);\n port = settings.host.slice(lastColonIndex + 1);\n } else {\n address = settings.host;\n }\n }\n }\n }\n return {\n address: address,\n port: port ? parseInt(port, 10) : undefined,\n };\n}\n\nfunction buildAttributes<AppModelType, DbModelType extends DocumentData>(\n reference: CollectionReference<AppModelType, DbModelType> | DocumentReference<AppModelType, DbModelType>,\n): SpanAttributes {\n const firestoreApp: FirebaseApp = reference.firestore.app;\n const firestoreOptions: FirebaseOptions = firestoreApp.options;\n const json: { settings?: FirestoreSettings } = reference.firestore.toJSON() || {};\n const settings: FirestoreSettings = json.settings || {};\n\n const attributes: SpanAttributes = {\n [ATTR_DB_COLLECTION_NAME]: reference.path,\n [ATTR_DB_NAMESPACE]: firestoreApp.name,\n [ATTR_DB_SYSTEM_NAME]: 'firebase.firestore',\n 'firebase.firestore.type': reference.type,\n 'firebase.firestore.options.projectId': firestoreOptions.projectId,\n 'firebase.firestore.options.appId': firestoreOptions.appId,\n 'firebase.firestore.options.messagingSenderId': firestoreOptions.messagingSenderId,\n 'firebase.firestore.options.storageBucket': firestoreOptions.storageBucket,\n };\n\n const { address, port } = getPortAndAddress(settings);\n\n if (address) {\n attributes[ATTR_SERVER_ADDRESS] = address;\n }\n if (port) {\n att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,SAAA,CAAU,IAAA;AAAA,IACrC,wCAAwC,gBAAA,CAAiB,SAAA;AAAA,IACzD,oCAAoC,gBAAA,CAAiB,KAAA;AAAA,IACrD,gDAAgD,gBAAA,CAAiB,iBAAA;AAAA,IACjE,4CAA4C,gBAAA,CAAiB;AAAA,GAC/D;AAEA,EAAA,MAAM,EAAE,OAAA,EAAS,IAAA,EAAK,GAAI,kBAAkB,QAAQ,CAAA;AAEpD,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,UAAA,CAAW,mBAAmB,CAAA,GAAI,OAAA;AAAA,EACpC;AACA,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,UAAA,CAAW,gBAAgB,CAAA,GAAI,IAAA;AAAA,EACjC;AAEA,EAAA,OAAO,UAAA;AACT;;;;"}
|
|
@@ -1,43 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { InstrumentationNodeModuleDefinition, isWrapped, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
|
|
1
|
+
import { InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';
|
|
3
2
|
import { InstrumentationNodeModuleFile } from '../../../InstrumentationNodeModuleFile.js';
|
|
3
|
+
import { startSpanManual, SPAN_KIND, SPAN_STATUS_ERROR, captureException, flush, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
4
4
|
|
|
5
|
-
function patchFunctions(
|
|
6
|
-
let requestHook = () => {
|
|
7
|
-
};
|
|
8
|
-
let responseHook = () => {
|
|
9
|
-
};
|
|
10
|
-
const errorHook = config.functions?.errorHook;
|
|
11
|
-
const configRequestHook = config.functions?.requestHook;
|
|
12
|
-
const configResponseHook = config.functions?.responseHook;
|
|
13
|
-
if (typeof configResponseHook === "function") {
|
|
14
|
-
responseHook = (span, err) => {
|
|
15
|
-
safeExecuteInTheMiddle(
|
|
16
|
-
() => configResponseHook(span, err),
|
|
17
|
-
(error) => {
|
|
18
|
-
if (!error) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
diag.error(error?.message);
|
|
22
|
-
},
|
|
23
|
-
true
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
if (typeof configRequestHook === "function") {
|
|
28
|
-
requestHook = (span) => {
|
|
29
|
-
safeExecuteInTheMiddle(
|
|
30
|
-
() => configRequestHook(span),
|
|
31
|
-
(error) => {
|
|
32
|
-
if (!error) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
diag.error(error?.message);
|
|
36
|
-
},
|
|
37
|
-
true
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
5
|
+
function patchFunctions(functionsSupportedVersions, wrap, unwrap) {
|
|
41
6
|
const moduleFunctionsCJS = new InstrumentationNodeModuleDefinition("firebase-functions", functionsSupportedVersions);
|
|
42
7
|
const modulesToInstrument = [
|
|
43
8
|
{ name: "firebase-functions/lib/v2/providers/https.js", triggerType: "function" },
|
|
@@ -50,21 +15,14 @@ function patchFunctions(tracer, functionsSupportedVersions, wrap, unwrap, config
|
|
|
50
15
|
new InstrumentationNodeModuleFile(
|
|
51
16
|
name,
|
|
52
17
|
functionsSupportedVersions,
|
|
53
|
-
(moduleExports) => wrapCommonFunctions(
|
|
54
|
-
moduleExports,
|
|
55
|
-
wrap,
|
|
56
|
-
unwrap,
|
|
57
|
-
tracer,
|
|
58
|
-
{ requestHook, responseHook, errorHook },
|
|
59
|
-
triggerType
|
|
60
|
-
),
|
|
18
|
+
(moduleExports) => wrapCommonFunctions(moduleExports, wrap, unwrap, triggerType),
|
|
61
19
|
(moduleExports) => unwrapCommonFunctions(moduleExports, unwrap)
|
|
62
20
|
)
|
|
63
21
|
);
|
|
64
22
|
});
|
|
65
23
|
return moduleFunctionsCJS;
|
|
66
24
|
}
|
|
67
|
-
function patchV2Functions(
|
|
25
|
+
function patchV2Functions(triggerType) {
|
|
68
26
|
return function v2FunctionsWrapper(original) {
|
|
69
27
|
return function(...args) {
|
|
70
28
|
const handler = typeof args[0] === "function" ? args[0] : args[1];
|
|
@@ -74,10 +32,8 @@ function patchV2Functions(tracer, functionsConfig, triggerType) {
|
|
|
74
32
|
}
|
|
75
33
|
const wrappedHandler = async function(...handlerArgs) {
|
|
76
34
|
const functionName = process.env.FUNCTION_TARGET || process.env.K_SERVICE || "unknown";
|
|
77
|
-
const span = tracer.startSpan(`firebase.function.${triggerType}`, {
|
|
78
|
-
kind: SpanKind.SERVER
|
|
79
|
-
});
|
|
80
35
|
const attributes = {
|
|
36
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.firebase.otel.functions",
|
|
81
37
|
"faas.name": functionName,
|
|
82
38
|
"faas.trigger": triggerType,
|
|
83
39
|
"faas.provider": "firebase"
|
|
@@ -88,27 +44,32 @@ function patchV2Functions(tracer, functionsConfig, triggerType) {
|
|
|
88
44
|
if (process.env.EVENTARC_CLOUD_EVENT_SOURCE) {
|
|
89
45
|
attributes["cloud.event_source"] = process.env.EVENTARC_CLOUD_EVENT_SOURCE;
|
|
90
46
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
47
|
+
return startSpanManual(
|
|
48
|
+
{
|
|
49
|
+
name: `firebase.function.${triggerType}`,
|
|
50
|
+
op: "http.request",
|
|
51
|
+
kind: SPAN_KIND.SERVER,
|
|
52
|
+
attributes
|
|
53
|
+
},
|
|
54
|
+
async (span) => {
|
|
55
|
+
try {
|
|
56
|
+
const result = await handler.apply(this, handlerArgs);
|
|
57
|
+
span.end();
|
|
58
|
+
return result;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
span.setStatus({ code: SPAN_STATUS_ERROR });
|
|
61
|
+
captureException(error, {
|
|
62
|
+
mechanism: {
|
|
63
|
+
type: "auto.firebase.otel.functions",
|
|
64
|
+
handled: false
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
span.end();
|
|
68
|
+
await flush(2e3);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
109
71
|
}
|
|
110
|
-
|
|
111
|
-
});
|
|
72
|
+
);
|
|
112
73
|
};
|
|
113
74
|
if (documentOrOptions) {
|
|
114
75
|
return original.call(this, documentOrOptions, wrappedHandler);
|
|
@@ -118,51 +79,31 @@ function patchV2Functions(tracer, functionsConfig, triggerType) {
|
|
|
118
79
|
};
|
|
119
80
|
};
|
|
120
81
|
}
|
|
121
|
-
function wrapCommonFunctions(moduleExports, wrap, unwrap,
|
|
82
|
+
function wrapCommonFunctions(moduleExports, wrap, unwrap, triggerType) {
|
|
122
83
|
unwrapCommonFunctions(moduleExports, unwrap);
|
|
123
84
|
switch (triggerType) {
|
|
124
85
|
case "function":
|
|
125
|
-
wrap(moduleExports, "onRequest", patchV2Functions(
|
|
126
|
-
wrap(moduleExports, "onCall", patchV2Functions(
|
|
86
|
+
wrap(moduleExports, "onRequest", patchV2Functions("http.request"));
|
|
87
|
+
wrap(moduleExports, "onCall", patchV2Functions("http.call"));
|
|
127
88
|
break;
|
|
128
89
|
case "firestore":
|
|
129
|
-
wrap(moduleExports, "onDocumentCreated", patchV2Functions(
|
|
130
|
-
wrap(moduleExports, "onDocumentUpdated", patchV2Functions(
|
|
131
|
-
wrap(moduleExports, "onDocumentDeleted", patchV2Functions(
|
|
132
|
-
wrap(moduleExports, "onDocumentWritten", patchV2Functions(
|
|
133
|
-
wrap(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
);
|
|
138
|
-
wrap(
|
|
139
|
-
moduleExports,
|
|
140
|
-
"onDocumentUpdatedWithAuthContext",
|
|
141
|
-
patchV2Functions(tracer, functionsConfig, "firestore.document.updated")
|
|
142
|
-
);
|
|
143
|
-
wrap(
|
|
144
|
-
moduleExports,
|
|
145
|
-
"onDocumentDeletedWithAuthContext",
|
|
146
|
-
patchV2Functions(tracer, functionsConfig, "firestore.document.deleted")
|
|
147
|
-
);
|
|
148
|
-
wrap(
|
|
149
|
-
moduleExports,
|
|
150
|
-
"onDocumentWrittenWithAuthContext",
|
|
151
|
-
patchV2Functions(tracer, functionsConfig, "firestore.document.written")
|
|
152
|
-
);
|
|
90
|
+
wrap(moduleExports, "onDocumentCreated", patchV2Functions("firestore.document.created"));
|
|
91
|
+
wrap(moduleExports, "onDocumentUpdated", patchV2Functions("firestore.document.updated"));
|
|
92
|
+
wrap(moduleExports, "onDocumentDeleted", patchV2Functions("firestore.document.deleted"));
|
|
93
|
+
wrap(moduleExports, "onDocumentWritten", patchV2Functions("firestore.document.written"));
|
|
94
|
+
wrap(moduleExports, "onDocumentCreatedWithAuthContext", patchV2Functions("firestore.document.created"));
|
|
95
|
+
wrap(moduleExports, "onDocumentUpdatedWithAuthContext", patchV2Functions("firestore.document.updated"));
|
|
96
|
+
wrap(moduleExports, "onDocumentDeletedWithAuthContext", patchV2Functions("firestore.document.deleted"));
|
|
97
|
+
wrap(moduleExports, "onDocumentWrittenWithAuthContext", patchV2Functions("firestore.document.written"));
|
|
153
98
|
break;
|
|
154
99
|
case "scheduler":
|
|
155
|
-
wrap(moduleExports, "onSchedule", patchV2Functions(
|
|
100
|
+
wrap(moduleExports, "onSchedule", patchV2Functions("scheduler.scheduled"));
|
|
156
101
|
break;
|
|
157
102
|
case "storage":
|
|
158
|
-
wrap(moduleExports, "onObjectFinalized", patchV2Functions(
|
|
159
|
-
wrap(moduleExports, "onObjectArchived", patchV2Functions(
|
|
160
|
-
wrap(moduleExports, "onObjectDeleted", patchV2Functions(
|
|
161
|
-
wrap(
|
|
162
|
-
moduleExports,
|
|
163
|
-
"onObjectMetadataUpdated",
|
|
164
|
-
patchV2Functions(tracer, functionsConfig, "storage.object.metadataUpdated")
|
|
165
|
-
);
|
|
103
|
+
wrap(moduleExports, "onObjectFinalized", patchV2Functions("storage.object.finalized"));
|
|
104
|
+
wrap(moduleExports, "onObjectArchived", patchV2Functions("storage.object.archived"));
|
|
105
|
+
wrap(moduleExports, "onObjectDeleted", patchV2Functions("storage.object.deleted"));
|
|
106
|
+
wrap(moduleExports, "onObjectMetadataUpdated", patchV2Functions("storage.object.metadataUpdated"));
|
|
166
107
|
break;
|
|
167
108
|
}
|
|
168
109
|
return moduleExports;
|
|
@@ -1 +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 { InstrumentationNodeModuleDefinition, isWrapped, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleFile } from '../../../InstrumentationNodeModuleFile';\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":";;;;AAwBO,SAAS,cAAA,CACd,MAAA,EACA,0BAAA,EACA,IAAA,EACA,QACA,MAAA,EACqC;AACrC,EAAA,IAAI,cAA2B,MAAM;AAAA,EAAC,CAAA;AACtC,EAAA,IAAI,eAA6B,MAAM;AAAA,EAAC,CAAA;AACxC,EAAA,MAAM,SAAA,GAAY,OAAO,SAAA,EAAW,SAAA;AACpC,EAAA,MAAM,iBAAA,GAAoB,OAAO,SAAA,EAAW,WAAA;AAC5C,EAAA,MAAM,kBAAA,GAAqB,OAAO,SAAA,EAAW,YAAA;AAE7C,EAAA,IAAI,OAAO,uBAAuB,UAAA,EAAY;AAC5C,IAAA,YAAA,GAAe,CAAC,MAAY,GAAA,KAAiB;AAC3C,MAAA,sBAAA;AAAA,QACE,MAAM,kBAAA,CAAmB,IAAA,EAAM,GAAG,CAAA;AAAA,QAClC,CAAA,KAAA,KAAS;AACP,UAAA,IAAI,CAAC,KAAA,EAAO;AACV,YAAA;AAAA,UACF;AACA,UAAA,IAAA,CAAK,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA,QAC3B,CAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF,CAAA;AAAA,EACF;AACA,EAAA,IAAI,OAAO,sBAAsB,UAAA,EAAY;AAC3C,IAAA,WAAA,GAAc,CAAC,IAAA,KAAe;AA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,CAAK,eAAe,mBAAA,EAAqB,gBAAA,CAAiB,MAAA,EAAQ,eAAA,EAAiB,0BAA0B,CAAC,CAAA;AAC9G,MAAA,IAAA,CAAK,eAAe,kBAAA,EAAoB,gBAAA,CAAiB,MAAA,EAAQ,eAAA,EAAiB,yBAAyB,CAAC,CAAA;AAC5G,MAAA,IAAA,CAAK,eAAe,iBAAA,EAAmB,gBAAA,CAAiB,MAAA,EAAQ,eAAA,EAAiB,wBAAwB,CAAC,CAAA;AAC1G,MAAA,IAAA;AAAA,QACE,aAAA;AAAA,QACA,yBAAA;AAAA,QACA,gBAAA,CAAiB,MAAA,EAAQ,eAAA,EAAiB,gCAAgC;AAAA,OAC5E;AACA,MAAA;AAAA;AAGJ,EAAA,OAAO,aAAA;AACT;AAEA,SAAS,qBAAA,CACP,eACA,MAAA,EAC4B;AAC5B,EAAA,MAAM,OAAA,GAAgD;AAAA,IACpD,YAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,mBAAA;AAAA,IACA,kBAAA;AAAA,IACA,iBAAA;AAAA,IACA,yBAAA;AAAA,IACA,mBAAA;AAAA,IACA,mBAAA;AAAA,IACA,mBAAA;AAAA,IACA,mBAAA;AAAA,IACA,kCAAA;AAAA,IACA,kCAAA;AAAA,IACA,kCAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,IAAI,SAAA,CAAU,aAAA,CAAc,MAAM,CAAC,CAAA,EAAG;AACpC,MAAA,MAAA,CAAO,eAAe,MAAM,CAAA;AAAA,IAC9B;AAAA,EACF;AACA,EAAA,OAAO,aAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"functions.js","sources":["../../../../../../../src/integrations/tracing/firebase/otel/patches/functions.ts"],"sourcesContent":["import type { InstrumentationBase } from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleFile } from '../../../InstrumentationNodeModuleFile';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n captureException,\n flush,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startSpanManual,\n} from '@sentry/core';\nimport type { FirebaseInstrumentation } from '../firebaseInstrumentation';\nimport type { AvailableFirebaseFunctions, FirebaseFunctions, OverloadedParameters } from '../types';\n\n/**\n * Patches Firebase Functions v2 to add OpenTelemetry instrumentation\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 */\nexport function patchFunctions(\n functionsSupportedVersions: string[],\n wrap: InstrumentationBase['_wrap'],\n unwrap: InstrumentationBase['_unwrap'],\n): InstrumentationNodeModuleDefinition {\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 => wrapCommonFunctions(moduleExports, wrap, unwrap, triggerType),\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 triggerType - Type of trigger\n * @returns A function that patches the function\n */\nexport function patchV2Functions<T extends FirebaseFunctions = FirebaseFunctions>(\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\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.firebase.otel.functions',\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 // `startSpanManual` to keep the span active but while still allowing us to end it before flushing on error.\n return startSpanManual(\n {\n name: `firebase.function.${triggerType}`,\n op: 'http.request',\n kind: SPAN_KIND.SERVER,\n attributes,\n },\n async span => {\n try {\n const result = await handler.apply(this, handlerArgs);\n span.end();\n return result;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n captureException(error, {\n mechanism: {\n type: 'auto.firebase.otel.functions',\n handled: false,\n },\n });\n span.end();\n await flush(2000);\n throw error;\n }\n },\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['_wrap'],\n unwrap: InstrumentationBase['_unwrap'],\n triggerType: 'function' | 'firestore' | 'scheduler' | 'storage',\n): AvailableFirebaseFunctions {\n unwrapCommonFunctions(moduleExports, unwrap);\n\n switch (triggerType) {\n case 'function':\n wrap(moduleExports, 'onRequest', patchV2Functions('http.request'));\n wrap(moduleExports, 'onCall', patchV2Functions('http.call'));\n break;\n\n case 'firestore':\n wrap(moduleExports, 'onDocumentCreated', patchV2Functions('firestore.document.created'));\n wrap(moduleExports, 'onDocumentUpdated', patchV2Functions('firestore.document.updated'));\n wrap(moduleExports, 'onDocumentDeleted', patchV2Functions('firestore.document.deleted'));\n wrap(moduleExports, 'onDocumentWritten', patchV2Functions('firestore.document.written'));\n wrap(moduleExports, 'onDocumentCreatedWithAuthContext', patchV2Functions('firestore.document.created'));\n wrap(moduleExports, 'onDocumentUpdatedWithAuthContext', patchV2Functions('firestore.document.updated'));\n wrap(moduleExports, 'onDocumentDeletedWithAuthContext', patchV2Functions('firestore.document.deleted'));\n wrap(moduleExports, 'onDocumentWrittenWithAuthContext', patchV2Functions('firestore.document.written'));\n break;\n\n case 'scheduler':\n wrap(moduleExports, 'onSchedule', patchV2Functions('scheduler.scheduled'));\n break;\n\n case 'storage':\n wrap(moduleExports, 'onObjectFinalized', patchV2Functions('storage.object.finalized'));\n wrap(moduleExports, 'onObjectArchived', patchV2Functions('storage.object.archived'));\n wrap(moduleExports, 'onObjectDeleted', patchV2Functions('storage.object.deleted'));\n wrap(moduleExports, 'onObjectMetadataUpdated', patchV2Functions('storage.object.metadataUpdated'));\n break;\n }\n\n return moduleExports;\n}\n\nfunction unwrapCommonFunctions(\n moduleExports: AvailableFirebaseFunctions,\n unwrap: InstrumentationBase['_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":";;;;AAqBO,SAAS,cAAA,CACd,0BAAA,EACA,IAAA,EACA,MAAA,EACqC;AACrC,EAAA,MAAM,kBAAA,GAAqB,IAAI,mCAAA,CAAoC,oBAAA,EAAsB,0BAA0B,CAAA;AACnH,EAAA,MAAM,mBAAA,GAAsB;AAAA,IAC1B,EAAE,IAAA,EAAM,8CAAA,EAAgD,WAAA,EAAa,UAAA,EAAW;AAAA,IAChF,EAAE,IAAA,EAAM,kDAAA,EAAoD,WAAA,EAAa,WAAA,EAAY;AAAA,IACrF,EAAE,IAAA,EAAM,kDAAA,EAAoD,WAAA,EAAa,WAAA,EAAY;AAAA,IACrF,EAAE,IAAA,EAAM,sCAAA,EAAwC,WAAA,EAAa,SAAA;AAAU,GACzE;AAEA,EAAA,mBAAA,CAAoB,OAAA,CAAQ,CAAC,EAAE,IAAA,EAAM,aAAY,KAAM;AACrD,IAAA,kBAAA,CAAmB,KAAA,CAAM,IAAA;AAAA,MACvB,IAAI,6BAAA;AAAA,QACF,IAAA;AAAA,QACA,0BAAA;AAAA,QACA,CAAA,aAAA,KAAiB,mBAAA,CAAoB,aAAA,EAAe,IAAA,EAAM,QAAQ,WAAW,CAAA;AAAA,QAC7E,CAAA,aAAA,KAAiB,qBAAA,CAAsB,aAAA,EAAe,MAAM;AAAA;AAC9D,KACF;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,kBAAA;AACT;AAQO,SAAS,iBACd,WAAA,EACsE;AACtE,EAAA,OAAO,SAAS,mBAAmB,QAAA,EAAkE;AACnG,IAAA,OAAO,YAA4C,IAAA,EAA8C;AAC/F,MAAA,MAAM,OAAA,GAAU,OAAO,IAAA,CAAK,CAAC,CAAA,KAAM,aAAa,IAAA,CAAK,CAAC,CAAA,GAAI,IAAA,CAAK,CAAC,CAAA;AAChE,MAAA,MAAM,iBAAA,GAAoB,OAAO,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ACA,kCAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,IAAI,SAAA,CAAU,aAAA,CAAc,MAAM,CAAC,CAAA,EAAG;AACpC,MAAA,MAAA,CAAO,eAAe,MAAM,CAAA;AAAA,IAC9B;AAAA,EACF;AACA,EAAA,OAAO,aAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/genericPool/index.ts"],"sourcesContent":["import { GenericPoolInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'GenericPool';\n\nexport const instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME, () => new GenericPoolInstrumentation({}));\n\nconst _genericPoolIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentGenericPool();\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;AAElB,MAAM,qBAAA,GAAwB,uBAAuB,gBAAA,EAAkB,MAAM,IAAI,0BAAA,CAA2B,EAAE,CAAC;AAEtH,MAAM,2BAA2B,MAAM;AACrC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,qBAAA,EAAsB;AAAA,IACxB;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,sBAAA,GAAyB,kBAAkB,uBAAuB;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/genericPool/index.ts"],"sourcesContent":["import { GenericPoolInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'GenericPool' as const;\n\nexport const instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME, () => new GenericPoolInstrumentation({}));\n\nconst _genericPoolIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentGenericPool();\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;AAElB,MAAM,qBAAA,GAAwB,uBAAuB,gBAAA,EAAkB,MAAM,IAAI,0BAAA,CAA2B,EAAE,CAAC;AAEtH,MAAM,2BAA2B,MAAM;AACrC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,qBAAA,EAAsB;AAAA,IACxB;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,sBAAA,GAAyB,kBAAkB,uBAAuB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/graphql/index.ts"],"sourcesContent":["import { GraphQLInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\ninterface GraphqlOptions {\n /**\n * Do not create spans for resolvers.\n *\n * Defaults to true.\n */\n ignoreResolveSpans?: boolean;\n\n /**\n * Don't create spans for the execution of the default resolver on object properties.\n *\n * When a resolver function is not defined on the schema for a field, graphql will\n * use the default resolver which just looks for a property with that name on the object.\n * If the property is not a function, it's not very interesting to trace.\n * This option can reduce noise and number of spans created.\n *\n * Defaults to true.\n */\n ignoreTrivialResolveSpans?: boolean;\n\n /**\n * If this is enabled, a http.server root span containing this span will automatically be renamed to include the operation name.\n * Set this to `false` if you do not want this behavior, and want to keep the default http.server span name.\n *\n * Defaults to true.\n */\n useOperationNameForRootSpan?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Graphql';\n\nexport const instrumentGraphql = generateInstrumentOnce(\n INTEGRATION_NAME,\n GraphQLInstrumentation,\n (_options: GraphqlOptions) => getOptionsWithDefaults(_options),\n);\n\nconst _graphqlIntegration = ((options: GraphqlOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // We set defaults here, too, because otherwise we'd update the instrumentation config\n // to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`\n // when being called the second time\n instrumentGraphql(getOptionsWithDefaults(options));\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.\n *\n * For more information, see the [`graphqlIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).\n *\n * @param {GraphqlOptions} options Configuration options for the GraphQL integration.\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.graphqlIntegration()],\n * });\n */\nexport const graphqlIntegration = defineIntegration(_graphqlIntegration);\n\nfunction getOptionsWithDefaults(options?: GraphqlOptions): GraphqlOptions {\n return {\n ignoreResolveSpans: true,\n ignoreTrivialResolveSpans: true,\n useOperationNameForRootSpan: true,\n ...options,\n };\n}\n"],"names":[],"mappings":";;;;AAkCA,MAAM,gBAAA,GAAmB,SAAA;AAElB,MAAM,iBAAA,GAAoB,sBAAA;AAAA,EAC/B,gBAAA;AAAA,EACA,sBAAA;AAAA,EACA,CAAC,QAAA,KAA6B,sBAAA,CAAuB,QAAQ;AAC/D;AAEA,MAAM,mBAAA,IAAuB,CAAC,OAAA,GAA0B,EAAC,KAAM;AAC7D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAIV,MAAA,iBAAA,CAAkB,sBAAA,CAAuB,OAAO,CAAC,CAAA;AAAA,IACnD;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,kBAAA,GAAqB,kBAAkB,mBAAmB;AAEvE,SAAS,uBAAuB,OAAA,EAA0C;AACxE,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,IAAA;AAAA,IACpB,yBAAA,EAA2B,IAAA;AAAA,IAC3B,2BAAA,EAA6B,IAAA;AAAA,IAC7B,GAAG;AAAA,GACL;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/graphql/index.ts"],"sourcesContent":["import { GraphQLInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\ninterface GraphqlOptions {\n /**\n * Do not create spans for resolvers.\n *\n * Defaults to true.\n */\n ignoreResolveSpans?: boolean;\n\n /**\n * Don't create spans for the execution of the default resolver on object properties.\n *\n * When a resolver function is not defined on the schema for a field, graphql will\n * use the default resolver which just looks for a property with that name on the object.\n * If the property is not a function, it's not very interesting to trace.\n * This option can reduce noise and number of spans created.\n *\n * Defaults to true.\n */\n ignoreTrivialResolveSpans?: boolean;\n\n /**\n * If this is enabled, a http.server root span containing this span will automatically be renamed to include the operation name.\n * Set this to `false` if you do not want this behavior, and want to keep the default http.server span name.\n *\n * Defaults to true.\n */\n useOperationNameForRootSpan?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Graphql' as const;\n\nexport const instrumentGraphql = generateInstrumentOnce(\n INTEGRATION_NAME,\n GraphQLInstrumentation,\n (_options: GraphqlOptions) => getOptionsWithDefaults(_options),\n);\n\nconst _graphqlIntegration = ((options: GraphqlOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // We set defaults here, too, because otherwise we'd update the instrumentation config\n // to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`\n // when being called the second time\n instrumentGraphql(getOptionsWithDefaults(options));\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.\n *\n * For more information, see the [`graphqlIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).\n *\n * @param {GraphqlOptions} options Configuration options for the GraphQL integration.\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.graphqlIntegration()],\n * });\n */\nexport const graphqlIntegration = defineIntegration(_graphqlIntegration);\n\nfunction getOptionsWithDefaults(options?: GraphqlOptions): GraphqlOptions {\n return {\n ignoreResolveSpans: true,\n ignoreTrivialResolveSpans: true,\n useOperationNameForRootSpan: true,\n ...options,\n };\n}\n"],"names":[],"mappings":";;;;AAkCA,MAAM,gBAAA,GAAmB,SAAA;AAElB,MAAM,iBAAA,GAAoB,sBAAA;AAAA,EAC/B,gBAAA;AAAA,EACA,sBAAA;AAAA,EACA,CAAC,QAAA,KAA6B,sBAAA,CAAuB,QAAQ;AAC/D;AAEA,MAAM,mBAAA,IAAuB,CAAC,OAAA,GAA0B,EAAC,KAAM;AAC7D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAIV,MAAA,iBAAA,CAAkB,sBAAA,CAAuB,OAAO,CAAC,CAAA;AAAA,IACnD;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,kBAAA,GAAqB,kBAAkB,mBAAmB;AAEvE,SAAS,uBAAuB,OAAA,EAA0C;AACxE,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,IAAA;AAAA,IACpB,yBAAA,EAA2B,IAAA;AAAA,IAC3B,2BAAA,EAA6B,IAAA;AAAA,IAC7B,GAAG;AAAA,GACL;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/hapi/index.ts"],"sourcesContent":["import { HapiInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n captureException,\n debug,\n defineIntegration,\n getDefaultIsolationScope,\n getIsolationScope,\n SDK_VERSION,\n} from '@sentry/core';\nimport { ensureIsWrapped, generateInstrumentOnce } from '@sentry/node-core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport type { Request, RequestEvent, Server } from './types';\n\nconst INTEGRATION_NAME = 'Hapi';\n\nexport const instrumentHapi = generateInstrumentOnce(INTEGRATION_NAME, () => new HapiInstrumentation());\n\nconst _hapiIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentHapi();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for [Hapi](https://hapi.dev/).\n *\n * If you also want to capture errors, you need to call `setupHapiErrorHandler(server)` after you set up your server.\n *\n * For more information, see the [hapi documentation](https://docs.sentry.io/platforms/javascript/guides/hapi/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.hapiIntegration()],\n * })\n * ```\n */\nexport const hapiIntegration = defineIntegration(_hapiIntegration);\n\nfunction isErrorEvent(event: unknown): event is RequestEvent {\n return !!(event && typeof event === 'object' && 'error' in event && event.error);\n}\n\nfunction sendErrorToSentry(errorData: object): void {\n captureException(errorData, {\n mechanism: {\n type: 'auto.function.hapi',\n handled: false,\n },\n });\n}\n\nexport const hapiErrorPlugin = {\n name: 'SentryHapiErrorPlugin',\n version: SDK_VERSION,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register: async function (serverArg: Record<any, any>) {\n const server = serverArg as unknown as Server;\n\n server.events.on({ name: 'request', channels: ['error'] }, (request: Request, event: RequestEvent) => {\n if (getIsolationScope() !== getDefaultIsolationScope()) {\n const route = request.route;\n if (route.path) {\n getIsolationScope().setTransactionName(`${route.method.toUpperCase()} ${route.path}`);\n }\n } else {\n DEBUG_BUILD &&\n debug.warn('Isolation scope is still the default isolation scope - skipping setting transactionName');\n }\n\n if (isErrorEvent(event)) {\n sendErrorToSentry(event.error);\n }\n });\n },\n};\n\n/**\n * Add a Hapi plugin to capture errors to Sentry.\n *\n * @param server The Hapi server to attach the error handler to\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const Hapi = require('@hapi/hapi');\n *\n * const init = async () => {\n * const server = Hapi.server();\n *\n * // all your routes here\n *\n * await Sentry.setupHapiErrorHandler(server);\n *\n * await server.start();\n * };\n * ```\n */\nexport async function setupHapiErrorHandler(server: Server): Promise<void> {\n await server.register(hapiErrorPlugin);\n ensureIsWrapped(server.register, 'hapi');\n}\n"],"names":[],"mappings":";;;;;AAcA,MAAM,gBAAA,GAAmB,MAAA;AAElB,MAAM,iBAAiB,sBAAA,CAAuB,gBAAA,EAAkB,MAAM,IAAI,qBAAqB;AAEtG,MAAM,oBAAoB,MAAM;AAC9B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,cAAA,EAAe;AAAA,IACjB;AAAA,GACF;AACF,CAAA,CAAA;AAkBO,MAAM,eAAA,GAAkB,kBAAkB,gBAAgB;AAEjE,SAAS,aAAa,KAAA,EAAuC;AAC3D,EAAA,OAAO,CAAC,EAAE,KAAA,IAAS,OAAO,UAAU,QAAA,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;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/hapi/index.ts"],"sourcesContent":["import { HapiInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n captureException,\n debug,\n defineIntegration,\n getDefaultIsolationScope,\n getIsolationScope,\n SDK_VERSION,\n} from '@sentry/core';\nimport { ensureIsWrapped, generateInstrumentOnce } from '@sentry/node-core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport type { Request, RequestEvent, Server } from './types';\n\nconst INTEGRATION_NAME = 'Hapi' as const;\n\nexport const instrumentHapi = generateInstrumentOnce(INTEGRATION_NAME, () => new HapiInstrumentation());\n\nconst _hapiIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentHapi();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for [Hapi](https://hapi.dev/).\n *\n * If you also want to capture errors, you need to call `setupHapiErrorHandler(server)` after you set up your server.\n *\n * For more information, see the [hapi documentation](https://docs.sentry.io/platforms/javascript/guides/hapi/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.hapiIntegration()],\n * })\n * ```\n */\nexport const hapiIntegration = defineIntegration(_hapiIntegration);\n\nfunction isErrorEvent(event: unknown): event is RequestEvent {\n return !!(event && typeof event === 'object' && 'error' in event && event.error);\n}\n\nfunction sendErrorToSentry(errorData: object): void {\n captureException(errorData, {\n mechanism: {\n type: 'auto.function.hapi',\n handled: false,\n },\n });\n}\n\nexport const hapiErrorPlugin = {\n name: 'SentryHapiErrorPlugin',\n version: SDK_VERSION,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register: async function (serverArg: Record<any, any>) {\n const server = serverArg as unknown as Server;\n\n server.events.on({ name: 'request', channels: ['error'] }, (request: Request, event: RequestEvent) => {\n if (getIsolationScope() !== getDefaultIsolationScope()) {\n const route = request.route;\n if (route.path) {\n getIsolationScope().setTransactionName(`${route.method.toUpperCase()} ${route.path}`);\n }\n } else {\n DEBUG_BUILD &&\n debug.warn('Isolation scope is still the default isolation scope - skipping setting transactionName');\n }\n\n if (isErrorEvent(event)) {\n sendErrorToSentry(event.error);\n }\n });\n },\n};\n\n/**\n * Add a Hapi plugin to capture errors to Sentry.\n *\n * @param server The Hapi server to attach the error handler to\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const Hapi = require('@hapi/hapi');\n *\n * const init = async () => {\n * const server = Hapi.server();\n *\n * // all your routes here\n *\n * await Sentry.setupHapiErrorHandler(server);\n *\n * await server.start();\n * };\n * ```\n */\nexport async function setupHapiErrorHandler(server: Server): Promise<void> {\n await server.register(hapiErrorPlugin);\n ensureIsWrapped(server.register, 'hapi');\n}\n"],"names":[],"mappings":";;;;;AAcA,MAAM,gBAAA,GAAmB,MAAA;AAElB,MAAM,iBAAiB,sBAAA,CAAuB,gBAAA,EAAkB,MAAM,IAAI,qBAAqB;AAEtG,MAAM,oBAAoB,MAAM;AAC9B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,cAAA,EAAe;AAAA,IACjB;AAAA,GACF;AACF,CAAA,CAAA;AAkBO,MAAM,eAAA,GAAkB,kBAAkB,gBAAgB;AAEjE,SAAS,aAAa,KAAA,EAAuC;AAC3D,EAAA,OAAO,CAAC,EAAE,KAAA,IAAS,OAAO,UAAU,QAAA,IAAY,OAAA,IAAW,SAAS,KAAA,CAAM,KAAA,CAAA;AAC5E;AAEA,SAAS,kBAAkB,SAAA,EAAyB;AAClD,EAAA,gBAAA,CAAiB,SAAA,EAAW;AAAA,IAC1B,SAAA,EAAW;AAAA,MACT,IAAA,EAAM,oBAAA;AAAA,MACN,OAAA,EAAS;AAAA;AACX,GACD,CAAA;AACH;AAEO,MAAM,eAAA,GAAkB;AAAA,EAC7B,IAAA,EAAM,uBAAA;AAAA,EACN,OAAA,EAAS,WAAA;AA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