@depup/sentry__node 10.44.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/build/cjs/debug-build.js +11 -0
- package/build/cjs/debug-build.js.map +1 -0
- package/build/cjs/index.js +216 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/init.js +10 -0
- package/build/cjs/init.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/growthbook.js +12 -0
- package/build/cjs/integrations/featureFlagShims/growthbook.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/launchDarkly.js +43 -0
- package/build/cjs/integrations/featureFlagShims/launchDarkly.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/openFeature.js +55 -0
- package/build/cjs/integrations/featureFlagShims/openFeature.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/statsig.js +23 -0
- package/build/cjs/integrations/featureFlagShims/statsig.js.map +1 -0
- package/build/cjs/integrations/featureFlagShims/unleash.js +23 -0
- package/build/cjs/integrations/featureFlagShims/unleash.js.map +1 -0
- package/build/cjs/integrations/fs.js +142 -0
- package/build/cjs/integrations/fs.js.map +1 -0
- package/build/cjs/integrations/http.js +224 -0
- package/build/cjs/integrations/http.js.map +1 -0
- package/build/cjs/integrations/node-fetch.js +108 -0
- package/build/cjs/integrations/node-fetch.js.map +1 -0
- package/build/cjs/integrations/tracing/amqplib.js +47 -0
- package/build/cjs/integrations/tracing/amqplib.js.map +1 -0
- package/build/cjs/integrations/tracing/anthropic-ai/index.js +79 -0
- package/build/cjs/integrations/tracing/anthropic-ai/index.js.map +1 -0
- package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js +95 -0
- package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/connect.js +110 -0
- package/build/cjs/integrations/tracing/connect.js.map +1 -0
- package/build/cjs/integrations/tracing/dataloader.js +72 -0
- package/build/cjs/integrations/tracing/dataloader.js.map +1 -0
- package/build/cjs/integrations/tracing/express.js +166 -0
- package/build/cjs/integrations/tracing/express.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/index.js +270 -0
- package/build/cjs/integrations/tracing/fastify/index.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/v3/constants.js +23 -0
- package/build/cjs/integrations/tracing/fastify/v3/constants.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
- package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js +304 -0
- package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/fastify/v3/utils.js +135 -0
- package/build/cjs/integrations/tracing/fastify/v3/utils.js.map +1 -0
- package/build/cjs/integrations/tracing/firebase/firebase.js +50 -0
- package/build/cjs/integrations/tracing/firebase/firebase.js.map +1 -0
- package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js +44 -0
- package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js +297 -0
- package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -0
- package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js +265 -0
- package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js.map +1 -0
- package/build/cjs/integrations/tracing/genericPool.js +59 -0
- package/build/cjs/integrations/tracing/genericPool.js.map +1 -0
- package/build/cjs/integrations/tracing/google-genai/index.js +78 -0
- package/build/cjs/integrations/tracing/google-genai/index.js.map +1 -0
- package/build/cjs/integrations/tracing/google-genai/instrumentation.js +88 -0
- package/build/cjs/integrations/tracing/google-genai/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/graphql.js +127 -0
- package/build/cjs/integrations/tracing/graphql.js.map +1 -0
- package/build/cjs/integrations/tracing/hapi/index.js +135 -0
- package/build/cjs/integrations/tracing/hapi/index.js.map +1 -0
- package/build/cjs/integrations/tracing/hono/constants.js +15 -0
- package/build/cjs/integrations/tracing/hono/constants.js.map +1 -0
- package/build/cjs/integrations/tracing/hono/index.js +137 -0
- package/build/cjs/integrations/tracing/hono/index.js.map +1 -0
- package/build/cjs/integrations/tracing/hono/instrumentation.js +236 -0
- package/build/cjs/integrations/tracing/hono/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/index.js +110 -0
- package/build/cjs/integrations/tracing/index.js.map +1 -0
- package/build/cjs/integrations/tracing/kafka.js +48 -0
- package/build/cjs/integrations/tracing/kafka.js.map +1 -0
- package/build/cjs/integrations/tracing/knex.js +57 -0
- package/build/cjs/integrations/tracing/knex.js.map +1 -0
- package/build/cjs/integrations/tracing/koa.js +138 -0
- package/build/cjs/integrations/tracing/koa.js.map +1 -0
- package/build/cjs/integrations/tracing/langchain/index.js +116 -0
- package/build/cjs/integrations/tracing/langchain/index.js.map +1 -0
- package/build/cjs/integrations/tracing/langchain/instrumentation.js +220 -0
- package/build/cjs/integrations/tracing/langchain/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/langgraph/index.js +93 -0
- package/build/cjs/integrations/tracing/langgraph/index.js.map +1 -0
- package/build/cjs/integrations/tracing/langgraph/instrumentation.js +60 -0
- package/build/cjs/integrations/tracing/langgraph/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/lrumemoizer.js +37 -0
- package/build/cjs/integrations/tracing/lrumemoizer.js.map +1 -0
- package/build/cjs/integrations/tracing/mongo.js +93 -0
- package/build/cjs/integrations/tracing/mongo.js.map +1 -0
- package/build/cjs/integrations/tracing/mongoose.js +46 -0
- package/build/cjs/integrations/tracing/mongoose.js.map +1 -0
- package/build/cjs/integrations/tracing/mysql.js +38 -0
- package/build/cjs/integrations/tracing/mysql.js.map +1 -0
- package/build/cjs/integrations/tracing/mysql2.js +46 -0
- package/build/cjs/integrations/tracing/mysql2.js.map +1 -0
- package/build/cjs/integrations/tracing/openai/index.js +78 -0
- package/build/cjs/integrations/tracing/openai/index.js.map +1 -0
- package/build/cjs/integrations/tracing/openai/instrumentation.js +104 -0
- package/build/cjs/integrations/tracing/openai/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/postgres.js +48 -0
- package/build/cjs/integrations/tracing/postgres.js.map +1 -0
- package/build/cjs/integrations/tracing/postgresjs.js +378 -0
- package/build/cjs/integrations/tracing/postgresjs.js.map +1 -0
- package/build/cjs/integrations/tracing/prisma.js +203 -0
- package/build/cjs/integrations/tracing/prisma.js.map +1 -0
- package/build/cjs/integrations/tracing/redis.js +121 -0
- package/build/cjs/integrations/tracing/redis.js.map +1 -0
- package/build/cjs/integrations/tracing/tedious.js +67 -0
- package/build/cjs/integrations/tracing/tedious.js.map +1 -0
- package/build/cjs/integrations/tracing/vercelai/constants.js +6 -0
- package/build/cjs/integrations/tracing/vercelai/constants.js.map +1 -0
- package/build/cjs/integrations/tracing/vercelai/index.js +82 -0
- package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -0
- package/build/cjs/integrations/tracing/vercelai/instrumentation.js +274 -0
- package/build/cjs/integrations/tracing/vercelai/instrumentation.js.map +1 -0
- package/build/cjs/preload.js +21 -0
- package/build/cjs/preload.js.map +1 -0
- package/build/cjs/sdk/index.js +78 -0
- package/build/cjs/sdk/index.js.map +1 -0
- package/build/cjs/sdk/initOtel.js +126 -0
- package/build/cjs/sdk/initOtel.js.map +1 -0
- package/build/cjs/utils/redisCache.js +122 -0
- package/build/cjs/utils/redisCache.js.map +1 -0
- package/build/esm/debug-build.js +9 -0
- package/build/esm/debug-build.js.map +1 -0
- package/build/esm/index.js +44 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/init.js +10 -0
- package/build/esm/init.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/growthbook.js +10 -0
- package/build/esm/integrations/featureFlagShims/growthbook.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/launchDarkly.js +40 -0
- package/build/esm/integrations/featureFlagShims/launchDarkly.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/openFeature.js +52 -0
- package/build/esm/integrations/featureFlagShims/openFeature.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/statsig.js +21 -0
- package/build/esm/integrations/featureFlagShims/statsig.js.map +1 -0
- package/build/esm/integrations/featureFlagShims/unleash.js +21 -0
- package/build/esm/integrations/featureFlagShims/unleash.js.map +1 -0
- package/build/esm/integrations/fs.js +140 -0
- package/build/esm/integrations/fs.js.map +1 -0
- package/build/esm/integrations/http.js +219 -0
- package/build/esm/integrations/http.js.map +1 -0
- package/build/esm/integrations/node-fetch.js +105 -0
- package/build/esm/integrations/node-fetch.js.map +1 -0
- package/build/esm/integrations/tracing/amqplib.js +44 -0
- package/build/esm/integrations/tracing/amqplib.js.map +1 -0
- package/build/esm/integrations/tracing/anthropic-ai/index.js +76 -0
- package/build/esm/integrations/tracing/anthropic-ai/index.js.map +1 -0
- package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js +93 -0
- package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/connect.js +106 -0
- package/build/esm/integrations/tracing/connect.js.map +1 -0
- package/build/esm/integrations/tracing/dataloader.js +69 -0
- package/build/esm/integrations/tracing/dataloader.js.map +1 -0
- package/build/esm/integrations/tracing/express.js +161 -0
- package/build/esm/integrations/tracing/express.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/index.js +265 -0
- package/build/esm/integrations/tracing/fastify/index.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/v3/constants.js +21 -0
- package/build/esm/integrations/tracing/fastify/v3/constants.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
- package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/v3/instrumentation.js +302 -0
- package/build/esm/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/fastify/v3/utils.js +131 -0
- package/build/esm/integrations/tracing/fastify/v3/utils.js.map +1 -0
- package/build/esm/integrations/tracing/firebase/firebase.js +47 -0
- package/build/esm/integrations/tracing/firebase/firebase.js.map +1 -0
- package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js +42 -0
- package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js +294 -0
- package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -0
- package/build/esm/integrations/tracing/firebase/otel/patches/functions.js +262 -0
- package/build/esm/integrations/tracing/firebase/otel/patches/functions.js.map +1 -0
- package/build/esm/integrations/tracing/genericPool.js +56 -0
- package/build/esm/integrations/tracing/genericPool.js.map +1 -0
- package/build/esm/integrations/tracing/google-genai/index.js +75 -0
- package/build/esm/integrations/tracing/google-genai/index.js.map +1 -0
- package/build/esm/integrations/tracing/google-genai/instrumentation.js +86 -0
- package/build/esm/integrations/tracing/google-genai/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/graphql.js +124 -0
- package/build/esm/integrations/tracing/graphql.js.map +1 -0
- package/build/esm/integrations/tracing/hapi/index.js +130 -0
- package/build/esm/integrations/tracing/hapi/index.js.map +1 -0
- package/build/esm/integrations/tracing/hono/constants.js +12 -0
- package/build/esm/integrations/tracing/hono/constants.js.map +1 -0
- package/build/esm/integrations/tracing/hono/index.js +133 -0
- package/build/esm/integrations/tracing/hono/index.js.map +1 -0
- package/build/esm/integrations/tracing/hono/instrumentation.js +234 -0
- package/build/esm/integrations/tracing/hono/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/index.js +107 -0
- package/build/esm/integrations/tracing/index.js.map +1 -0
- package/build/esm/integrations/tracing/kafka.js +45 -0
- package/build/esm/integrations/tracing/kafka.js.map +1 -0
- package/build/esm/integrations/tracing/knex.js +54 -0
- package/build/esm/integrations/tracing/knex.js.map +1 -0
- package/build/esm/integrations/tracing/koa.js +134 -0
- package/build/esm/integrations/tracing/koa.js.map +1 -0
- package/build/esm/integrations/tracing/langchain/index.js +113 -0
- package/build/esm/integrations/tracing/langchain/index.js.map +1 -0
- package/build/esm/integrations/tracing/langchain/instrumentation.js +218 -0
- package/build/esm/integrations/tracing/langchain/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/langgraph/index.js +90 -0
- package/build/esm/integrations/tracing/langgraph/index.js.map +1 -0
- package/build/esm/integrations/tracing/langgraph/instrumentation.js +58 -0
- package/build/esm/integrations/tracing/langgraph/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/lrumemoizer.js +34 -0
- package/build/esm/integrations/tracing/lrumemoizer.js.map +1 -0
- package/build/esm/integrations/tracing/mongo.js +89 -0
- package/build/esm/integrations/tracing/mongo.js.map +1 -0
- package/build/esm/integrations/tracing/mongoose.js +43 -0
- package/build/esm/integrations/tracing/mongoose.js.map +1 -0
- package/build/esm/integrations/tracing/mysql.js +35 -0
- package/build/esm/integrations/tracing/mysql.js.map +1 -0
- package/build/esm/integrations/tracing/mysql2.js +43 -0
- package/build/esm/integrations/tracing/mysql2.js.map +1 -0
- package/build/esm/integrations/tracing/openai/index.js +75 -0
- package/build/esm/integrations/tracing/openai/index.js.map +1 -0
- package/build/esm/integrations/tracing/openai/instrumentation.js +102 -0
- package/build/esm/integrations/tracing/openai/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/postgres.js +45 -0
- package/build/esm/integrations/tracing/postgres.js.map +1 -0
- package/build/esm/integrations/tracing/postgresjs.js +374 -0
- package/build/esm/integrations/tracing/postgresjs.js.map +1 -0
- package/build/esm/integrations/tracing/prisma.js +200 -0
- package/build/esm/integrations/tracing/prisma.js.map +1 -0
- package/build/esm/integrations/tracing/redis.js +117 -0
- package/build/esm/integrations/tracing/redis.js.map +1 -0
- package/build/esm/integrations/tracing/tedious.js +64 -0
- package/build/esm/integrations/tracing/tedious.js.map +1 -0
- package/build/esm/integrations/tracing/vercelai/constants.js +4 -0
- package/build/esm/integrations/tracing/vercelai/constants.js.map +1 -0
- package/build/esm/integrations/tracing/vercelai/index.js +79 -0
- package/build/esm/integrations/tracing/vercelai/index.js.map +1 -0
- package/build/esm/integrations/tracing/vercelai/instrumentation.js +269 -0
- package/build/esm/integrations/tracing/vercelai/instrumentation.js.map +1 -0
- package/build/esm/package.json +1 -0
- package/build/esm/preload.js +21 -0
- package/build/esm/preload.js.map +1 -0
- package/build/esm/sdk/index.js +73 -0
- package/build/esm/sdk/index.js.map +1 -0
- package/build/esm/sdk/initOtel.js +121 -0
- package/build/esm/sdk/initOtel.js.map +1 -0
- package/build/esm/utils/redisCache.js +114 -0
- package/build/esm/utils/redisCache.js.map +1 -0
- package/build/import-hook.mjs +5 -0
- package/build/loader-hook.mjs +1 -0
- package/build/types/debug-build.d.ts +7 -0
- package/build/types/debug-build.d.ts.map +1 -0
- package/build/types/index.d.ts +42 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/init.d.ts +2 -0
- package/build/types/init.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/growthbook.d.ts +6 -0
- package/build/types/integrations/featureFlagShims/growthbook.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/index.d.ts +6 -0
- package/build/types/integrations/featureFlagShims/index.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/launchDarkly.d.ts +10 -0
- package/build/types/integrations/featureFlagShims/launchDarkly.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/openFeature.d.ts +23 -0
- package/build/types/integrations/featureFlagShims/openFeature.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/statsig.d.ts +6 -0
- package/build/types/integrations/featureFlagShims/statsig.d.ts.map +1 -0
- package/build/types/integrations/featureFlagShims/unleash.d.ts +6 -0
- package/build/types/integrations/featureFlagShims/unleash.d.ts.map +1 -0
- package/build/types/integrations/fs.d.ts +24 -0
- package/build/types/integrations/fs.d.ts.map +1 -0
- package/build/types/integrations/http.d.ts +136 -0
- package/build/types/integrations/http.d.ts.map +1 -0
- package/build/types/integrations/node-fetch.d.ts +36 -0
- package/build/types/integrations/node-fetch.d.ts.map +1 -0
- package/build/types/integrations/tracing/amqplib.d.ts +20 -0
- package/build/types/integrations/tracing/amqplib.d.ts.map +1 -0
- package/build/types/integrations/tracing/anthropic-ai/index.d.ts +59 -0
- package/build/types/integrations/tracing/anthropic-ai/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/anthropic-ai/instrumentation.d.ts +19 -0
- package/build/types/integrations/tracing/anthropic-ai/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/connect.d.ts +46 -0
- package/build/types/integrations/tracing/connect.d.ts.map +1 -0
- package/build/types/integrations/tracing/dataloader.d.ts +20 -0
- package/build/types/integrations/tracing/dataloader.d.ts.map +1 -0
- package/build/types/integrations/tracing/express.d.ts +72 -0
- package/build/types/integrations/tracing/express.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/index.d.ts +119 -0
- package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/types.d.ts +33 -0
- package/build/types/integrations/tracing/fastify/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/constants.d.ts +3 -0
- package/build/types/integrations/tracing/fastify/v3/constants.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
- package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
- package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
- package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/types.d.ts +21 -0
- package/build/types/integrations/tracing/fastify/v3/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/fastify/v3/utils.d.ts +28 -0
- package/build/types/integrations/tracing/fastify/v3/utils.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/firebase.d.ts +6 -0
- package/build/types/integrations/tracing/firebase/firebase.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/index.d.ts +2 -0
- package/build/types/integrations/tracing/firebase/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +19 -0
- package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/index.d.ts +3 -0
- package/build/types/integrations/tracing/firebase/otel/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts +25 -0
- package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
- package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts.map +1 -0
- package/build/types/integrations/tracing/firebase/otel/types.d.ts +120 -0
- package/build/types/integrations/tracing/firebase/otel/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/genericPool.d.ts +20 -0
- package/build/types/integrations/tracing/genericPool.d.ts.map +1 -0
- package/build/types/integrations/tracing/google-genai/index.d.ts +59 -0
- package/build/types/integrations/tracing/google-genai/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/google-genai/instrumentation.d.ts +20 -0
- package/build/types/integrations/tracing/google-genai/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/graphql.d.ts +48 -0
- package/build/types/integrations/tracing/graphql.d.ts.map +1 -0
- package/build/types/integrations/tracing/hapi/index.d.ts +50 -0
- package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/hapi/types.d.ts +166 -0
- package/build/types/integrations/tracing/hapi/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/hono/constants.d.ts +11 -0
- package/build/types/integrations/tracing/hono/constants.d.ts.map +1 -0
- package/build/types/integrations/tracing/hono/index.d.ts +52 -0
- package/build/types/integrations/tracing/hono/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/hono/instrumentation.d.ts +55 -0
- package/build/types/integrations/tracing/hono/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/hono/types.d.ts +36 -0
- package/build/types/integrations/tracing/hono/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/index.d.ts +12 -0
- package/build/types/integrations/tracing/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/kafka.d.ts +19 -0
- package/build/types/integrations/tracing/kafka.d.ts.map +1 -0
- package/build/types/integrations/tracing/knex.d.ts +20 -0
- package/build/types/integrations/tracing/knex.d.ts.map +1 -0
- package/build/types/integrations/tracing/koa.d.ts +70 -0
- package/build/types/integrations/tracing/koa.d.ts.map +1 -0
- package/build/types/integrations/tracing/langchain/index.d.ts +97 -0
- package/build/types/integrations/tracing/langchain/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/langchain/instrumentation.d.ts +29 -0
- package/build/types/integrations/tracing/langchain/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/langgraph/index.d.ts +74 -0
- package/build/types/integrations/tracing/langgraph/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/langgraph/instrumentation.d.ts +19 -0
- package/build/types/integrations/tracing/langgraph/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/lrumemoizer.d.ts +19 -0
- package/build/types/integrations/tracing/lrumemoizer.d.ts.map +1 -0
- package/build/types/integrations/tracing/mongo.d.ts +24 -0
- package/build/types/integrations/tracing/mongo.d.ts.map +1 -0
- package/build/types/integrations/tracing/mongoose.d.ts +20 -0
- package/build/types/integrations/tracing/mongoose.d.ts.map +1 -0
- package/build/types/integrations/tracing/mysql.d.ts +20 -0
- package/build/types/integrations/tracing/mysql.d.ts.map +1 -0
- package/build/types/integrations/tracing/mysql2.d.ts +20 -0
- package/build/types/integrations/tracing/mysql2.d.ts.map +1 -0
- package/build/types/integrations/tracing/openai/index.d.ts +59 -0
- package/build/types/integrations/tracing/openai/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/openai/instrumentation.d.ts +26 -0
- package/build/types/integrations/tracing/openai/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/postgres.d.ts +24 -0
- package/build/types/integrations/tracing/postgres.d.ts.map +1 -0
- package/build/types/integrations/tracing/postgresjs.d.ts +101 -0
- package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -0
- package/build/types/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts +38 -0
- package/build/types/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts.map +1 -0
- package/build/types/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts +31 -0
- package/build/types/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts.map +1 -0
- package/build/types/integrations/tracing/prisma.d.ts +50 -0
- package/build/types/integrations/tracing/prisma.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis.d.ts +41 -0
- package/build/types/integrations/tracing/redis.d.ts.map +1 -0
- package/build/types/integrations/tracing/tedious.d.ts +20 -0
- package/build/types/integrations/tracing/tedious.d.ts.map +1 -0
- package/build/types/integrations/tracing/vercelai/constants.d.ts +2 -0
- package/build/types/integrations/tracing/vercelai/constants.d.ts.map +1 -0
- package/build/types/integrations/tracing/vercelai/index.d.ts +43 -0
- package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/vercelai/instrumentation.d.ts +56 -0
- package/build/types/integrations/tracing/vercelai/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/vercelai/types.d.ts +59 -0
- package/build/types/integrations/tracing/vercelai/types.d.ts.map +1 -0
- package/build/types/preload.d.ts +2 -0
- package/build/types/preload.d.ts.map +1 -0
- package/build/types/sdk/index.d.ts +18 -0
- package/build/types/sdk/index.d.ts.map +1 -0
- package/build/types/sdk/initOtel.d.ts +28 -0
- package/build/types/sdk/initOtel.d.ts.map +1 -0
- package/build/types/types.d.ts +89 -0
- package/build/types/types.d.ts.map +1 -0
- package/build/types/utils/redisCache.d.ts +16 -0
- package/build/types/utils/redisCache.d.ts.map +1 -0
- package/build/types-ts3.8/debug-build.d.ts +7 -0
- package/build/types-ts3.8/index.d.ts +42 -0
- package/build/types-ts3.8/init.d.ts +2 -0
- package/build/types-ts3.8/integrations/featureFlagShims/growthbook.d.ts +6 -0
- package/build/types-ts3.8/integrations/featureFlagShims/index.d.ts +6 -0
- package/build/types-ts3.8/integrations/featureFlagShims/launchDarkly.d.ts +10 -0
- package/build/types-ts3.8/integrations/featureFlagShims/openFeature.d.ts +23 -0
- package/build/types-ts3.8/integrations/featureFlagShims/statsig.d.ts +6 -0
- package/build/types-ts3.8/integrations/featureFlagShims/unleash.d.ts +6 -0
- package/build/types-ts3.8/integrations/fs.d.ts +24 -0
- package/build/types-ts3.8/integrations/http.d.ts +139 -0
- package/build/types-ts3.8/integrations/node-fetch.d.ts +36 -0
- package/build/types-ts3.8/integrations/tracing/amqplib.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/anthropic-ai/index.d.ts +59 -0
- package/build/types-ts3.8/integrations/tracing/anthropic-ai/instrumentation.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/connect.d.ts +46 -0
- package/build/types-ts3.8/integrations/tracing/dataloader.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/express.d.ts +72 -0
- package/build/types-ts3.8/integrations/tracing/fastify/index.d.ts +119 -0
- package/build/types-ts3.8/integrations/tracing/fastify/types.d.ts +33 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/constants.d.ts +3 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/types.d.ts +21 -0
- package/build/types-ts3.8/integrations/tracing/fastify/v3/utils.d.ts +28 -0
- package/build/types-ts3.8/integrations/tracing/firebase/firebase.d.ts +6 -0
- package/build/types-ts3.8/integrations/tracing/firebase/index.d.ts +2 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/index.d.ts +3 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/firestore.d.ts +25 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
- package/build/types-ts3.8/integrations/tracing/firebase/otel/types.d.ts +120 -0
- package/build/types-ts3.8/integrations/tracing/genericPool.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/google-genai/index.d.ts +59 -0
- package/build/types-ts3.8/integrations/tracing/google-genai/instrumentation.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/graphql.d.ts +48 -0
- package/build/types-ts3.8/integrations/tracing/hapi/index.d.ts +50 -0
- package/build/types-ts3.8/integrations/tracing/hapi/types.d.ts +166 -0
- package/build/types-ts3.8/integrations/tracing/hono/constants.d.ts +11 -0
- package/build/types-ts3.8/integrations/tracing/hono/index.d.ts +52 -0
- package/build/types-ts3.8/integrations/tracing/hono/instrumentation.d.ts +55 -0
- package/build/types-ts3.8/integrations/tracing/hono/types.d.ts +36 -0
- package/build/types-ts3.8/integrations/tracing/index.d.ts +12 -0
- package/build/types-ts3.8/integrations/tracing/kafka.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/knex.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/koa.d.ts +70 -0
- package/build/types-ts3.8/integrations/tracing/langchain/index.d.ts +97 -0
- package/build/types-ts3.8/integrations/tracing/langchain/instrumentation.d.ts +29 -0
- package/build/types-ts3.8/integrations/tracing/langgraph/index.d.ts +74 -0
- package/build/types-ts3.8/integrations/tracing/langgraph/instrumentation.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/lrumemoizer.d.ts +19 -0
- package/build/types-ts3.8/integrations/tracing/mongo.d.ts +24 -0
- package/build/types-ts3.8/integrations/tracing/mongoose.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/mysql.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/mysql2.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/openai/index.d.ts +59 -0
- package/build/types-ts3.8/integrations/tracing/openai/instrumentation.d.ts +26 -0
- package/build/types-ts3.8/integrations/tracing/postgres.d.ts +24 -0
- package/build/types-ts3.8/integrations/tracing/postgresjs.d.ts +101 -0
- package/build/types-ts3.8/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts +44 -0
- package/build/types-ts3.8/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts +34 -0
- package/build/types-ts3.8/integrations/tracing/prisma.d.ts +50 -0
- package/build/types-ts3.8/integrations/tracing/redis.d.ts +41 -0
- package/build/types-ts3.8/integrations/tracing/tedious.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/vercelai/constants.d.ts +2 -0
- package/build/types-ts3.8/integrations/tracing/vercelai/index.d.ts +43 -0
- package/build/types-ts3.8/integrations/tracing/vercelai/instrumentation.d.ts +56 -0
- package/build/types-ts3.8/integrations/tracing/vercelai/types.d.ts +59 -0
- package/build/types-ts3.8/preload.d.ts +2 -0
- package/build/types-ts3.8/sdk/index.d.ts +18 -0
- package/build/types-ts3.8/sdk/initOtel.d.ts +31 -0
- package/build/types-ts3.8/types.d.ts +89 -0
- package/build/types-ts3.8/utils/redisCache.d.ts +16 -0
- package/changes.json +10 -0
- package/package.json +150 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.js","sources":["../../../../src/integrations/tracing/graphql.ts"],"sourcesContent":["import type { AttributeValue } from '@opentelemetry/api';\nimport { SpanStatusCode } from '@opentelemetry/api';\nimport { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, getRootSpan, spanToJSON } from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';\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) => {\n const options = getOptionsWithDefaults(_options);\n\n return {\n ...options,\n responseHook(span, result) {\n addOriginToSpan(span, 'auto.graphql.otel.graphql');\n\n // We want to ensure spans are marked as errored if there are errors in the result\n // We only do that if the span is not already marked with a status\n const resultWithMaybeError = result as { errors?: { message: string }[] };\n if (resultWithMaybeError.errors?.length && !spanToJSON(span).status) {\n span.setStatus({ code: SpanStatusCode.ERROR });\n }\n\n const attributes = spanToJSON(span).data;\n\n // If operation.name is not set, we fall back to use operation.type only\n const operationType = attributes['graphql.operation.type'];\n const operationName = attributes['graphql.operation.name'];\n\n if (options.useOperationNameForRootSpan && operationType) {\n const rootSpan = getRootSpan(span);\n const rootSpanAttributes = spanToJSON(rootSpan).data;\n\n const existingOperations = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION] || [];\n\n const newOperation = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n\n // We keep track of each operation on the root span\n // This can either be a string, or an array of strings (if there are multiple operations)\n if (Array.isArray(existingOperations)) {\n (existingOperations as string[]).push(newOperation);\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, existingOperations);\n } else if (typeof existingOperations === 'string') {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);\n } else {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, newOperation);\n }\n\n if (!spanToJSON(rootSpan).data['original-description']) {\n rootSpan.setAttribute('original-description', spanToJSON(rootSpan).description);\n }\n // Important for e.g. @sentry/aws-serverless because this would otherwise overwrite the name again\n rootSpan.updateName(\n `${spanToJSON(rootSpan).data['original-description']} (${getGraphqlOperationNamesFromAttribute(\n existingOperations,\n )})`,\n );\n }\n },\n };\n },\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\n// copy from packages/opentelemetry/utils\nfunction getGraphqlOperationNamesFromAttribute(attr: AttributeValue): string {\n if (Array.isArray(attr)) {\n // oxlint-disable-next-line typescript/require-array-sort-compare\n const sorted = attr.slice().sort();\n\n // Up to 5 items, we just add all of them\n if (sorted.length <= 5) {\n return sorted.join(', ');\n } else {\n // Else, we add the first 5 and the diff of other operations\n return `${sorted.slice(0, 5).join(', ')}, +${sorted.length - 5}`;\n }\n }\n\n return `${attr}`;\n}\n"],"names":[],"mappings":";;;;;;AAqCA,MAAM,gBAAA,GAAmB,SAAS;;AAE3B,MAAM,iBAAA,GAAoB,sBAAsB;AACvD,EAAE,gBAAgB;AAClB,EAAE,sBAAsB;AACxB,EAAE,CAAC,QAAQ,KAAqB;AAChC,IAAI,MAAM,OAAA,GAAU,sBAAsB,CAAC,QAAQ,CAAC;;AAEpD,IAAI,OAAO;AACX,MAAM,GAAG,OAAO;AAChB,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE;AACjC,QAAQ,eAAe,CAAC,IAAI,EAAE,2BAA2B,CAAC;;AAE1D;AACA;AACA,QAAQ,MAAM,oBAAA,GAAuB,MAAA;AACrC,QAAQ,IAAI,oBAAoB,CAAC,MAAM,EAAE,MAAA,IAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;AAC7E,UAAU,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,KAAA,EAAO,CAAC;AACxD,QAAQ;;AAER,QAAQ,MAAM,aAAa,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI;;AAEhD;AACA,QAAQ,MAAM,aAAA,GAAgB,UAAU,CAAC,wBAAwB,CAAC;AAClE,QAAQ,MAAM,aAAA,GAAgB,UAAU,CAAC,wBAAwB,CAAC;;AAElE,QAAQ,IAAI,OAAO,CAAC,2BAAA,IAA+B,aAAa,EAAE;AAClE,UAAU,MAAM,QAAA,GAAW,WAAW,CAAC,IAAI,CAAC;AAC5C,UAAU,MAAM,qBAAqB,UAAU,CAAC,QAAQ,CAA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ACA,MAAA,iBAAA,CAAA,sBAAA,CAAA,OAAA,CAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,kBAAA,GAAA,iBAAA,CAAA,mBAAA;;AAEA,SAAA,sBAAA,CAAA,OAAA,EAAA;AACA,EAAA,OAAA;AACA,IAAA,kBAAA,EAAA,IAAA;AACA,IAAA,yBAAA,EAAA,IAAA;AACA,IAAA,2BAAA,EAAA,IAAA;AACA,IAAA,GAAA,OAAA;AACA,GAAA;AACA;;AAEA;AACA,SAAA,qCAAA,CAAA,IAAA,EAAA;AACA,EAAA,IAAA,KAAA,CAAA,OAAA,CAAA,IAAA,CAAA,EAAA;AACA;AACA,IAAA,MAAA,MAAA,GAAA,IAAA,CAAA,KAAA,EAAA,CAAA,IAAA,EAAA;;AAEA;AACA,IAAA,IAAA,MAAA,CAAA,MAAA,IAAA,CAAA,EAAA;AACA,MAAA,OAAA,MAAA,CAAA,IAAA,CAAA,IAAA,CAAA;AACA,IAAA,CAAA,MAAA;AACA;AACA,MAAA,OAAA,CAAA,EAAA,MAAA,CAAA,KAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA,GAAA,EAAA,MAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,OAAA,CAAA,EAAA,IAAA,CAAA,CAAA;AACA;;;;"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { HapiInstrumentation } from '@opentelemetry/instrumentation-hapi';
|
|
2
|
+
import { defineIntegration, SDK_VERSION, getClient, getIsolationScope, getDefaultIsolationScope, debug, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, captureException } from '@sentry/core';
|
|
3
|
+
import { generateInstrumentOnce, ensureIsWrapped } from '@sentry/node-core';
|
|
4
|
+
import { DEBUG_BUILD } from '../../../debug-build.js';
|
|
5
|
+
|
|
6
|
+
const INTEGRATION_NAME = 'Hapi';
|
|
7
|
+
|
|
8
|
+
const instrumentHapi = generateInstrumentOnce(INTEGRATION_NAME, () => new HapiInstrumentation());
|
|
9
|
+
|
|
10
|
+
const _hapiIntegration = (() => {
|
|
11
|
+
return {
|
|
12
|
+
name: INTEGRATION_NAME,
|
|
13
|
+
setupOnce() {
|
|
14
|
+
instrumentHapi();
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}) ;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Adds Sentry tracing instrumentation for [Hapi](https://hapi.dev/).
|
|
21
|
+
*
|
|
22
|
+
* If you also want to capture errors, you need to call `setupHapiErrorHandler(server)` after you set up your server.
|
|
23
|
+
*
|
|
24
|
+
* For more information, see the [hapi documentation](https://docs.sentry.io/platforms/javascript/guides/hapi/).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```javascript
|
|
28
|
+
* const Sentry = require('@sentry/node');
|
|
29
|
+
*
|
|
30
|
+
* Sentry.init({
|
|
31
|
+
* integrations: [Sentry.hapiIntegration()],
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
const hapiIntegration = defineIntegration(_hapiIntegration);
|
|
36
|
+
|
|
37
|
+
function isErrorEvent(event) {
|
|
38
|
+
return !!(event && typeof event === 'object' && 'error' in event && event.error);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function sendErrorToSentry(errorData) {
|
|
42
|
+
captureException(errorData, {
|
|
43
|
+
mechanism: {
|
|
44
|
+
type: 'auto.function.hapi',
|
|
45
|
+
handled: false,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const hapiErrorPlugin = {
|
|
51
|
+
name: 'SentryHapiErrorPlugin',
|
|
52
|
+
version: SDK_VERSION,
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
register: async function (serverArg) {
|
|
55
|
+
const server = serverArg ;
|
|
56
|
+
|
|
57
|
+
server.events.on({ name: 'request', channels: ['error'] }, (request, event) => {
|
|
58
|
+
if (getIsolationScope() !== getDefaultIsolationScope()) {
|
|
59
|
+
const route = request.route;
|
|
60
|
+
if (route.path) {
|
|
61
|
+
getIsolationScope().setTransactionName(`${route.method.toUpperCase()} ${route.path}`);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
DEBUG_BUILD &&
|
|
65
|
+
debug.warn('Isolation scope is still the default isolation scope - skipping setting transactionName');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (isErrorEvent(event)) {
|
|
69
|
+
sendErrorToSentry(event.error);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Add a Hapi plugin to capture errors to Sentry.
|
|
77
|
+
*
|
|
78
|
+
* @param server The Hapi server to attach the error handler to
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```javascript
|
|
82
|
+
* const Sentry = require('@sentry/node');
|
|
83
|
+
* const Hapi = require('@hapi/hapi');
|
|
84
|
+
*
|
|
85
|
+
* const init = async () => {
|
|
86
|
+
* const server = Hapi.server();
|
|
87
|
+
*
|
|
88
|
+
* // all your routes here
|
|
89
|
+
*
|
|
90
|
+
* await Sentry.setupHapiErrorHandler(server);
|
|
91
|
+
*
|
|
92
|
+
* await server.start();
|
|
93
|
+
* };
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
async function setupHapiErrorHandler(server) {
|
|
97
|
+
await server.register(hapiErrorPlugin);
|
|
98
|
+
|
|
99
|
+
// Sadly, middleware spans do not go through `requestHook`, so we handle those here
|
|
100
|
+
// We register this hook in this method, because if we register it in the integration `setup`,
|
|
101
|
+
// it would always run even for users that are not even using hapi
|
|
102
|
+
const client = getClient();
|
|
103
|
+
if (client) {
|
|
104
|
+
client.on('spanStart', span => {
|
|
105
|
+
addHapiSpanAttributes(span);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
ensureIsWrapped(server.register, 'hapi');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function addHapiSpanAttributes(span) {
|
|
113
|
+
const attributes = spanToJSON(span).data;
|
|
114
|
+
|
|
115
|
+
// this is one of: router, plugin, server.ext
|
|
116
|
+
const type = attributes['hapi.type'];
|
|
117
|
+
|
|
118
|
+
// If this is already set, or we have no Hapi span, no need to process again...
|
|
119
|
+
if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
span.setAttributes({
|
|
124
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.hapi',
|
|
125
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.hapi`,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { hapiErrorPlugin, hapiIntegration, instrumentHapi, setupHapiErrorHandler };
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/hapi/index.ts"],"sourcesContent":["import { HapiInstrumentation } from '@opentelemetry/instrumentation-hapi';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n captureException,\n debug,\n defineIntegration,\n getClient,\n getDefaultIsolationScope,\n getIsolationScope,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\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\n // Sadly, middleware spans do not go through `requestHook`, so we handle those here\n // We register this hook in this method, because if we register it in the integration `setup`,\n // it would always run even for users that are not even using hapi\n const client = getClient();\n if (client) {\n client.on('spanStart', span => {\n addHapiSpanAttributes(span);\n });\n }\n\n ensureIsWrapped(server.register, 'hapi');\n}\n\nfunction addHapiSpanAttributes(span: Span): void {\n const attributes = spanToJSON(span).data;\n\n // this is one of: router, plugin, server.ext\n const type = attributes['hapi.type'];\n\n // If this is already set, or we have no Hapi span, no need to process again...\n if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {\n return;\n }\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.hapi',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.hapi`,\n });\n}\n"],"names":[],"mappings":";;;;;AAkBA,MAAM,gBAAA,GAAmB,MAAM;;AAExB,MAAM,cAAA,GAAiB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,IAAI,mBAAmB,EAAE;;AAEtG,MAAM,gBAAA,IAAoB,MAAM;AAChC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,cAAc,EAAE;AACtB,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,eAAA,GAAkB,iBAAiB,CAAC,gBAAgB;;AAEjE,SAAS,YAAY,CAAC,KAAK,EAAkC;AAC7D,EAAE,OAAO,CAAC,EAAE,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,WAAW,KAAA,IAAS,KAAK,CAAC,KAAK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MAAA,EAAA;AACA,EAAA,MAAA,MAAA,CAAA,QAAA,CAAA,eAAA,CAAA;;AAEA;AACA;AACA;AACA,EAAA,MAAA,MAAA,GAAA,SAAA,EAAA;AACA,EAAA,IAAA,MAAA,EAAA;AACA,IAAA,MAAA,CAAA,EAAA,CAAA,WAAA,EAAA,IAAA,IAAA;AACA,MAAA,qBAAA,CAAA,IAAA,CAAA;AACA,IAAA,CAAA,CAAA;AACA,EAAA;;AAEA,EAAA,eAAA,CAAA,MAAA,CAAA,QAAA,EAAA,MAAA,CAAA;AACA;;AAEA,SAAA,qBAAA,CAAA,IAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAA,UAAA,CAAA,IAAA,CAAA,CAAA,IAAA;;AAEA;AACA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,WAAA,CAAA;;AAEA;AACA,EAAA,IAAA,UAAA,CAAA,4BAAA,CAAA,IAAA,CAAA,IAAA,EAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,IAAA,CAAA,aAAA,CAAA;AACA,IAAA,CAAA,gCAAA,GAAA,qBAAA;AACA,IAAA,CAAA,4BAAA,GAAA,CAAA,EAAA,IAAA,CAAA,KAAA,CAAA;AACA,GAAA,CAAA;AACA;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const AttributeNames = {
|
|
2
|
+
HONO_TYPE: 'hono.type',
|
|
3
|
+
HONO_NAME: 'hono.name',
|
|
4
|
+
} ;
|
|
5
|
+
|
|
6
|
+
const HonoTypes = {
|
|
7
|
+
MIDDLEWARE: 'middleware',
|
|
8
|
+
REQUEST_HANDLER: 'request_handler',
|
|
9
|
+
} ;
|
|
10
|
+
|
|
11
|
+
export { AttributeNames, HonoTypes };
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../../src/integrations/tracing/hono/constants.ts"],"sourcesContent":["export const AttributeNames = {\n HONO_TYPE: 'hono.type',\n HONO_NAME: 'hono.name',\n} as const;\n\nexport type AttributeNames = (typeof AttributeNames)[keyof typeof AttributeNames];\n\nexport const HonoTypes = {\n MIDDLEWARE: 'middleware',\n REQUEST_HANDLER: 'request_handler',\n} as const;\n\nexport type HonoTypes = (typeof HonoTypes)[keyof typeof HonoTypes];\n"],"names":[],"mappings":"AAAO,MAAM,iBAAiB;AAC9B,EAAE,SAAS,EAAE,WAAW;AACxB,EAAE,SAAS,EAAE,WAAW;AACxB,CAAA;;AAIO,MAAM,YAAY;AACzB,EAAE,UAAU,EAAE,YAAY;AAC1B,EAAE,eAAe,EAAE,iBAAiB;AACpC,CAAA;;;;"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { ATTR_HTTP_ROUTE, ATTR_HTTP_REQUEST_METHOD } from '@opentelemetry/semantic-conventions';
|
|
2
|
+
import { defineIntegration, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getIsolationScope, getDefaultIsolationScope, debug, httpRequestToRequestData, captureException } from '@sentry/core';
|
|
3
|
+
import { generateInstrumentOnce, ensureIsWrapped } from '@sentry/node-core';
|
|
4
|
+
import { DEBUG_BUILD } from '../../../debug-build.js';
|
|
5
|
+
import { AttributeNames } from './constants.js';
|
|
6
|
+
import { HonoInstrumentation } from './instrumentation.js';
|
|
7
|
+
|
|
8
|
+
const INTEGRATION_NAME = 'Hono';
|
|
9
|
+
|
|
10
|
+
function addHonoSpanAttributes(span) {
|
|
11
|
+
const attributes = spanToJSON(span).data;
|
|
12
|
+
const type = attributes[AttributeNames.HONO_TYPE];
|
|
13
|
+
if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
span.setAttributes({
|
|
18
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.hono',
|
|
19
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.hono`,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const name = attributes[AttributeNames.HONO_NAME];
|
|
23
|
+
if (typeof name === 'string') {
|
|
24
|
+
span.updateName(name);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (getIsolationScope() === getDefaultIsolationScope()) {
|
|
28
|
+
DEBUG_BUILD && debug.warn('Isolation scope is default isolation scope - skipping setting transactionName');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const route = attributes[ATTR_HTTP_ROUTE];
|
|
33
|
+
const method = attributes[ATTR_HTTP_REQUEST_METHOD];
|
|
34
|
+
if (typeof route === 'string' && typeof method === 'string') {
|
|
35
|
+
getIsolationScope().setTransactionName(`${method} ${route}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const instrumentHono = generateInstrumentOnce(
|
|
40
|
+
INTEGRATION_NAME,
|
|
41
|
+
() =>
|
|
42
|
+
new HonoInstrumentation({
|
|
43
|
+
responseHook: span => {
|
|
44
|
+
addHonoSpanAttributes(span);
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const _honoIntegration = (() => {
|
|
50
|
+
return {
|
|
51
|
+
name: INTEGRATION_NAME,
|
|
52
|
+
setupOnce() {
|
|
53
|
+
instrumentHono();
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}) ;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Adds Sentry tracing instrumentation for [Hono](https://hono.dev/).
|
|
60
|
+
*
|
|
61
|
+
* If you also want to capture errors, you need to call `setupHonoErrorHandler(app)` after you set up your Hono server.
|
|
62
|
+
*
|
|
63
|
+
* For more information, see the [hono documentation](https://docs.sentry.io/platforms/javascript/guides/hono/).
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```javascript
|
|
67
|
+
* const Sentry = require('@sentry/node');
|
|
68
|
+
*
|
|
69
|
+
* Sentry.init({
|
|
70
|
+
* integrations: [Sentry.honoIntegration()],
|
|
71
|
+
* })
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
const honoIntegration = defineIntegration(_honoIntegration);
|
|
75
|
+
|
|
76
|
+
function honoRequestHandler() {
|
|
77
|
+
return async function sentryRequestMiddleware(context, next) {
|
|
78
|
+
const normalizedRequest = httpRequestToRequestData(context.req);
|
|
79
|
+
getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });
|
|
80
|
+
await next();
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function defaultShouldHandleError(context) {
|
|
85
|
+
const statusCode = context.res.status;
|
|
86
|
+
return statusCode >= 500;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function honoErrorHandler(options) {
|
|
90
|
+
return async function sentryErrorMiddleware(context, next) {
|
|
91
|
+
await next();
|
|
92
|
+
|
|
93
|
+
const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;
|
|
94
|
+
if (shouldHandleError(context)) {
|
|
95
|
+
(context.res ).sentry = captureException(context.error, {
|
|
96
|
+
mechanism: {
|
|
97
|
+
type: 'auto.middleware.hono',
|
|
98
|
+
handled: false,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Add a Hono error handler to capture errors to Sentry.
|
|
107
|
+
*
|
|
108
|
+
* @param app The Hono instances
|
|
109
|
+
* @param options Configuration options for the handler
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```javascript
|
|
113
|
+
* const Sentry = require('@sentry/node');
|
|
114
|
+
* const { Hono } = require("hono");
|
|
115
|
+
*
|
|
116
|
+
* const app = new Hono();
|
|
117
|
+
*
|
|
118
|
+
* Sentry.setupHonoErrorHandler(app);
|
|
119
|
+
*
|
|
120
|
+
* // Add your routes, etc.
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
function setupHonoErrorHandler(
|
|
124
|
+
app,
|
|
125
|
+
options,
|
|
126
|
+
) {
|
|
127
|
+
app.use(honoRequestHandler());
|
|
128
|
+
app.use(honoErrorHandler(options));
|
|
129
|
+
ensureIsWrapped(app.use, 'hono');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { honoIntegration, instrumentHono, setupHonoErrorHandler };
|
|
133
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/hono/index.ts"],"sourcesContent":["import { ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n captureException,\n debug,\n defineIntegration,\n getDefaultIsolationScope,\n getIsolationScope,\n httpRequestToRequestData,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n} from '@sentry/core';\nimport { ensureIsWrapped, generateInstrumentOnce } from '@sentry/node-core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport { AttributeNames } from './constants';\nimport { HonoInstrumentation } from './instrumentation';\nimport type { Context, MiddlewareHandler, MiddlewareHandlerInterface, Next } from './types';\n\nconst INTEGRATION_NAME = 'Hono';\n\nfunction addHonoSpanAttributes(span: Span): void {\n const attributes = spanToJSON(span).data;\n const type = attributes[AttributeNames.HONO_TYPE];\n if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {\n return;\n }\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.hono',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.hono`,\n });\n\n const name = attributes[AttributeNames.HONO_NAME];\n if (typeof name === 'string') {\n span.updateName(name);\n }\n\n if (getIsolationScope() === getDefaultIsolationScope()) {\n DEBUG_BUILD && debug.warn('Isolation scope is default isolation scope - skipping setting transactionName');\n return;\n }\n\n const route = attributes[ATTR_HTTP_ROUTE];\n const method = attributes[ATTR_HTTP_REQUEST_METHOD];\n if (typeof route === 'string' && typeof method === 'string') {\n getIsolationScope().setTransactionName(`${method} ${route}`);\n }\n}\n\nexport const instrumentHono = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n new HonoInstrumentation({\n responseHook: span => {\n addHonoSpanAttributes(span);\n },\n }),\n);\n\nconst _honoIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentHono();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for [Hono](https://hono.dev/).\n *\n * If you also want to capture errors, you need to call `setupHonoErrorHandler(app)` after you set up your Hono server.\n *\n * For more information, see the [hono documentation](https://docs.sentry.io/platforms/javascript/guides/hono/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.honoIntegration()],\n * })\n * ```\n */\nexport const honoIntegration = defineIntegration(_honoIntegration);\n\ninterface HonoHandlerOptions {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n * @param error Captured Hono error\n */\n shouldHandleError: (context: Context) => boolean;\n}\n\nfunction honoRequestHandler(): MiddlewareHandler {\n return async function sentryRequestMiddleware(context: Context, next: Next): Promise<void> {\n const normalizedRequest = httpRequestToRequestData(context.req);\n getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });\n await next();\n };\n}\n\nfunction defaultShouldHandleError(context: Context): boolean {\n const statusCode = context.res.status;\n return statusCode >= 500;\n}\n\nfunction honoErrorHandler(options?: Partial<HonoHandlerOptions>): MiddlewareHandler {\n return async function sentryErrorMiddleware(context: Context, next: Next): Promise<void> {\n await next();\n\n const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;\n if (shouldHandleError(context)) {\n (context.res as { sentry?: string }).sentry = captureException(context.error, {\n mechanism: {\n type: 'auto.middleware.hono',\n handled: false,\n },\n });\n }\n };\n}\n\n/**\n * Add a Hono error handler to capture errors to Sentry.\n *\n * @param app The Hono instances\n * @param options Configuration options for the handler\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const { Hono } = require(\"hono\");\n *\n * const app = new Hono();\n *\n * Sentry.setupHonoErrorHandler(app);\n *\n * // Add your routes, etc.\n * ```\n */\nexport function setupHonoErrorHandler(\n app: { use: MiddlewareHandlerInterface },\n options?: Partial<HonoHandlerOptions>,\n): void {\n app.use(honoRequestHandler());\n app.use(honoErrorHandler(options));\n ensureIsWrapped(app.use, 'hono');\n}\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B,SAAS,qBAAqB,CAAC,IAAI,EAAc;AACjD,EAAE,MAAM,aAAa,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI;AAC1C,EAAE,MAAM,OAAO,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC;AACnD,EAAE,IAAI,UAAU,CAAC,4BAA4B,CAAA,IAAK,CAAC,IAAI,EAAE;AACzD,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,CAAC,aAAa,CAAC;AACrB,IAAI,CAAC,gCAAgC,GAAG,qBAAqB;AAC7D,IAAI,CAAC,4BAA4B,GAAG,CAAC,EAAA,IAAA,CAAA,KAAA,CAAA;AACA,GAAA,CAAA;;AAEA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA,SAAA,CAAA;AACA,EAAA,IAAA,OAAA,IAAA,KAAA,QAAA,EAAA;AACA,IAAA,IAAA,CAAA,UAAA,CAAA,IAAA,CAAA;AACA,EAAA;;AAEA,EAAA,IAAA,iBAAA,EAAA,KAAA,wBAAA,EAAA,EAAA;AACA,IAAA,WAAA,IAAA,KAAA,CAAA,IAAA,CAAA,+EAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,KAAA,GAAA,UA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AAA,qBAAA,CAAA,OAAA,EAAA,IAAA,EAAA;AACA,IAAA,MAAA,IAAA,EAAA;;AAEA,IAAA,MAAA,iBAAA,GAAA,OAAA,EAAA,iBAAA,IAAA,wBAAA;AACA,IAAA,IAAA,iBAAA,CAAA,OAAA,CAAA,EAAA;AACA,MAAA,CAAA,OAAA,CAAA,GAAA,GAAA,MAAA,GAAA,gBAAA,CAAA,OAAA,CAAA,KAAA,EAAA;AACA,QAAA,SAAA,EAAA;AACA,UAAA,IAAA,EAAA,sBAAA;AACA,UAAA,OAAA,EAAA,KAAA;AACA,SAAA;AACA,OAAA,CAAA;AACA,IAAA;AACA,EAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,qBAAA;AACA,EAAA,GAAA;AACA,EAAA,OAAA;AACA,EAAA;AACA,EAAA,GAAA,CAAA,GAAA,CAAA,kBAAA,EAAA,CAAA;AACA,EAAA,GAAA,CAAA,GAAA,CAAA,gBAAA,CAAA,OAAA,CAAA,CAAA;AACA,EAAA,eAAA,CAAA,GAAA,CAAA,GAAA,EAAA,MAAA,CAAA;AACA;;;;"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { context, trace, SpanStatusCode } from '@opentelemetry/api';
|
|
2
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { isThenable } from '@sentry/core';
|
|
4
|
+
import { AttributeNames, HonoTypes } from './constants.js';
|
|
5
|
+
|
|
6
|
+
const PACKAGE_NAME = '@sentry/instrumentation-hono';
|
|
7
|
+
const PACKAGE_VERSION = '0.0.1';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Hono instrumentation for OpenTelemetry
|
|
11
|
+
*/
|
|
12
|
+
class HonoInstrumentation extends InstrumentationBase {
|
|
13
|
+
constructor(config = {}) {
|
|
14
|
+
super(PACKAGE_NAME, PACKAGE_VERSION, config);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the instrumentation.
|
|
19
|
+
*/
|
|
20
|
+
init() {
|
|
21
|
+
return [
|
|
22
|
+
new InstrumentationNodeModuleDefinition('hono', ['>=4.0.0 <5'], moduleExports => this._patch(moduleExports)),
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Patches the module exports to instrument Hono.
|
|
28
|
+
*/
|
|
29
|
+
_patch(moduleExports) {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
31
|
+
const instrumentation = this;
|
|
32
|
+
|
|
33
|
+
class WrappedHono extends moduleExports.Hono {
|
|
34
|
+
constructor(...args) {
|
|
35
|
+
super(...args);
|
|
36
|
+
|
|
37
|
+
instrumentation._wrap(this, 'get', instrumentation._patchHandler());
|
|
38
|
+
instrumentation._wrap(this, 'post', instrumentation._patchHandler());
|
|
39
|
+
instrumentation._wrap(this, 'put', instrumentation._patchHandler());
|
|
40
|
+
instrumentation._wrap(this, 'delete', instrumentation._patchHandler());
|
|
41
|
+
instrumentation._wrap(this, 'options', instrumentation._patchHandler());
|
|
42
|
+
instrumentation._wrap(this, 'patch', instrumentation._patchHandler());
|
|
43
|
+
instrumentation._wrap(this, 'all', instrumentation._patchHandler());
|
|
44
|
+
instrumentation._wrap(this, 'on', instrumentation._patchOnHandler());
|
|
45
|
+
instrumentation._wrap(this, 'use', instrumentation._patchMiddlewareHandler());
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
moduleExports.Hono = WrappedHono;
|
|
51
|
+
} catch {
|
|
52
|
+
// This is a workaround for environments where direct assignment is not allowed.
|
|
53
|
+
return { ...moduleExports, Hono: WrappedHono };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return moduleExports;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Patches the route handler to instrument it.
|
|
61
|
+
*/
|
|
62
|
+
_patchHandler() {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
64
|
+
const instrumentation = this;
|
|
65
|
+
|
|
66
|
+
return function (original) {
|
|
67
|
+
return function wrappedHandler( ...args) {
|
|
68
|
+
if (typeof args[0] === 'string') {
|
|
69
|
+
const path = args[0];
|
|
70
|
+
if (args.length === 1) {
|
|
71
|
+
return original.apply(this, [path]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const handlers = args.slice(1);
|
|
75
|
+
return original.apply(this, [
|
|
76
|
+
path,
|
|
77
|
+
...handlers.map(handler => instrumentation._wrapHandler(handler )),
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return original.apply(
|
|
82
|
+
this,
|
|
83
|
+
args.map(handler => instrumentation._wrapHandler(handler )),
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Patches the 'on' handler to instrument it.
|
|
91
|
+
*/
|
|
92
|
+
_patchOnHandler() {
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
94
|
+
const instrumentation = this;
|
|
95
|
+
|
|
96
|
+
return function (original) {
|
|
97
|
+
return function wrappedHandler( ...args) {
|
|
98
|
+
const handlers = args.slice(2);
|
|
99
|
+
return original.apply(this, [
|
|
100
|
+
...args.slice(0, 2),
|
|
101
|
+
...handlers.map(handler => instrumentation._wrapHandler(handler )),
|
|
102
|
+
]);
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Patches the middleware handler to instrument it.
|
|
109
|
+
*/
|
|
110
|
+
_patchMiddlewareHandler() {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
112
|
+
const instrumentation = this;
|
|
113
|
+
|
|
114
|
+
return function (original) {
|
|
115
|
+
return function wrappedHandler( ...args) {
|
|
116
|
+
if (typeof args[0] === 'string') {
|
|
117
|
+
const path = args[0];
|
|
118
|
+
if (args.length === 1) {
|
|
119
|
+
return original.apply(this, [path]);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const handlers = args.slice(1);
|
|
123
|
+
return original.apply(this, [
|
|
124
|
+
path,
|
|
125
|
+
...handlers.map(handler => instrumentation._wrapHandler(handler )),
|
|
126
|
+
]);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return original.apply(
|
|
130
|
+
this,
|
|
131
|
+
args.map(handler => instrumentation._wrapHandler(handler )),
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Wraps a handler or middleware handler to apply instrumentation.
|
|
139
|
+
*/
|
|
140
|
+
_wrapHandler(handler) {
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
142
|
+
const instrumentation = this;
|
|
143
|
+
|
|
144
|
+
return function ( c, next) {
|
|
145
|
+
if (!instrumentation.isEnabled()) {
|
|
146
|
+
return handler.apply(this, [c, next]);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const path = c.req.path;
|
|
150
|
+
const span = instrumentation.tracer.startSpan(path);
|
|
151
|
+
|
|
152
|
+
return context.with(trace.setSpan(context.active(), span), () => {
|
|
153
|
+
return instrumentation._safeExecute(
|
|
154
|
+
() => {
|
|
155
|
+
const result = handler.apply(this, [c, next]);
|
|
156
|
+
if (isThenable(result)) {
|
|
157
|
+
return result.then(result => {
|
|
158
|
+
const type = instrumentation._determineHandlerType(result);
|
|
159
|
+
span.setAttributes({
|
|
160
|
+
[AttributeNames.HONO_TYPE]: type,
|
|
161
|
+
[AttributeNames.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path : handler.name || 'anonymous',
|
|
162
|
+
});
|
|
163
|
+
instrumentation.getConfig().responseHook?.(span);
|
|
164
|
+
return result;
|
|
165
|
+
});
|
|
166
|
+
} else {
|
|
167
|
+
const type = instrumentation._determineHandlerType(result);
|
|
168
|
+
span.setAttributes({
|
|
169
|
+
[AttributeNames.HONO_TYPE]: type,
|
|
170
|
+
[AttributeNames.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path : handler.name || 'anonymous',
|
|
171
|
+
});
|
|
172
|
+
instrumentation.getConfig().responseHook?.(span);
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
() => span.end(),
|
|
177
|
+
error => {
|
|
178
|
+
instrumentation._handleError(span, error);
|
|
179
|
+
span.end();
|
|
180
|
+
},
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Safely executes a function and handles errors.
|
|
188
|
+
*/
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
190
|
+
_safeExecute(execute, onSuccess, onFailure) {
|
|
191
|
+
try {
|
|
192
|
+
const result = execute();
|
|
193
|
+
|
|
194
|
+
if (isThenable(result)) {
|
|
195
|
+
result.then(
|
|
196
|
+
() => onSuccess(),
|
|
197
|
+
(error) => onFailure(error),
|
|
198
|
+
);
|
|
199
|
+
} else {
|
|
200
|
+
onSuccess();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return result;
|
|
204
|
+
} catch (error) {
|
|
205
|
+
onFailure(error);
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Determines the handler type based on the result.
|
|
212
|
+
* @param result
|
|
213
|
+
* @private
|
|
214
|
+
*/
|
|
215
|
+
_determineHandlerType(result) {
|
|
216
|
+
return result === undefined ? HonoTypes.MIDDLEWARE : HonoTypes.REQUEST_HANDLER;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Handles errors by setting the span status and recording the exception.
|
|
221
|
+
*/
|
|
222
|
+
_handleError(span, error) {
|
|
223
|
+
if (error instanceof Error) {
|
|
224
|
+
span.setStatus({
|
|
225
|
+
code: SpanStatusCode.ERROR,
|
|
226
|
+
message: error.message,
|
|
227
|
+
});
|
|
228
|
+
span.recordException(error);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export { HonoInstrumentation };
|
|
234
|
+
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/hono/instrumentation.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport { context, SpanStatusCode, trace } from '@opentelemetry/api';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport { isThenable } from '@sentry/core';\nimport { AttributeNames, HonoTypes } from './constants';\nimport type {\n Context,\n Handler,\n HandlerInterface,\n Hono,\n HonoInstance,\n MiddlewareHandler,\n MiddlewareHandlerInterface,\n Next,\n OnHandlerInterface,\n} from './types';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-hono';\nconst PACKAGE_VERSION = '0.0.1';\n\nexport interface HonoResponseHookFunction {\n (span: Span): void;\n}\n\nexport interface HonoInstrumentationConfig extends InstrumentationConfig {\n /** Function for adding custom span attributes from the response */\n responseHook?: HonoResponseHookFunction;\n}\n\n/**\n * Hono instrumentation for OpenTelemetry\n */\nexport class HonoInstrumentation extends InstrumentationBase<HonoInstrumentationConfig> {\n public constructor(config: HonoInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n /**\n * Initialize the instrumentation.\n */\n public init(): InstrumentationNodeModuleDefinition[] {\n return [\n new InstrumentationNodeModuleDefinition('hono', ['>=4.0.0 <5'], moduleExports => this._patch(moduleExports)),\n ];\n }\n\n /**\n * Patches the module exports to instrument Hono.\n */\n private _patch(moduleExports: { Hono: Hono }): { Hono: Hono } {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n class WrappedHono extends moduleExports.Hono {\n public constructor(...args: unknown[]) {\n super(...args);\n\n instrumentation._wrap(this, 'get', instrumentation._patchHandler());\n instrumentation._wrap(this, 'post', instrumentation._patchHandler());\n instrumentation._wrap(this, 'put', instrumentation._patchHandler());\n instrumentation._wrap(this, 'delete', instrumentation._patchHandler());\n instrumentation._wrap(this, 'options', instrumentation._patchHandler());\n instrumentation._wrap(this, 'patch', instrumentation._patchHandler());\n instrumentation._wrap(this, 'all', instrumentation._patchHandler());\n instrumentation._wrap(this, 'on', instrumentation._patchOnHandler());\n instrumentation._wrap(this, 'use', instrumentation._patchMiddlewareHandler());\n }\n }\n\n try {\n moduleExports.Hono = WrappedHono;\n } catch {\n // This is a workaround for environments where direct assignment is not allowed.\n return { ...moduleExports, Hono: WrappedHono };\n }\n\n return moduleExports;\n }\n\n /**\n * Patches the route handler to instrument it.\n */\n private _patchHandler(): (original: HandlerInterface) => HandlerInterface {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return function (original: HandlerInterface) {\n return function wrappedHandler(this: HonoInstance, ...args: unknown[]) {\n if (typeof args[0] === 'string') {\n const path = args[0];\n if (args.length === 1) {\n return original.apply(this, [path]);\n }\n\n const handlers = args.slice(1);\n return original.apply(this, [\n path,\n ...handlers.map(handler => instrumentation._wrapHandler(handler as Handler | MiddlewareHandler)),\n ]);\n }\n\n return original.apply(\n this,\n args.map(handler => instrumentation._wrapHandler(handler as Handler | MiddlewareHandler)),\n );\n };\n };\n }\n\n /**\n * Patches the 'on' handler to instrument it.\n */\n private _patchOnHandler(): (original: OnHandlerInterface) => OnHandlerInterface {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return function (original: OnHandlerInterface) {\n return function wrappedHandler(this: HonoInstance, ...args: unknown[]) {\n const handlers = args.slice(2);\n return original.apply(this, [\n ...args.slice(0, 2),\n ...handlers.map(handler => instrumentation._wrapHandler(handler as Handler | MiddlewareHandler)),\n ]);\n };\n };\n }\n\n /**\n * Patches the middleware handler to instrument it.\n */\n private _patchMiddlewareHandler(): (original: MiddlewareHandlerInterface) => MiddlewareHandlerInterface {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return function (original: MiddlewareHandlerInterface) {\n return function wrappedHandler(this: HonoInstance, ...args: unknown[]) {\n if (typeof args[0] === 'string') {\n const path = args[0];\n if (args.length === 1) {\n return original.apply(this, [path]);\n }\n\n const handlers = args.slice(1);\n return original.apply(this, [\n path,\n ...handlers.map(handler => instrumentation._wrapHandler(handler as MiddlewareHandler)),\n ]);\n }\n\n return original.apply(\n this,\n args.map(handler => instrumentation._wrapHandler(handler as MiddlewareHandler)),\n );\n };\n };\n }\n\n /**\n * Wraps a handler or middleware handler to apply instrumentation.\n */\n private _wrapHandler(handler: Handler | MiddlewareHandler): Handler | MiddlewareHandler {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return function (this: unknown, c: Context, next: Next) {\n if (!instrumentation.isEnabled()) {\n return handler.apply(this, [c, next]);\n }\n\n const path = c.req.path;\n const span = instrumentation.tracer.startSpan(path);\n\n return context.with(trace.setSpan(context.active(), span), () => {\n return instrumentation._safeExecute(\n () => {\n const result = handler.apply(this, [c, next]);\n if (isThenable(result)) {\n return result.then(result => {\n const type = instrumentation._determineHandlerType(result);\n span.setAttributes({\n [AttributeNames.HONO_TYPE]: type,\n [AttributeNames.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path : handler.name || 'anonymous',\n });\n instrumentation.getConfig().responseHook?.(span);\n return result;\n });\n } else {\n const type = instrumentation._determineHandlerType(result);\n span.setAttributes({\n [AttributeNames.HONO_TYPE]: type,\n [AttributeNames.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path : handler.name || 'anonymous',\n });\n instrumentation.getConfig().responseHook?.(span);\n return result;\n }\n },\n () => span.end(),\n error => {\n instrumentation._handleError(span, error);\n span.end();\n },\n );\n });\n };\n }\n\n /**\n * Safely executes a function and handles errors.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _safeExecute(execute: () => any, onSuccess: () => void, onFailure: (error: unknown) => void): () => any {\n try {\n const result = execute();\n\n if (isThenable(result)) {\n result.then(\n () => onSuccess(),\n (error: unknown) => onFailure(error),\n );\n } else {\n onSuccess();\n }\n\n return result;\n } catch (error: unknown) {\n onFailure(error);\n throw error;\n }\n }\n\n /**\n * Determines the handler type based on the result.\n * @param result\n * @private\n */\n private _determineHandlerType(result: unknown): HonoTypes {\n return result === undefined ? HonoTypes.MIDDLEWARE : HonoTypes.REQUEST_HANDLER;\n }\n\n /**\n * Handles errors by setting the span status and recording the exception.\n */\n private _handleError(span: Span, error: unknown): void {\n if (error instanceof Error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.recordException(error);\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAkBA,MAAM,YAAA,GAAe,8BAA8B;AACnD,MAAM,eAAA,GAAkB,OAAO;;AAW/B;AACA;AACA;AACO,MAAM,mBAAA,SAA4B,mBAAmB,CAA4B;AACxF,GAAS,WAAW,CAAC,MAAM,GAA8B,EAAE,EAAE;AAC7D,IAAI,KAAK,CAAC,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC;AAChD,EAAE;;AAEF;AACA;AACA;AACA,GAAS,IAAI,GAA0C;AACvD,IAAI,OAAO;AACX,MAAM,IAAI,mCAAmC,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,aAAA,IAAiB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AAClH,KAAK;AACL,EAAE;;AAEF;AACA;AACA;AACA,GAAU,MAAM,CAAC,aAAa,EAAkC;AAChE;AACA,IAAI,MAAM,eAAA,GAAkB,IAAI;;AAE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