@sentry/server-utils 10.63.0 → 10.65.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/graphql/graphql-dc-subscriber.js +125 -0
- package/build/cjs/graphql/graphql-dc-subscriber.js.map +1 -0
- package/build/cjs/graphql/index.js +23 -0
- package/build/cjs/graphql/index.js.map +1 -0
- package/build/cjs/graphql/utils.js +86 -0
- package/build/cjs/graphql/utils.js.map +1 -0
- package/build/cjs/index.js +12 -9
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/amqplib.js +420 -0
- package/build/cjs/integrations/tracing-channel/amqplib.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/anthropic.js +101 -0
- package/build/cjs/integrations/tracing-channel/anthropic.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/express/index.js +24 -0
- package/build/cjs/integrations/tracing-channel/express/index.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/express/instrumentation.js +173 -0
- package/build/cjs/integrations/tracing-channel/express/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/express/route.js +76 -0
- package/build/cjs/integrations/tracing-channel/express/route.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js +1 -1
- package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/google-genai.js +96 -0
- package/build/cjs/integrations/tracing-channel/google-genai.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/graphql/constants.js +26 -0
- package/build/cjs/integrations/tracing-channel/graphql/constants.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/graphql/index.js +66 -0
- package/build/cjs/integrations/tracing-channel/graphql/index.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/graphql/resolvers.js +168 -0
- package/build/cjs/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/graphql/spans.js +102 -0
- package/build/cjs/integrations/tracing-channel/graphql/spans.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/hapi-types.js +30 -0
- package/build/cjs/integrations/tracing-channel/hapi-types.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/hapi-utils.js +177 -0
- package/build/cjs/integrations/tracing-channel/hapi-utils.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/hapi.js +52 -0
- package/build/cjs/integrations/tracing-channel/hapi.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/ioredis.js +96 -0
- package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/mysql.js +2 -1
- package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/openai.js +83 -0
- package/build/cjs/integrations/tracing-channel/openai.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/postgres-js.js +191 -0
- package/build/cjs/integrations/tracing-channel/postgres-js.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/postgres.js +170 -0
- package/build/cjs/integrations/tracing-channel/postgres.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/redis.js +227 -0
- package/build/cjs/integrations/tracing-channel/redis.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/vercel-ai.js +25 -0
- package/build/cjs/integrations/tracing-channel/vercel-ai.js.map +1 -0
- package/build/cjs/mongoose/index.js +23 -0
- package/build/cjs/mongoose/index.js.map +1 -0
- package/build/cjs/mongoose/mongoose-dc-subscriber.js +97 -0
- package/build/cjs/mongoose/mongoose-dc-subscriber.js.map +1 -0
- package/build/cjs/mysql2/index.js +23 -0
- package/build/cjs/mysql2/index.js.map +1 -0
- package/build/cjs/mysql2/mysql2-dc-subscriber.js +68 -0
- package/build/cjs/mysql2/mysql2-dc-subscriber.js.map +1 -0
- package/build/cjs/orchestrion/bundler/vite.js +3 -3
- package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
- package/build/cjs/orchestrion/channels.js +29 -2
- package/build/cjs/orchestrion/channels.js.map +1 -1
- package/build/cjs/orchestrion/config/amqplib.js +81 -0
- package/build/cjs/orchestrion/config/amqplib.js.map +1 -0
- package/build/cjs/orchestrion/config/anthropic-ai.js +43 -0
- package/build/cjs/orchestrion/config/anthropic-ai.js.map +1 -0
- package/build/cjs/orchestrion/config/express.js +76 -0
- package/build/cjs/orchestrion/config/express.js.map +1 -0
- package/build/cjs/orchestrion/config/google-genai.js +38 -0
- package/build/cjs/orchestrion/config/google-genai.js.map +1 -0
- package/build/cjs/orchestrion/config/graphql.js +28 -0
- package/build/cjs/orchestrion/config/graphql.js.map +1 -0
- package/build/cjs/orchestrion/config/hapi.js +26 -0
- package/build/cjs/orchestrion/config/hapi.js.map +1 -0
- package/build/cjs/orchestrion/config/index.js +48 -0
- package/build/cjs/orchestrion/config/index.js.map +1 -0
- package/build/cjs/orchestrion/config/ioredis.js +35 -0
- package/build/cjs/orchestrion/config/ioredis.js.map +1 -0
- package/build/cjs/orchestrion/config/lru-memoizer.js +17 -0
- package/build/cjs/orchestrion/config/lru-memoizer.js.map +1 -0
- package/build/cjs/orchestrion/config/mysql.js +16 -0
- package/build/cjs/orchestrion/config/mysql.js.map +1 -0
- package/build/cjs/orchestrion/config/openai.js +40 -0
- package/build/cjs/orchestrion/config/openai.js.map +1 -0
- package/build/cjs/orchestrion/config/pg.js +51 -0
- package/build/cjs/orchestrion/config/pg.js.map +1 -0
- package/build/cjs/orchestrion/config/postgres.js +50 -0
- package/build/cjs/orchestrion/config/postgres.js.map +1 -0
- package/build/cjs/orchestrion/config/redis.js +76 -0
- package/build/cjs/orchestrion/config/redis.js.map +1 -0
- package/build/cjs/orchestrion/config/vercel-ai.js +48 -0
- package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -0
- package/build/cjs/orchestrion/detect.js +6 -1
- package/build/cjs/orchestrion/detect.js.map +1 -1
- package/build/cjs/orchestrion/index.js +44 -5
- package/build/cjs/orchestrion/index.js.map +1 -1
- package/build/cjs/orchestrion/runtime/register.js +10 -7
- package/build/cjs/orchestrion/runtime/register.js.map +1 -1
- package/build/cjs/redis/index.js +23 -0
- package/build/cjs/redis/index.js.map +1 -0
- package/build/cjs/redis/redis-dc-subscriber.js +23 -35
- package/build/cjs/redis/redis-dc-subscriber.js.map +1 -1
- package/build/cjs/redis/redis-statement-serializer.js +34 -0
- package/build/cjs/redis/redis-statement-serializer.js.map +1 -0
- package/build/cjs/tracing-channel.js +8 -7
- package/build/cjs/tracing-channel.js.map +1 -1
- package/build/cjs/vercel-ai/util.js +123 -0
- package/build/cjs/vercel-ai/util.js.map +1 -0
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +147 -76
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js +386 -0
- package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
- package/build/esm/graphql/graphql-dc-subscriber.js +118 -0
- package/build/esm/graphql/graphql-dc-subscriber.js.map +1 -0
- package/build/esm/graphql/index.js +21 -0
- package/build/esm/graphql/index.js.map +1 -0
- package/build/esm/graphql/utils.js +81 -0
- package/build/esm/graphql/utils.js.map +1 -0
- package/build/esm/index.js +5 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/tracing-channel/amqplib.js +418 -0
- package/build/esm/integrations/tracing-channel/amqplib.js.map +1 -0
- package/build/esm/integrations/tracing-channel/anthropic.js +99 -0
- package/build/esm/integrations/tracing-channel/anthropic.js.map +1 -0
- package/build/esm/integrations/tracing-channel/express/index.js +22 -0
- package/build/esm/integrations/tracing-channel/express/index.js.map +1 -0
- package/build/esm/integrations/tracing-channel/express/instrumentation.js +171 -0
- package/build/esm/integrations/tracing-channel/express/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing-channel/express/route.js +68 -0
- package/build/esm/integrations/tracing-channel/express/route.js.map +1 -0
- package/build/esm/integrations/tracing-channel/fastify/instrumentation.js +2 -2
- package/build/esm/integrations/tracing-channel/fastify/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing-channel/google-genai.js +94 -0
- package/build/esm/integrations/tracing-channel/google-genai.js.map +1 -0
- package/build/esm/integrations/tracing-channel/graphql/constants.js +14 -0
- package/build/esm/integrations/tracing-channel/graphql/constants.js.map +1 -0
- package/build/esm/integrations/tracing-channel/graphql/index.js +63 -0
- package/build/esm/integrations/tracing-channel/graphql/index.js.map +1 -0
- package/build/esm/integrations/tracing-channel/graphql/resolvers.js +164 -0
- package/build/esm/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
- package/build/esm/integrations/tracing-channel/graphql/spans.js +96 -0
- package/build/esm/integrations/tracing-channel/graphql/spans.js.map +1 -0
- package/build/esm/integrations/tracing-channel/hapi-types.js +25 -0
- package/build/esm/integrations/tracing-channel/hapi-types.js.map +1 -0
- package/build/esm/integrations/tracing-channel/hapi-utils.js +172 -0
- package/build/esm/integrations/tracing-channel/hapi-utils.js.map +1 -0
- package/build/esm/integrations/tracing-channel/hapi.js +50 -0
- package/build/esm/integrations/tracing-channel/hapi.js.map +1 -0
- package/build/esm/integrations/tracing-channel/ioredis.js +94 -0
- package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -0
- package/build/esm/integrations/tracing-channel/mysql.js +3 -2
- package/build/esm/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/esm/integrations/tracing-channel/openai.js +81 -0
- package/build/esm/integrations/tracing-channel/openai.js.map +1 -0
- package/build/esm/integrations/tracing-channel/postgres-js.js +189 -0
- package/build/esm/integrations/tracing-channel/postgres-js.js.map +1 -0
- package/build/esm/integrations/tracing-channel/postgres.js +168 -0
- package/build/esm/integrations/tracing-channel/postgres.js.map +1 -0
- package/build/esm/integrations/tracing-channel/redis.js +225 -0
- package/build/esm/integrations/tracing-channel/redis.js.map +1 -0
- package/build/esm/integrations/tracing-channel/vercel-ai.js +23 -0
- package/build/esm/integrations/tracing-channel/vercel-ai.js.map +1 -0
- package/build/esm/mongoose/index.js +21 -0
- package/build/esm/mongoose/index.js.map +1 -0
- package/build/esm/mongoose/mongoose-dc-subscriber.js +89 -0
- package/build/esm/mongoose/mongoose-dc-subscriber.js.map +1 -0
- package/build/esm/mysql2/index.js +21 -0
- package/build/esm/mysql2/index.js.map +1 -0
- package/build/esm/mysql2/mysql2-dc-subscriber.js +62 -0
- package/build/esm/mysql2/mysql2-dc-subscriber.js.map +1 -0
- package/build/esm/orchestrion/bundler/vite.js +1 -1
- package/build/esm/orchestrion/channels.js +29 -2
- package/build/esm/orchestrion/channels.js.map +1 -1
- package/build/esm/orchestrion/config/amqplib.js +78 -0
- package/build/esm/orchestrion/config/amqplib.js.map +1 -0
- package/build/esm/orchestrion/config/anthropic-ai.js +40 -0
- package/build/esm/orchestrion/config/anthropic-ai.js.map +1 -0
- package/build/esm/orchestrion/config/express.js +73 -0
- package/build/esm/orchestrion/config/express.js.map +1 -0
- package/build/esm/orchestrion/config/google-genai.js +35 -0
- package/build/esm/orchestrion/config/google-genai.js.map +1 -0
- package/build/esm/orchestrion/config/graphql.js +25 -0
- package/build/esm/orchestrion/config/graphql.js.map +1 -0
- package/build/esm/orchestrion/config/hapi.js +23 -0
- package/build/esm/orchestrion/config/hapi.js.map +1 -0
- package/build/esm/orchestrion/config/index.js +44 -0
- package/build/esm/orchestrion/config/index.js.map +1 -0
- package/build/esm/orchestrion/config/ioredis.js +32 -0
- package/build/esm/orchestrion/config/ioredis.js.map +1 -0
- package/build/esm/orchestrion/config/lru-memoizer.js +14 -0
- package/build/esm/orchestrion/config/lru-memoizer.js.map +1 -0
- package/build/esm/orchestrion/config/mysql.js +13 -0
- package/build/esm/orchestrion/config/mysql.js.map +1 -0
- package/build/esm/orchestrion/config/openai.js +37 -0
- package/build/esm/orchestrion/config/openai.js.map +1 -0
- package/build/esm/orchestrion/config/pg.js +48 -0
- package/build/esm/orchestrion/config/pg.js.map +1 -0
- package/build/esm/orchestrion/config/postgres.js +47 -0
- package/build/esm/orchestrion/config/postgres.js.map +1 -0
- package/build/esm/orchestrion/config/redis.js +73 -0
- package/build/esm/orchestrion/config/redis.js.map +1 -0
- package/build/esm/orchestrion/config/vercel-ai.js +45 -0
- package/build/esm/orchestrion/config/vercel-ai.js.map +1 -0
- package/build/esm/orchestrion/detect.js +6 -2
- package/build/esm/orchestrion/detect.js.map +1 -1
- package/build/esm/orchestrion/index.js +33 -3
- package/build/esm/orchestrion/index.js.map +1 -1
- package/build/esm/orchestrion/runtime/register.js +8 -4
- package/build/esm/orchestrion/runtime/register.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/redis/index.js +21 -0
- package/build/esm/redis/index.js.map +1 -0
- package/build/esm/redis/redis-dc-subscriber.js +24 -36
- package/build/esm/redis/redis-dc-subscriber.js.map +1 -1
- package/build/esm/redis/redis-statement-serializer.js +32 -0
- package/build/esm/redis/redis-statement-serializer.js.map +1 -0
- package/build/esm/tracing-channel.js +9 -8
- package/build/esm/tracing-channel.js.map +1 -1
- package/build/esm/vercel-ai/util.js +116 -0
- package/build/esm/vercel-ai/util.js.map +1 -0
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +122 -54
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js +384 -0
- package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
- package/build/types/graphql/graphql-dc-subscriber.d.ts +94 -0
- package/build/types/graphql/graphql-dc-subscriber.d.ts.map +1 -0
- package/build/types/graphql/index.d.ts +12 -0
- package/build/types/graphql/index.d.ts.map +1 -0
- package/build/types/graphql/utils.d.ts +40 -0
- package/build/types/graphql/utils.d.ts.map +1 -0
- package/build/types/index.d.ts +6 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/amqplib.d.ts +11 -0
- package/build/types/integrations/tracing-channel/amqplib.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/anthropic.d.ts +10 -0
- package/build/types/integrations/tracing-channel/anthropic.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/express/index.d.ts +18 -0
- package/build/types/integrations/tracing-channel/express/index.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
- package/build/types/integrations/tracing-channel/express/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/express/route.d.ts +28 -0
- package/build/types/integrations/tracing-channel/express/route.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/express/types.d.ts +64 -0
- package/build/types/integrations/tracing-channel/express/types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/fastify/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/google-genai.d.ts +12 -0
- package/build/types/integrations/tracing-channel/google-genai.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/constants.d.ts +12 -0
- package/build/types/integrations/tracing-channel/graphql/constants.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
- package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/index.d.ts +28 -0
- package/build/types/integrations/tracing-channel/graphql/index.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
- package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/spans.d.ts +17 -0
- package/build/types/integrations/tracing-channel/graphql/spans.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/types.d.ts +25 -0
- package/build/types/integrations/tracing-channel/graphql/types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/hapi-types.d.ts +53 -0
- package/build/types/integrations/tracing-channel/hapi-types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/hapi-utils.d.ts +25 -0
- package/build/types/integrations/tracing-channel/hapi-utils.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/hapi.d.ts +9 -0
- package/build/types/integrations/tracing-channel/hapi.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/ioredis.d.ts +17 -0
- package/build/types/integrations/tracing-channel/ioredis.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/mysql.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/openai.d.ts +10 -0
- package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/postgres-js.d.ts +26 -0
- package/build/types/integrations/tracing-channel/postgres-js.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/postgres.d.ts +15 -0
- package/build/types/integrations/tracing-channel/postgres.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/redis.d.ts +16 -0
- package/build/types/integrations/tracing-channel/redis.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/vercel-ai.d.ts +13 -0
- package/build/types/integrations/tracing-channel/vercel-ai.d.ts.map +1 -0
- package/build/types/mongoose/index.d.ts +11 -0
- package/build/types/mongoose/index.d.ts.map +1 -0
- package/build/types/mongoose/mongoose-dc-subscriber.d.ts +63 -0
- package/build/types/mongoose/mongoose-dc-subscriber.d.ts.map +1 -0
- package/build/types/mysql2/index.d.ts +11 -0
- package/build/types/mysql2/index.d.ts.map +1 -0
- package/build/types/mysql2/mysql2-dc-subscriber.d.ts +59 -0
- package/build/types/mysql2/mysql2-dc-subscriber.d.ts.map +1 -0
- package/build/types/orchestrion/channels.d.ts +55 -1
- package/build/types/orchestrion/channels.d.ts.map +1 -1
- package/build/types/orchestrion/config/amqplib.d.ts +66 -0
- package/build/types/orchestrion/config/amqplib.d.ts.map +1 -0
- package/build/types/orchestrion/config/anthropic-ai.d.ts +31 -0
- package/build/types/orchestrion/config/anthropic-ai.d.ts.map +1 -0
- package/build/types/orchestrion/config/express.d.ts +32 -0
- package/build/types/orchestrion/config/express.d.ts.map +1 -0
- package/build/types/orchestrion/config/google-genai.d.ts +30 -0
- package/build/types/orchestrion/config/google-genai.d.ts.map +1 -0
- package/build/types/orchestrion/config/graphql.d.ts +29 -0
- package/build/types/orchestrion/config/graphql.d.ts.map +1 -0
- package/build/types/orchestrion/config/hapi.d.ts +17 -0
- package/build/types/orchestrion/config/hapi.d.ts.map +1 -0
- package/build/types/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
- package/build/types/orchestrion/config/index.d.ts.map +1 -0
- package/build/types/orchestrion/config/ioredis.d.ts +7 -0
- package/build/types/orchestrion/config/ioredis.d.ts.map +1 -0
- package/build/types/orchestrion/config/lru-memoizer.d.ts +16 -0
- package/build/types/orchestrion/config/lru-memoizer.d.ts.map +1 -0
- package/build/types/orchestrion/config/mysql.d.ts +16 -0
- package/build/types/orchestrion/config/mysql.d.ts.map +1 -0
- package/build/types/orchestrion/config/openai.d.ts +20 -0
- package/build/types/orchestrion/config/openai.d.ts.map +1 -0
- package/build/types/orchestrion/config/pg.d.ts +33 -0
- package/build/types/orchestrion/config/pg.d.ts.map +1 -0
- package/build/types/orchestrion/config/postgres.d.ts +9 -0
- package/build/types/orchestrion/config/postgres.d.ts.map +1 -0
- package/build/types/orchestrion/config/redis.d.ts +37 -0
- package/build/types/orchestrion/config/redis.d.ts.map +1 -0
- package/build/types/orchestrion/config/vercel-ai.d.ts +12 -0
- package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -0
- package/build/types/orchestrion/detect.d.ts +10 -0
- package/build/types/orchestrion/detect.d.ts.map +1 -1
- package/build/types/orchestrion/index.d.ts +80 -3
- package/build/types/orchestrion/index.d.ts.map +1 -1
- package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
- package/build/types/redis/index.d.ts +18 -0
- package/build/types/redis/index.d.ts.map +1 -0
- package/build/types/redis/redis-dc-subscriber.d.ts +0 -5
- package/build/types/redis/redis-dc-subscriber.d.ts.map +1 -1
- package/build/types/redis/redis-statement-serializer.d.ts +6 -0
- package/build/types/redis/redis-statement-serializer.d.ts.map +1 -0
- package/build/types/tracing-channel.d.ts +5 -0
- package/build/types/tracing-channel.d.ts.map +1 -1
- package/build/types/vercel-ai/util.d.ts +32 -0
- package/build/types/vercel-ai/util.d.ts.map +1 -0
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts +15 -5
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
- package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts +12 -0
- package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts.map +1 -0
- package/build/types-ts3.8/graphql/graphql-dc-subscriber.d.ts +94 -0
- package/build/types-ts3.8/graphql/index.d.ts +12 -0
- package/build/types-ts3.8/graphql/utils.d.ts +40 -0
- package/build/types-ts3.8/index.d.ts +6 -2
- package/build/types-ts3.8/integrations/tracing-channel/amqplib.d.ts +11 -0
- package/build/types-ts3.8/integrations/tracing-channel/anthropic.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/express/index.d.ts +18 -0
- package/build/types-ts3.8/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
- package/build/types-ts3.8/integrations/tracing-channel/express/route.d.ts +28 -0
- package/build/types-ts3.8/integrations/tracing-channel/express/types.d.ts +64 -0
- package/build/types-ts3.8/integrations/tracing-channel/google-genai.d.ts +12 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/constants.d.ts +12 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/index.d.ts +30 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/spans.d.ts +17 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/types.d.ts +25 -0
- package/build/types-ts3.8/integrations/tracing-channel/hapi-types.d.ts +65 -0
- package/build/types-ts3.8/integrations/tracing-channel/hapi-utils.d.ts +25 -0
- package/build/types-ts3.8/integrations/tracing-channel/hapi.d.ts +9 -0
- package/build/types-ts3.8/integrations/tracing-channel/ioredis.d.ts +17 -0
- package/build/types-ts3.8/integrations/tracing-channel/openai.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/postgres-js.d.ts +26 -0
- package/build/types-ts3.8/integrations/tracing-channel/postgres.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing-channel/redis.d.ts +16 -0
- package/build/types-ts3.8/integrations/tracing-channel/vercel-ai.d.ts +13 -0
- package/build/types-ts3.8/mongoose/index.d.ts +11 -0
- package/build/types-ts3.8/mongoose/mongoose-dc-subscriber.d.ts +63 -0
- package/build/types-ts3.8/mysql2/index.d.ts +11 -0
- package/build/types-ts3.8/mysql2/mysql2-dc-subscriber.d.ts +59 -0
- package/build/types-ts3.8/orchestrion/channels.d.ts +55 -1
- package/build/types-ts3.8/orchestrion/config/amqplib.d.ts +66 -0
- package/build/types-ts3.8/orchestrion/config/anthropic-ai.d.ts +31 -0
- package/build/types-ts3.8/orchestrion/config/express.d.ts +32 -0
- package/build/types-ts3.8/orchestrion/config/google-genai.d.ts +30 -0
- package/build/types-ts3.8/orchestrion/config/graphql.d.ts +29 -0
- package/build/types-ts3.8/orchestrion/config/hapi.d.ts +17 -0
- package/build/types-ts3.8/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
- package/build/types-ts3.8/orchestrion/config/ioredis.d.ts +7 -0
- package/build/types-ts3.8/orchestrion/config/lru-memoizer.d.ts +16 -0
- package/build/types-ts3.8/orchestrion/config/mysql.d.ts +16 -0
- package/build/types-ts3.8/orchestrion/config/openai.d.ts +20 -0
- package/build/types-ts3.8/orchestrion/config/pg.d.ts +33 -0
- package/build/types-ts3.8/orchestrion/config/postgres.d.ts +9 -0
- package/build/types-ts3.8/orchestrion/config/redis.d.ts +37 -0
- package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +12 -0
- package/build/types-ts3.8/orchestrion/detect.d.ts +10 -0
- package/build/types-ts3.8/orchestrion/index.d.ts +82 -3
- package/build/types-ts3.8/redis/index.d.ts +18 -0
- package/build/types-ts3.8/redis/redis-dc-subscriber.d.ts +0 -5
- package/build/types-ts3.8/redis/redis-statement-serializer.d.ts +6 -0
- package/build/types-ts3.8/tracing-channel.d.ts +5 -0
- package/build/types-ts3.8/vercel-ai/util.d.ts +32 -0
- package/build/types-ts3.8/vercel-ai/vercel-ai-dc-subscriber.d.ts +15 -5
- package/build/types-ts3.8/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts +12 -0
- package/package.json +9 -9
- package/build/cjs/orchestrion/config.js +0 -44
- package/build/cjs/orchestrion/config.js.map +0 -1
- package/build/esm/orchestrion/config.js +0 -40
- package/build/esm/orchestrion/config.js.map +0 -1
- package/build/types/orchestrion/config.d.ts.map +0 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
2
|
+
import { defineIntegration, waitForTracingChannelBinding, debug, bindScopeToEmitter, getCurrentScope, startInactiveSpan, SPAN_KIND, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, isObjectLike } from '@sentry/core';
|
|
3
|
+
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
4
|
+
import { CHANNELS } from '../../orchestrion/channels.js';
|
|
5
|
+
import { bindTracingChannelToSpan } from '../../tracing-channel.js';
|
|
6
|
+
|
|
7
|
+
const INTEGRATION_NAME = "Postgres";
|
|
8
|
+
const ORIGIN = "auto.db.orchestrion.postgres";
|
|
9
|
+
const ATTR_DB_SYSTEM = "db.system";
|
|
10
|
+
const ATTR_DB_NAME = "db.name";
|
|
11
|
+
const ATTR_DB_CONNECTION_STRING = "db.connection_string";
|
|
12
|
+
const ATTR_DB_USER = "db.user";
|
|
13
|
+
const ATTR_DB_STATEMENT = "db.statement";
|
|
14
|
+
const ATTR_NET_PEER_NAME = "net.peer.name";
|
|
15
|
+
const ATTR_NET_PEER_PORT = "net.peer.port";
|
|
16
|
+
const ATTR_PG_PLAN = "db.postgresql.plan";
|
|
17
|
+
const ATTR_PG_IDLE_TIMEOUT = "db.postgresql.idle.timeout.millis";
|
|
18
|
+
const ATTR_PG_MAX_CLIENT = "db.postgresql.max.client";
|
|
19
|
+
const DB_SYSTEM_POSTGRESQL = "postgresql";
|
|
20
|
+
const SPAN_QUERY_FALLBACK = "pg.query";
|
|
21
|
+
const SPAN_CONNECT = "pg.connect";
|
|
22
|
+
const SPAN_POOL_CONNECT = "pg-pool.connect";
|
|
23
|
+
const _postgresChannelIntegration = ((options = {}) => {
|
|
24
|
+
return {
|
|
25
|
+
name: INTEGRATION_NAME,
|
|
26
|
+
setupOnce() {
|
|
27
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
waitForTracingChannelBinding(() => {
|
|
31
|
+
subscribeQueryLikeChannel(CHANNELS.PG_QUERY, querySpanOptions, { deferStreamedResult: true });
|
|
32
|
+
if (!options.ignoreConnectSpans) {
|
|
33
|
+
subscribeQueryLikeChannel(CHANNELS.PG_CONNECT, connectSpanOptions);
|
|
34
|
+
subscribeQueryLikeChannel(CHANNELS.PGPOOL_CONNECT, poolConnectSpanOptions);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
function subscribeQueryLikeChannel(channelName, getSpanOptions, { deferStreamedResult = false } = {}) {
|
|
41
|
+
DEBUG_BUILD && debug.log(`[orchestrion:pg] subscribing to channel "${channelName}"`);
|
|
42
|
+
bindTracingChannelToSpan(
|
|
43
|
+
diagnosticsChannel.tracingChannel(channelName),
|
|
44
|
+
(data) => {
|
|
45
|
+
data._sentryCallerScope = getCurrentScope();
|
|
46
|
+
return startInactiveSpan({ ...getSpanOptions(data), kind: SPAN_KIND.CLIENT });
|
|
47
|
+
},
|
|
48
|
+
// `connect`/`pool-connect` resolve with a persistent `Client` (itself an
|
|
49
|
+
// `EventEmitter`), which is NOT a streamed result. Deferring their span
|
|
50
|
+
// to that emitter's `'end'`/`'error'` would keep it open for the whole
|
|
51
|
+
// connection lifetime, so it never ends in time and is dropped. Only
|
|
52
|
+
// `query` can return a streamable `Submittable`, so only it defers.
|
|
53
|
+
deferStreamedResult ? {
|
|
54
|
+
// Only instrument under an active span, leaving the context untouched otherwise
|
|
55
|
+
// (e.g. connects issued during app startup).
|
|
56
|
+
requiresParentSpan: true,
|
|
57
|
+
// Streamable `Submittable` (e.g. `client.query(new Query())`)
|
|
58
|
+
// returns an emitter that orchestrion stores on `ctx.result` while
|
|
59
|
+
// firing no async events; the query isn't done until the emitter
|
|
60
|
+
// emits `'end'`/`'error'`. Defer ending to those events for that
|
|
61
|
+
// path; the callback, promise, and sync-throw paths carry no
|
|
62
|
+
// emitter, so the helper ends the span as usual.
|
|
63
|
+
deferSpanEnd({ data, end }) {
|
|
64
|
+
const result = data.result;
|
|
65
|
+
if (!result || typeof result !== "object" || !hasOnMethod(result)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const callerScope = data._sentryCallerScope;
|
|
69
|
+
if (callerScope) {
|
|
70
|
+
bindScopeToEmitter(result, callerScope);
|
|
71
|
+
}
|
|
72
|
+
result.on("error", (err) => end(err));
|
|
73
|
+
result.on("end", () => end());
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
} : { requiresParentSpan: true }
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
function querySpanOptions(ctx) {
|
|
80
|
+
const params = ctx.self?.connectionParameters ?? {};
|
|
81
|
+
const queryConfig = extractQueryConfig(ctx.arguments);
|
|
82
|
+
return {
|
|
83
|
+
// The description is the SQL statement
|
|
84
|
+
name: queryConfig?.text ?? SPAN_QUERY_FALLBACK,
|
|
85
|
+
op: "db",
|
|
86
|
+
attributes: {
|
|
87
|
+
...getConnectionAttributes(params),
|
|
88
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
89
|
+
[ATTR_DB_STATEMENT]: queryConfig?.text || void 0,
|
|
90
|
+
[ATTR_PG_PLAN]: typeof queryConfig?.name === "string" ? queryConfig.name : void 0
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function connectSpanOptions(ctx) {
|
|
95
|
+
const params = ctx.self?.connectionParameters ?? {};
|
|
96
|
+
return { name: SPAN_CONNECT, op: "db", attributes: getConnectionAttributes(params) };
|
|
97
|
+
}
|
|
98
|
+
function poolConnectSpanOptions(ctx) {
|
|
99
|
+
const opts = ctx.self?.options ?? {};
|
|
100
|
+
return { name: SPAN_POOL_CONNECT, op: "db", attributes: getPoolConnectionAttributes(opts) };
|
|
101
|
+
}
|
|
102
|
+
function hasOnMethod(obj) {
|
|
103
|
+
return "on" in obj && typeof obj.on === "function";
|
|
104
|
+
}
|
|
105
|
+
function extractQueryConfig(args) {
|
|
106
|
+
const arg0 = args[0];
|
|
107
|
+
if (typeof arg0 === "string") {
|
|
108
|
+
return { text: arg0 };
|
|
109
|
+
}
|
|
110
|
+
if (isObjectLike(arg0) && typeof arg0.text === "string") {
|
|
111
|
+
const obj = arg0;
|
|
112
|
+
return { text: obj.text, name: obj.name };
|
|
113
|
+
}
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
function getConnectionAttributes(params) {
|
|
117
|
+
return {
|
|
118
|
+
[ATTR_DB_SYSTEM]: DB_SYSTEM_POSTGRESQL,
|
|
119
|
+
[ATTR_DB_CONNECTION_STRING]: getConnectionString(params),
|
|
120
|
+
[ATTR_DB_NAME]: params.database,
|
|
121
|
+
[ATTR_DB_USER]: params.user,
|
|
122
|
+
[ATTR_NET_PEER_NAME]: params.host,
|
|
123
|
+
[ATTR_NET_PEER_PORT]: Number.isInteger(params.port) ? params.port : void 0
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function getPoolConnectionAttributes(opts) {
|
|
127
|
+
let url;
|
|
128
|
+
try {
|
|
129
|
+
url = opts.connectionString ? new URL(opts.connectionString) : void 0;
|
|
130
|
+
} catch {
|
|
131
|
+
url = void 0;
|
|
132
|
+
}
|
|
133
|
+
const database = url?.pathname.slice(1) || opts.database;
|
|
134
|
+
const host = url?.hostname || opts.host;
|
|
135
|
+
const port = Number(url?.port) || (Number.isInteger(opts.port) ? opts.port : void 0);
|
|
136
|
+
const user = url?.username || opts.user;
|
|
137
|
+
return {
|
|
138
|
+
[ATTR_DB_SYSTEM]: DB_SYSTEM_POSTGRESQL,
|
|
139
|
+
[ATTR_DB_CONNECTION_STRING]: getConnectionString(opts),
|
|
140
|
+
[ATTR_PG_IDLE_TIMEOUT]: opts.idleTimeoutMillis,
|
|
141
|
+
[ATTR_PG_MAX_CLIENT]: opts.max,
|
|
142
|
+
[ATTR_DB_NAME]: database,
|
|
143
|
+
[ATTR_NET_PEER_PORT]: port,
|
|
144
|
+
// these two come from a url parse and slice, can be ''
|
|
145
|
+
[ATTR_NET_PEER_NAME]: host || void 0,
|
|
146
|
+
[ATTR_DB_USER]: user || void 0
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function getConnectionString(params) {
|
|
150
|
+
if (params.connectionString) {
|
|
151
|
+
try {
|
|
152
|
+
const url = new URL(params.connectionString);
|
|
153
|
+
url.username = "";
|
|
154
|
+
url.password = "";
|
|
155
|
+
return url.toString();
|
|
156
|
+
} catch {
|
|
157
|
+
return "postgresql://localhost:5432/";
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const host = params.host || "localhost";
|
|
161
|
+
const port = params.port || 5432;
|
|
162
|
+
const database = params.database || "";
|
|
163
|
+
return `postgresql://${host}:${port}/${database}`;
|
|
164
|
+
}
|
|
165
|
+
const postgresChannelIntegration = defineIntegration(_postgresChannelIntegration);
|
|
166
|
+
|
|
167
|
+
export { postgresChannelIntegration };
|
|
168
|
+
//# sourceMappingURL=postgres.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.js","sources":["../../../../src/integrations/tracing-channel/postgres.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn, Scope, SpanAttributes } from '@sentry/core';\nimport {\n isObjectLike,\n bindScopeToEmitter,\n debug,\n defineIntegration,\n getCurrentScope,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// NOTE: this uses the same name as the OTel integration by design.\n// When enabled, the OTel 'Postgres' integration is omitted from the default set.\nconst INTEGRATION_NAME = 'Postgres' as const;\n\n// Only the query span carries an origin (the connect/pool-connect spans don't,\n// so they default to 'manual').\nconst ORIGIN = 'auto.db.orchestrion.postgres';\n\n// OpenTelemetry \"OLD\" db/net semantic-conventions, inlined to keep this\n// integration free of `@opentelemetry/*` deps.\nconst ATTR_DB_SYSTEM = 'db.system';\nconst ATTR_DB_NAME = 'db.name';\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\nconst ATTR_DB_USER = 'db.user';\nconst ATTR_DB_STATEMENT = 'db.statement';\nconst ATTR_NET_PEER_NAME = 'net.peer.name';\nconst ATTR_NET_PEER_PORT = 'net.peer.port';\nconst ATTR_PG_PLAN = 'db.postgresql.plan';\nconst ATTR_PG_IDLE_TIMEOUT = 'db.postgresql.idle.timeout.millis';\nconst ATTR_PG_MAX_CLIENT = 'db.postgresql.max.client';\nconst DB_SYSTEM_POSTGRESQL = 'postgresql';\n\n// We set `op: 'db'` and the SQL description directly here (same as mysql\n// orchestrion) rather than relying on the OTel pipeline's `inferDbSpanData`\n// processor, which only runs in the node SDK, so setting them here is what\n// makes the spans correct on the other runtimes\n//\n// The user-visible span is identical to OTel: query spans are named after\n// `db.statement`; connect/pool-connect spans keep these names.\nconst SPAN_QUERY_FALLBACK = 'pg.query';\nconst SPAN_CONNECT = 'pg.connect';\nconst SPAN_POOL_CONNECT = 'pg-pool.connect';\n\n/**\n * The shape orchestrion's transform attaches to the tracing-channel `context`. Documented here rather\n * than imported because orchestrion's runtime doesn't export it.\n */\ninterface PgChannelContext {\n // The live args array passed to the wrapped `query`/`connect` call.\n arguments: unknown[];\n self?: unknown;\n result?: unknown;\n error?: unknown;\n // The caller's scope, captured at `start` and replayed onto a streamed `Submittable` emitter (see below).\n _sentryCallerScope?: Scope;\n}\n\ninterface PgConnectionParams {\n database?: string;\n host?: string;\n port?: number;\n user?: string;\n connectionString?: string;\n}\n\ninterface PgPoolOptions extends PgConnectionParams {\n idleTimeoutMillis?: number;\n // pg-pool stores the max pool size as `max` (defaulting it to 10 in its\n // constructor). The OTel pg instrumentation reads a `maxClient` field that\n // pg-pool never sets, so its `db.postgresql.max.client` attribute is always\n // dropped; we read the real `max` so the attribute is actually populated.\n max?: number;\n}\n\nconst _postgresChannelIntegration = ((options: { ignoreConnectSpans?: boolean } = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19 so do nothing in that case.\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n // Query spans: `pg`/native `Client.prototype.query`. Only this channel can return a streamable\n // `Submittable` result, so it's the only one that defers span-ending to the emitter (see below).\n subscribeQueryLikeChannel(CHANNELS.PG_QUERY, querySpanOptions, { deferStreamedResult: true });\n\n // Connect spans, gated by `ignoreConnectSpans` (same as OTel pg).\n // `Client.prototype.connect` (pg + native)\n // and `Pool.prototype.connect` (pg-pool).\n if (!options.ignoreConnectSpans) {\n subscribeQueryLikeChannel(CHANNELS.PG_CONNECT, connectSpanOptions);\n subscribeQueryLikeChannel(CHANNELS.PGPOOL_CONNECT, poolConnectSpanOptions);\n }\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Subscribe to a pg tracing-channel and manage a span across its lifecycle.\n * Shared by the query/connect/pool-connect channels. They differ only in how\n * the span's name + attributes are built (`getSpanOptions`), and whether the\n * result can be a streamable emitter (`deferStreamedResult`, query-only).\n */\nfunction subscribeQueryLikeChannel(\n channelName: string,\n getSpanOptions: (ctx: PgChannelContext) => { name: string; op: string; attributes: SpanAttributes },\n { deferStreamedResult = false }: { deferStreamedResult?: boolean } = {},\n): void {\n DEBUG_BUILD && debug.log(`[orchestrion:pg] subscribing to channel \"${channelName}\"`);\n\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<PgChannelContext>(channelName),\n data => {\n // Capture the caller's scope while still synchronously inside the call, for the streamed path:\n // pg dispatches a `Submittable` emitter's events outside the original async scope, so `deferSpanEnd`\n // replays this scope onto that emitter.\n data._sentryCallerScope = getCurrentScope();\n\n // `kind: CLIENT` mirrors the OTel pg instrumentation, so the emitted\n // `otel.kind` matches across the OTel and diagnostics-channel paths.\n return startInactiveSpan({ ...getSpanOptions(data), kind: SPAN_KIND.CLIENT });\n },\n // `connect`/`pool-connect` resolve with a persistent `Client` (itself an\n // `EventEmitter`), which is NOT a streamed result. Deferring their span\n // to that emitter's `'end'`/`'error'` would keep it open for the whole\n // connection lifetime, so it never ends in time and is dropped. Only\n // `query` can return a streamable `Submittable`, so only it defers.\n deferStreamedResult\n ? {\n // Only instrument under an active span, leaving the context untouched otherwise\n // (e.g. connects issued during app startup).\n requiresParentSpan: true,\n // Streamable `Submittable` (e.g. `client.query(new Query())`)\n // returns an emitter that orchestrion stores on `ctx.result` while\n // firing no async events; the query isn't done until the emitter\n // emits `'end'`/`'error'`. Defer ending to those events for that\n // path; the callback, promise, and sync-throw paths carry no\n // emitter, so the helper ends the span as usual.\n deferSpanEnd({ data, end }) {\n const result = data.result;\n if (!result || typeof result !== 'object' || !hasOnMethod(result)) {\n return false;\n }\n\n // Replay the caller's scope onto the emitter so listeners theu\n // user attaches after the call returns (and any spans they start)\n // nest under the caller, not a fresh root trace.\n const callerScope = data._sentryCallerScope;\n if (callerScope) {\n bindScopeToEmitter(result, callerScope);\n }\n\n result.on('error', err => end(err));\n result.on('end', () => end());\n\n return true;\n },\n }\n : { requiresParentSpan: true },\n );\n}\n\nfunction querySpanOptions(ctx: PgChannelContext): { name: string; op: string; attributes: SpanAttributes } {\n const params = (ctx.self as { connectionParameters?: PgConnectionParams } | undefined)?.connectionParameters ?? {};\n const queryConfig = extractQueryConfig(ctx.arguments);\n return {\n // The description is the SQL statement\n name: queryConfig?.text ?? SPAN_QUERY_FALLBACK,\n op: 'db',\n attributes: {\n ...getConnectionAttributes(params),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [ATTR_DB_STATEMENT]: queryConfig?.text || undefined,\n [ATTR_PG_PLAN]: typeof queryConfig?.name === 'string' ? queryConfig.name : undefined,\n },\n };\n}\n\nfunction connectSpanOptions(ctx: PgChannelContext): { name: string; op: string; attributes: SpanAttributes } {\n const params = (ctx.self as { connectionParameters?: PgConnectionParams } | undefined)?.connectionParameters ?? {};\n // No origin set -> defaults to 'manual'\n return { name: SPAN_CONNECT, op: 'db', attributes: getConnectionAttributes(params) };\n}\n\nfunction poolConnectSpanOptions(ctx: PgChannelContext): { name: string; op: string; attributes: SpanAttributes } {\n const opts = (ctx.self as { options?: PgPoolOptions } | undefined)?.options ?? {};\n return { name: SPAN_POOL_CONNECT, op: 'db', attributes: getPoolConnectionAttributes(opts) };\n}\n\nfunction hasOnMethod(obj: object): obj is { on: (event: string, listener: (arg?: unknown) => void) => unknown } {\n return 'on' in obj && typeof (obj as { on?: unknown }).on === 'function';\n}\n\n// `client.query(text, cb?)`, `client.query(text, values, cb?)`, and\n// `client.query(configObj, cb?)` are all valid; normalize to `{ text, name }`\n// (the only fields the span needs). Returns undefined for invalid args.\nfunction extractQueryConfig(args: unknown[]): { text: string; name?: unknown } | undefined {\n const arg0 = args[0];\n if (typeof arg0 === 'string') {\n return { text: arg0 };\n }\n if (isObjectLike(arg0) && typeof (arg0 as { text?: unknown }).text === 'string') {\n const obj = arg0 as { text: string; name?: unknown };\n return { text: obj.text, name: obj.name };\n }\n return undefined;\n}\n\nfunction getConnectionAttributes(params: PgConnectionParams): SpanAttributes {\n return {\n [ATTR_DB_SYSTEM]: DB_SYSTEM_POSTGRESQL,\n [ATTR_DB_CONNECTION_STRING]: getConnectionString(params),\n [ATTR_DB_NAME]: params.database,\n [ATTR_DB_USER]: params.user,\n [ATTR_NET_PEER_NAME]: params.host,\n [ATTR_NET_PEER_PORT]: Number.isInteger(params.port) ? params.port : undefined,\n };\n}\n\nfunction getPoolConnectionAttributes(opts: PgPoolOptions): SpanAttributes {\n let url: URL | undefined;\n try {\n url = opts.connectionString ? new URL(opts.connectionString) : undefined;\n } catch {\n url = undefined;\n }\n const database = url?.pathname.slice(1) || opts.database;\n const host = url?.hostname || opts.host;\n // Mirror OTel's `getSemanticAttributesFromPoolConnection`: prefer the URL's\n // port, but fall back to an explicit `opts.port` when the connection string\n // omits it (`Number('')` / `Number(undefined)` -> falsy).\n const port = Number(url?.port) || (Number.isInteger(opts.port) ? opts.port : undefined);\n const user = url?.username || opts.user;\n return {\n [ATTR_DB_SYSTEM]: DB_SYSTEM_POSTGRESQL,\n [ATTR_DB_CONNECTION_STRING]: getConnectionString(opts),\n [ATTR_PG_IDLE_TIMEOUT]: opts.idleTimeoutMillis,\n [ATTR_PG_MAX_CLIENT]: opts.max,\n [ATTR_DB_NAME]: database,\n [ATTR_NET_PEER_PORT]: port,\n // these two come from a url parse and slice, can be ''\n [ATTR_NET_PEER_NAME]: host || undefined,\n [ATTR_DB_USER]: user || undefined,\n };\n}\n\n// Builds `postgresql://host:port/database`, masking credentials when a raw\n// connection string was provided.\nfunction getConnectionString(params: PgConnectionParams): string {\n if (params.connectionString) {\n try {\n const url = new URL(params.connectionString);\n url.username = '';\n url.password = '';\n return url.toString();\n } catch {\n return 'postgresql://localhost:5432/';\n }\n }\n const host = params.host || 'localhost';\n const port = params.port || 5432;\n const database = params.database || '';\n return `postgresql://${host}:${port}/${database}`;\n}\n\n/**\n * EXPERIMENTAL: orchestrion-driven `pg` (node-postgres) integration.\n *\n * Subscribes to the `orchestrion:pg:query`/`:connect` and\n * `orchestrion:pg-pool:connect` diagnostics_channels that the orchestrion code\n * transform injects into `pg`'s `Client.prototype.query`/`connect`\n * and `pg-pool`'s `Pool.prototype.connect`. Requires the orchestrion runtime\n * hook or bundler plugin to be active.\n */\nexport const postgresChannelIntegration = defineIntegration(_postgresChannelIntegration);\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,gBAAA,GAAmB,UAAA;AAIzB,MAAM,MAAA,GAAS,8BAAA;AAIf,MAAM,cAAA,GAAiB,WAAA;AACvB,MAAM,YAAA,GAAe,SAAA;AACrB,MAAM,yBAAA,GAA4B,sBAAA;AAClC,MAAM,YAAA,GAAe,SAAA;AACrB,MAAM,iBAAA,GAAoB,cAAA;AAC1B,MAAM,kBAAA,GAAqB,eAAA;AAC3B,MAAM,kBAAA,GAAqB,eAAA;AAC3B,MAAM,YAAA,GAAe,oBAAA;AACrB,MAAM,oBAAA,GAAuB,mCAAA;AAC7B,MAAM,kBAAA,GAAqB,0BAAA;AAC3B,MAAM,oBAAA,GAAuB,YAAA;AAS7B,MAAM,mBAAA,GAAsB,UAAA;AAC5B,MAAM,YAAA,GAAe,YAAA;AACrB,MAAM,iBAAA,GAAoB,iBAAA;AAiC1B,MAAM,2BAAA,IAA+B,CAAC,OAAA,GAA4C,EAAC,KAAM;AACvF,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAAC,mBAAmB,cAAA,EAAgB;AACtC,QAAA;AAAA,MACF;AAEA,MAAA,4BAAA,CAA6B,MAAM;AAGjC,QAAA,yBAAA,CAA0B,SAAS,QAAA,EAAU,gBAAA,EAAkB,EAAE,mBAAA,EAAqB,MAAM,CAAA;AAK5F,QAAA,IAAI,CAAC,QAAQ,kBAAA,EAAoB;AAC/B,UAAA,yBAAA,CAA0B,QAAA,CAAS,YAAY,kBAAkB,CAAA;AACjE,UAAA,yBAAA,CAA0B,QAAA,CAAS,gBAAgB,sBAAsB,CAAA;AAAA,QAC3E;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF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AkB,2BAA2B;;;;"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
2
|
+
import { SERVER_PORT, SERVER_ADDRESS, DB_OPERATION_BATCH_SIZE, DB_SYSTEM_NAME, DB_STATEMENT, NET_PEER_PORT, NET_PEER_NAME, DB_SYSTEM } from '@sentry/conventions/attributes';
|
|
3
|
+
import { defineIntegration, debug, waitForTracingChannelBinding, getActiveSpan, withActiveSpan, startInactiveSpan, SPAN_KIND, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR, isObjectLike } from '@sentry/core';
|
|
4
|
+
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
5
|
+
import { CHANNELS } from '../../orchestrion/channels.js';
|
|
6
|
+
import { defaultDbStatementSerializer } from '../../redis/redis-statement-serializer.js';
|
|
7
|
+
import { bindTracingChannelToSpan } from '../../tracing-channel.js';
|
|
8
|
+
|
|
9
|
+
const INTEGRATION_NAME = "RedisChannel";
|
|
10
|
+
const ORIGIN = "auto.db.orchestrion.redis";
|
|
11
|
+
const ATTR_DB_CONNECTION_STRING = "db.connection_string";
|
|
12
|
+
const DB_SYSTEM_VALUE_REDIS = "redis";
|
|
13
|
+
function endSpan(span, err) {
|
|
14
|
+
if (err) {
|
|
15
|
+
span.setStatus({ code: SPAN_STATUS_ERROR, message: err instanceof Error ? err.message : String(err) });
|
|
16
|
+
}
|
|
17
|
+
span.end();
|
|
18
|
+
}
|
|
19
|
+
function runResponseHook(hook, span, command, args, result) {
|
|
20
|
+
if (!hook) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
hook(span, command, args, result);
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function stripCommandOptions(args) {
|
|
29
|
+
const first = args[0];
|
|
30
|
+
if (isObjectLike(first) && Object.getOwnPropertySymbols(first).length > 0) {
|
|
31
|
+
return args.slice(1);
|
|
32
|
+
}
|
|
33
|
+
return args;
|
|
34
|
+
}
|
|
35
|
+
function removeCredentialsFromConnectionString(url) {
|
|
36
|
+
if (typeof url !== "string" || !url) {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const parsed = new URL(url);
|
|
41
|
+
parsed.searchParams.delete("user_pwd");
|
|
42
|
+
parsed.username = "";
|
|
43
|
+
parsed.password = "";
|
|
44
|
+
return parsed.href;
|
|
45
|
+
} catch {
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function nodeRedisAttributes(options) {
|
|
50
|
+
return {
|
|
51
|
+
[DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS,
|
|
52
|
+
[NET_PEER_NAME]: options?.socket?.host,
|
|
53
|
+
[NET_PEER_PORT]: options?.socket?.port,
|
|
54
|
+
[ATTR_DB_CONNECTION_STRING]: removeCredentialsFromConnectionString(options?.url),
|
|
55
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function startCommandSpan(commandName, commandArgs, attributes) {
|
|
59
|
+
return startInactiveSpan({
|
|
60
|
+
name: `redis-${commandName}`,
|
|
61
|
+
kind: SPAN_KIND.CLIENT,
|
|
62
|
+
attributes: {
|
|
63
|
+
...attributes,
|
|
64
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db",
|
|
65
|
+
[DB_STATEMENT]: defaultDbStatementSerializer(commandName, commandArgs)
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function subscribeLegacyRedisCommand(responseHook) {
|
|
70
|
+
const channel = diagnosticsChannel.tracingChannel(CHANNELS.REDIS_COMMAND);
|
|
71
|
+
const noop = () => {
|
|
72
|
+
};
|
|
73
|
+
channel.subscribe({
|
|
74
|
+
end: noop,
|
|
75
|
+
asyncStart: noop,
|
|
76
|
+
asyncEnd: noop,
|
|
77
|
+
start(data) {
|
|
78
|
+
const command = data.arguments?.[0];
|
|
79
|
+
if (!command || typeof command !== "object") {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const originalCallback = command.callback;
|
|
83
|
+
if (typeof originalCallback !== "function") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const client = data.self;
|
|
87
|
+
const attributes = {
|
|
88
|
+
[DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS,
|
|
89
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
|
|
90
|
+
};
|
|
91
|
+
attributes[NET_PEER_NAME] = client?.connection_options?.host;
|
|
92
|
+
attributes[NET_PEER_PORT] = client?.connection_options?.port;
|
|
93
|
+
if (client?.address) {
|
|
94
|
+
attributes[ATTR_DB_CONNECTION_STRING] = `redis://${client.address}`;
|
|
95
|
+
}
|
|
96
|
+
const span = startCommandSpan(command.command, command.args ?? [], attributes);
|
|
97
|
+
data._sentrySpan = span;
|
|
98
|
+
const parentSpan = getActiveSpan();
|
|
99
|
+
command.callback = function(err, reply) {
|
|
100
|
+
if (!err) {
|
|
101
|
+
runResponseHook(responseHook, span, command.command, command.args ?? [], reply);
|
|
102
|
+
}
|
|
103
|
+
endSpan(span, err);
|
|
104
|
+
const args = arguments;
|
|
105
|
+
return withActiveSpan(parentSpan ?? null, () => originalCallback.apply(this, args));
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
error(data) {
|
|
109
|
+
const span = data._sentrySpan;
|
|
110
|
+
if (span) {
|
|
111
|
+
endSpan(span, data.error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function bindNodeRedisCommandChannel(channelName, getWireArgs, responseHook) {
|
|
117
|
+
const channel = diagnosticsChannel.tracingChannel(channelName);
|
|
118
|
+
bindTracingChannelToSpan(
|
|
119
|
+
channel,
|
|
120
|
+
(data) => {
|
|
121
|
+
const wireArgs = getWireArgs(data);
|
|
122
|
+
if (!wireArgs?.length) {
|
|
123
|
+
return void 0;
|
|
124
|
+
}
|
|
125
|
+
const commandName = String(wireArgs[0]);
|
|
126
|
+
const options = data.self?.options;
|
|
127
|
+
return startCommandSpan(commandName, wireArgs.slice(1), nodeRedisAttributes(options));
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
captureError: false,
|
|
131
|
+
beforeSpanEnd(span, data) {
|
|
132
|
+
if ("error" in data || !responseHook) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const wireArgs = getWireArgs(data);
|
|
136
|
+
if (wireArgs?.length) {
|
|
137
|
+
runResponseHook(responseHook, span, String(wireArgs[0]), wireArgs.slice(1), data.result);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
function getSendCommandArgs(data) {
|
|
144
|
+
const args = data.arguments?.[0];
|
|
145
|
+
return Array.isArray(args) ? args : void 0;
|
|
146
|
+
}
|
|
147
|
+
function getExecutorArgs(data) {
|
|
148
|
+
const command = data.arguments?.[0];
|
|
149
|
+
const jsArgs = data.arguments?.[1];
|
|
150
|
+
if (typeof command?.transformArguments !== "function" || !Array.isArray(jsArgs)) {
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
return command.transformArguments(...stripCommandOptions(jsArgs));
|
|
155
|
+
} catch {
|
|
156
|
+
return void 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function bindNodeRedisConnectChannel() {
|
|
160
|
+
const channel = diagnosticsChannel.tracingChannel(CHANNELS.NODE_REDIS_CONNECT);
|
|
161
|
+
bindTracingChannelToSpan(
|
|
162
|
+
channel,
|
|
163
|
+
(data) => {
|
|
164
|
+
const options = data.self?.options;
|
|
165
|
+
return startInactiveSpan({
|
|
166
|
+
name: "redis-connect",
|
|
167
|
+
kind: SPAN_KIND.CLIENT,
|
|
168
|
+
attributes: { ...nodeRedisAttributes(options), [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db" }
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
{ captureError: false }
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
function bindNodeRedisBatchChannel(channelName, getOperation) {
|
|
175
|
+
const channel = diagnosticsChannel.tracingChannel(channelName);
|
|
176
|
+
bindTracingChannelToSpan(
|
|
177
|
+
channel,
|
|
178
|
+
(data) => {
|
|
179
|
+
const commands = data.arguments?.[0];
|
|
180
|
+
const size = Array.isArray(commands) ? commands.length : void 0;
|
|
181
|
+
const socket = data.self?.options?.socket;
|
|
182
|
+
return startInactiveSpan({
|
|
183
|
+
name: getOperation(data),
|
|
184
|
+
kind: SPAN_KIND.CLIENT,
|
|
185
|
+
attributes: {
|
|
186
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
187
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db.redis",
|
|
188
|
+
[DB_SYSTEM_NAME]: DB_SYSTEM_VALUE_REDIS,
|
|
189
|
+
...size && size > 1 ? { [DB_OPERATION_BATCH_SIZE]: size } : {},
|
|
190
|
+
...socket?.host != null ? { [SERVER_ADDRESS]: socket.host } : {},
|
|
191
|
+
...socket?.port != null ? { [SERVER_PORT]: socket.port } : {}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
{ captureError: false }
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
const _redisChannelIntegration = ((options = {}) => {
|
|
199
|
+
const responseHook = options.responseHook;
|
|
200
|
+
return {
|
|
201
|
+
name: INTEGRATION_NAME,
|
|
202
|
+
setupOnce() {
|
|
203
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
DEBUG_BUILD && debug.log(`[orchestrion:redis] subscribing to "${CHANNELS.REDIS_COMMAND}" and node-redis channels`);
|
|
207
|
+
subscribeLegacyRedisCommand(responseHook);
|
|
208
|
+
waitForTracingChannelBinding(() => {
|
|
209
|
+
bindNodeRedisCommandChannel(CHANNELS.NODE_REDIS_COMMAND, getSendCommandArgs, responseHook);
|
|
210
|
+
bindNodeRedisCommandChannel(CHANNELS.NODE_REDIS_EXECUTOR, getExecutorArgs, responseHook);
|
|
211
|
+
bindNodeRedisConnectChannel();
|
|
212
|
+
bindNodeRedisBatchChannel(CHANNELS.NODE_REDIS_MULTI, () => "MULTI");
|
|
213
|
+
bindNodeRedisBatchChannel(CHANNELS.NODE_REDIS_PIPELINE, () => "PIPELINE");
|
|
214
|
+
bindNodeRedisBatchChannel(
|
|
215
|
+
CHANNELS.NODE_REDIS_BATCH,
|
|
216
|
+
(data) => data.arguments?.[2] !== void 0 ? "MULTI" : "PIPELINE"
|
|
217
|
+
);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
const redisChannelIntegration = defineIntegration(_redisChannelIntegration);
|
|
223
|
+
|
|
224
|
+
export { redisChannelIntegration };
|
|
225
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.js","sources":["../../../../src/integrations/tracing-channel/redis.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated -- we intentionally emit the OLD db/net semconv\n to match `@opentelemetry/instrumentation-redis`. TODO(v11): switch to the non-deprecated\n `db.system.name`/`db.query.text`/`server.address`/`server.port` conventions and drop this disable. */\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport {\n DB_OPERATION_BATCH_SIZE,\n DB_STATEMENT,\n DB_SYSTEM,\n DB_SYSTEM_NAME,\n NET_PEER_NAME,\n NET_PEER_PORT,\n SERVER_ADDRESS,\n SERVER_PORT,\n} from '@sentry/conventions/attributes';\nimport type { IntegrationFn, Span, SpanAttributes } from '@sentry/core';\nimport {\n isObjectLike,\n debug,\n defineIntegration,\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n waitForTracingChannelBinding,\n withActiveSpan,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { defaultDbStatementSerializer } from '../../redis/redis-statement-serializer';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// A distinct name from the composite OTel `Redis` integration — they can't share one, and\n// `Redis` stays in the set for its native diagnostics_channel subscriber (node-redis >=5.12 /\n// ioredis >=5.11). When this integration is active, the OTel `RedisInstrumentation` monkey-patch\n// is fully gated off in the node SDK.\nconst INTEGRATION_NAME = 'RedisChannel' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.redis';\n\n// todo(v11): drop this — it is already covered by host and port.\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\nconst DB_SYSTEM_VALUE_REDIS = 'redis';\n\n/** Mirrors `@opentelemetry/instrumentation-redis`' response hook. Not called for failed commands. */\nexport type RedisResponseHook = (span: Span, command: string, args: Array<string | Buffer>, result: unknown) => void;\n\nexport interface RedisChannelIntegrationOptions {\n responseHook?: RedisResponseHook;\n}\n\n/** Structural type for a node-redis (`@redis/client`) command definition. */\ninterface RedisCommandDefinition {\n transformArguments?: (...args: unknown[]) => Array<string | Buffer>;\n}\n\n/** Structural type for the `command_obj` `redis` v2-v3 passes to `internal_send_command`. */\ninterface LegacyRedisCommand {\n command: string;\n args: Array<string | Buffer>;\n callback?: (err: Error | null | undefined, reply: unknown) => unknown;\n}\n\ninterface LegacyRedisClient {\n connection_options?: { host?: string; port?: number };\n address?: string;\n}\n\ninterface NodeRedisClientOptions {\n socket?: { host?: string; port?: number };\n url?: string;\n}\n\ninterface NodeRedisClient {\n options?: NodeRedisClientOptions;\n}\n\ninterface CommandContext {\n arguments?: unknown[];\n self?: unknown;\n result?: unknown;\n error?: unknown;\n}\n\nfunction endSpan(span: Span, err: unknown): void {\n if (err) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err instanceof Error ? err.message : String(err) });\n }\n span.end();\n}\n\nfunction runResponseHook(\n hook: RedisResponseHook | undefined,\n span: Span,\n command: string,\n args: Array<string | Buffer>,\n result: unknown,\n): void {\n if (!hook) {\n return;\n }\n try {\n hook(span, command, args, result);\n } catch {\n // never let a user-provided response hook break instrumentation\n }\n}\n\n// Strip a leading `commandOptions(...)` object (tagged with a `Symbol`) before\n// deriving the wire arguments, mirroring `@redis/client`'s `transformCommandArguments`.\nfunction stripCommandOptions(args: unknown[]): unknown[] {\n const first = args[0];\n if (isObjectLike(first) && Object.getOwnPropertySymbols(first).length > 0) {\n return args.slice(1);\n }\n return args;\n}\n\nfunction removeCredentialsFromConnectionString(url: string | undefined): string | undefined {\n if (typeof url !== 'string' || !url) {\n return undefined;\n }\n try {\n const parsed = new URL(url);\n parsed.searchParams.delete('user_pwd');\n parsed.username = '';\n parsed.password = '';\n return parsed.href;\n } catch {\n return undefined;\n }\n}\n\nfunction nodeRedisAttributes(options: NodeRedisClientOptions | undefined): SpanAttributes {\n return {\n [DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS,\n [NET_PEER_NAME]: options?.socket?.host,\n [NET_PEER_PORT]: options?.socket?.port,\n [ATTR_DB_CONNECTION_STRING]: removeCredentialsFromConnectionString(options?.url),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n}\n\nfunction startCommandSpan(commandName: string, commandArgs: Array<string | Buffer>, attributes: SpanAttributes): Span {\n return startInactiveSpan({\n name: `redis-${commandName}`,\n kind: SPAN_KIND.CLIENT,\n attributes: {\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n [DB_STATEMENT]: defaultDbStatementSerializer(commandName, commandArgs),\n },\n });\n}\n\n// --- redis v2-v3: `RedisClient.prototype.internal_send_command(command_obj)` ---\n\n// Settles via `command_obj.callback`, not the sync return — so instead of\n// `bindTracingChannelToSpan` we open the span in `start`, wrap the callback to end it, and end on `error` for sync throws.\nfunction subscribeLegacyRedisCommand(responseHook: RedisResponseHook | undefined): void {\n const channel = diagnosticsChannel.tracingChannel<CommandContext>(CHANNELS.REDIS_COMMAND);\n const noop = (): void => {};\n channel.subscribe({\n end: noop,\n asyncStart: noop,\n asyncEnd: noop,\n start(data) {\n const command = data.arguments?.[0] as LegacyRedisCommand | undefined;\n if (!command || typeof command !== 'object') {\n return;\n }\n // The span is ended via the wrapped callback (or the sync-throw `error` path). A\n // command with no callback has no completion signal to end it on, so don't open one.\n const originalCallback = command.callback;\n if (typeof originalCallback !== 'function') {\n return;\n }\n const client = data.self as LegacyRedisClient | undefined;\n const attributes: SpanAttributes = {\n [DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n\n attributes[NET_PEER_NAME] = client?.connection_options?.host;\n attributes[NET_PEER_PORT] = client?.connection_options?.port;\n\n if (client?.address) {\n attributes[ATTR_DB_CONNECTION_STRING] = `redis://${client.address}`;\n }\n const span = startCommandSpan(command.command, command.args ?? [], attributes);\n (data as CommandContext & { _sentrySpan?: Span })._sentrySpan = span;\n\n const parentSpan = getActiveSpan();\n command.callback = function (this: unknown, err: Error | null | undefined, reply: unknown) {\n if (!err) {\n runResponseHook(responseHook, span, command.command, command.args ?? [], reply);\n }\n endSpan(span, err);\n // eslint-disable-next-line prefer-rest-params\n const args = arguments as unknown as [Error | null | undefined, unknown];\n return withActiveSpan(parentSpan ?? null, () => originalCallback.apply(this, args));\n };\n },\n error(data) {\n // Synchronous throw: the wrapped callback never fires, so end here instead.\n const span = (data as CommandContext & { _sentrySpan?: Span })._sentrySpan;\n if (span) {\n endSpan(span, data.error);\n }\n },\n });\n}\n\n// --- node-redis v4/v5 (`@redis/client`) ---\n\nfunction bindNodeRedisCommandChannel(\n channelName: string,\n getWireArgs: (data: CommandContext) => Array<string | Buffer> | undefined,\n responseHook: RedisResponseHook | undefined,\n): void {\n const channel = diagnosticsChannel.tracingChannel<CommandContext, CommandContext>(channelName);\n bindTracingChannelToSpan(\n channel,\n data => {\n const wireArgs = getWireArgs(data);\n if (!wireArgs?.length) {\n return undefined;\n }\n const commandName = String(wireArgs[0]);\n const options = (data.self as NodeRedisClient | undefined)?.options;\n return startCommandSpan(commandName, wireArgs.slice(1), nodeRedisAttributes(options));\n },\n {\n captureError: false,\n beforeSpanEnd(span, data) {\n if ('error' in data || !responseHook) {\n return;\n }\n const wireArgs = getWireArgs(data);\n if (wireArgs?.length) {\n runResponseHook(responseHook, span, String(wireArgs[0]), wireArgs.slice(1), data.result);\n }\n },\n },\n );\n}\n\n// `sendCommand(args, options)` — `args` are already the wire arguments.\nfunction getSendCommandArgs(data: CommandContext): Array<string | Buffer> | undefined {\n const args = data.arguments?.[0];\n return Array.isArray(args) ? (args as Array<string | Buffer>) : undefined;\n}\n\n// `commandsExecutor(command, jsArgs)` — derive the wire arguments the same way\n// `@redis/client` does internally, via `command.transformArguments`.\nfunction getExecutorArgs(data: CommandContext): Array<string | Buffer> | undefined {\n const command = data.arguments?.[0] as RedisCommandDefinition | undefined;\n const jsArgs = data.arguments?.[1];\n if (typeof command?.transformArguments !== 'function' || !Array.isArray(jsArgs)) {\n return undefined;\n }\n try {\n return command.transformArguments(...stripCommandOptions(jsArgs));\n } catch {\n return undefined;\n }\n}\n\nfunction bindNodeRedisConnectChannel(): void {\n const channel = diagnosticsChannel.tracingChannel<CommandContext, CommandContext>(CHANNELS.NODE_REDIS_CONNECT);\n bindTracingChannelToSpan(\n channel,\n data => {\n const options = (data.self as NodeRedisClient | undefined)?.options;\n return startInactiveSpan({\n name: 'redis-connect',\n kind: SPAN_KIND.CLIENT,\n attributes: { ...nodeRedisAttributes(options), [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db' },\n });\n },\n { captureError: false },\n );\n}\n\n// Batch (multi/pipeline): one span per `exec`. Batched commands bypass `sendCommand`, so\n// the executor's `ctx.arguments[0]` (the queued commands) gives the batch size. Span shape\n// mirrors the native `node-redis:batch` span (see `redis-dc-subscriber.ts`).\nfunction bindNodeRedisBatchChannel(channelName: string, getOperation: (data: CommandContext) => string): void {\n const channel = diagnosticsChannel.tracingChannel<CommandContext, CommandContext>(channelName);\n bindTracingChannelToSpan(\n channel,\n data => {\n const commands = data.arguments?.[0];\n const size = Array.isArray(commands) ? commands.length : undefined;\n const socket = (data.self as NodeRedisClient | undefined)?.options?.socket;\n return startInactiveSpan({\n name: getOperation(data),\n kind: SPAN_KIND.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_VALUE_REDIS,\n ...(size && size > 1 ? { [DB_OPERATION_BATCH_SIZE]: size } : {}),\n ...(socket?.host != null ? { [SERVER_ADDRESS]: socket.host } : {}),\n ...(socket?.port != null ? { [SERVER_PORT]: socket.port } : {}),\n },\n });\n },\n { captureError: false },\n );\n}\n\nconst _redisChannelIntegration = ((options: RedisChannelIntegrationOptions = {}) => {\n const responseHook = options.responseHook;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(`[orchestrion:redis] subscribing to \"${CHANNELS.REDIS_COMMAND}\" and node-redis channels`);\n\n // redis v2-v3 uses a nested callback rather than `bindStore`, so it can be\n // subscribed synchronously here.\n subscribeLegacyRedisCommand(responseHook);\n\n waitForTracingChannelBinding(() => {\n bindNodeRedisCommandChannel(CHANNELS.NODE_REDIS_COMMAND, getSendCommandArgs, responseHook);\n bindNodeRedisCommandChannel(CHANNELS.NODE_REDIS_EXECUTOR, getExecutorArgs, responseHook);\n bindNodeRedisConnectChannel();\n bindNodeRedisBatchChannel(CHANNELS.NODE_REDIS_MULTI, () => 'MULTI');\n bindNodeRedisBatchChannel(CHANNELS.NODE_REDIS_PIPELINE, () => 'PIPELINE');\n bindNodeRedisBatchChannel(CHANNELS.NODE_REDIS_BATCH, data =>\n data.arguments?.[2] !== undefined ? 'MULTI' : 'PIPELINE',\n );\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * EXPERIMENTAL — orchestrion-driven redis integration for `redis` v2-v3 and\n * node-redis v4/v5 `<5.12.0` (`@redis/client`). Covers single commands, `connect`,\n * and multi/pipeline batches, fully replacing `@opentelemetry/instrumentation-redis`.\n * Requires the orchestrion runtime hook or bundler plugin.\n */\nexport const redisChannelIntegration = defineIntegration(_redisChannelIntegration);\n"],"names":[],"mappings":";;;;;;;;AAqCA,MAAM,gBAAA,GAAmB,cAAA;AAEzB,MAAM,MAAA,GAAS,2BAAA;AAGf,MAAM,yBAAA,GAA4B,sBAAA;AAClC,MAAM,qBAAA,GAAwB,OAAA;AA0C9B,SAAS,OAAA,CAAQ,MAAY,GAAA,EAAoB;AAC/C,EAAA,IAAI,GAAA,EAAK;AACP,IAAA,IAAA,CAAK,SAAA,CAAU,EAAE,IAAA,EAAM,iBAAA,EAAmB,OAAA,EAAS,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAA,EAAG,CAAA;AAAA,EACvG;AACA,EAAA,IAAA,CAAK,GAAA,EAAI;AACX;AAEA,SAAS,eAAA,CACP,IAAA,EACA,IAAA,EACA,OAAA,EACA,MACA,MAAA,EACM;AACN,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA;AAAA,EACF;AACA,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,MAAM,CAAA;AAAA,EAClC,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAIA,SAAS,oBAAoB,IAAA,EAA4B;AACvD,EAAA,MAAM,KAAA,GAAQ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;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAQO,MAAM,uBAAA,GAA0B,kBAAkB,wBAAwB;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineIntegration, extendIntegration, waitForTracingChannelBinding } from '@sentry/core';
|
|
2
|
+
import { vercelAiIntegration } from '../../vercel-ai/index.js';
|
|
3
|
+
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
4
|
+
import { subscribeVercelAiOrchestrionChannels } from '../../vercel-ai/vercel-ai-orchestrion-subscriber.js';
|
|
5
|
+
|
|
6
|
+
const _vercelAiChannelIntegration = ((options = {}) => {
|
|
7
|
+
const parentIntegration = vercelAiIntegration(options);
|
|
8
|
+
return extendIntegration(parentIntegration, {
|
|
9
|
+
options,
|
|
10
|
+
setupOnce() {
|
|
11
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
waitForTracingChannelBinding(() => {
|
|
15
|
+
subscribeVercelAiOrchestrionChannels(diagnosticsChannel.tracingChannel, options);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
const vercelAiChannelIntegration = defineIntegration(_vercelAiChannelIntegration);
|
|
21
|
+
|
|
22
|
+
export { vercelAiChannelIntegration };
|
|
23
|
+
//# sourceMappingURL=vercel-ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-ai.js","sources":["../../../../src/integrations/tracing-channel/vercel-ai.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, extendIntegration, waitForTracingChannelBinding } from '@sentry/core';\nimport { vercelAiIntegration as baseVercelAiIntegration } from '../../vercel-ai';\nimport * as dc from 'node:diagnostics_channel';\nimport { subscribeVercelAiOrchestrionChannels } from '../../vercel-ai/vercel-ai-orchestrion-subscriber';\n\ntype VercelAiOptions = Parameters<typeof baseVercelAiIntegration>[0];\n\n// In channel-based (orchestrion) mode we emit our own `gen_ai.*` spans from the\n// diagnostics channels. The `ai` SDK would otherwise emit its own native\n// OpenTelemetry spans whenever the user enables `experimental_telemetry`, which\n// would be duplicates. Rather than dropping those after the fact, the v6\n// subscriber suppresses them at the source: it flips the wrapped call's\n// `experimental_telemetry.isEnabled` to `false`, so `ai` falls back to its\n// internal no-op tracer and never creates the native spans in the first place.\n// See `subscribeVercelAiOrchestrionChannels`.\nconst _vercelAiChannelIntegration = ((options: VercelAiOptions = {}) => {\n const parentIntegration = baseVercelAiIntegration(options);\n\n return extendIntegration(parentIntegration, {\n options,\n setupOnce() {\n // Bail if this is not available\n if (!dc.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n subscribeVercelAiOrchestrionChannels(dc.tracingChannel, options);\n });\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Auto-instrument the `ai` SDK. Supported are:\n * - v7 via native `ai:telemetry` tracing channel\n * - v4, v5 & v6 via orchestrion `orchestrion:ai:*` channels\n */\nexport const vercelAiChannelIntegration = defineIntegration(_vercelAiChannelIntegration);\n"],"names":["baseVercelAiIntegration","dc"],"mappings":";;;;;AAgBA,MAAM,2BAAA,IAA+B,CAAC,OAAA,GAA2B,EAAC,KAAM;AACtE,EAAA,MAAM,iBAAA,GAAoBA,oBAAwB,OAAO,CAAA;AAEzD,EAAA,OAAO,kBAAkB,iBAAA,EAAmB;AAAA,IAC1C,OAAA;AAAA,IACA,SAAA,GAAY;AAEV,MAAA,IAAI,CAACC,mBAAG,cAAA,EAAgB;AACtB,QAAA;AAAA,MACF;AAEA,MAAA,4BAAA,CAA6B,MAAM;AACjC,QAAA,oCAAA,CAAqCA,kBAAA,CAAG,gBAAgB,OAAO,CAAA;AAAA,MACjE,CAAC,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAOO,MAAM,0BAAA,GAA6B,kBAAkB,2BAA2B;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineIntegration, waitForTracingChannelBinding } from '@sentry/core';
|
|
2
|
+
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
3
|
+
import { subscribeMongooseDiagnosticChannels } from './mongoose-dc-subscriber.js';
|
|
4
|
+
|
|
5
|
+
const _mongooseIntegration = (() => {
|
|
6
|
+
return {
|
|
7
|
+
name: "Mongoose",
|
|
8
|
+
setupOnce() {
|
|
9
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
waitForTracingChannelBinding(() => {
|
|
13
|
+
subscribeMongooseDiagnosticChannels(diagnosticsChannel.tracingChannel);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
const mongooseIntegration = defineIntegration(_mongooseIntegration);
|
|
19
|
+
|
|
20
|
+
export { mongooseIntegration };
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/mongoose/index.ts"],"sourcesContent":["import { defineIntegration, type IntegrationFn, waitForTracingChannelBinding } from '@sentry/core';\nimport * as dc from 'node:diagnostics_channel';\nimport { subscribeMongooseDiagnosticChannels } from './mongoose-dc-subscriber';\n\nconst _mongooseIntegration = (() => {\n return {\n name: 'Mongoose',\n setupOnce() {\n // Bail on Node <= 18.18.0, where `tracingChannel` does not exist.\n if (!dc.tracingChannel) {\n return;\n }\n\n // Subscribe to mongoose's native tracing channels (mongoose >= 9.7).\n // This is a no-op on versions that don't publish to the channels, so it is always safe to call.\n waitForTracingChannelBinding(() => {\n subscribeMongooseDiagnosticChannels(dc.tracingChannel);\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Auto-instrument the [mongoose](https://www.npmjs.com/package/mongoose) library via its native\n * `node:diagnostics_channel` tracing channels (mongoose >= 9.7).\n *\n * On older mongoose versions the channels are never published to, so this integration is inert and\n * the IITM-based patcher (gated to `< 9.7.0`) handles instrumentation instead.\n */\nexport const mongooseIntegration = defineIntegration(_mongooseIntegration);\n"],"names":["dc"],"mappings":";;;;AAIA,MAAM,wBAAwB,MAAM;AAClC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,UAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAACA,mBAAG,cAAA,EAAgB;AACtB,QAAA;AAAA,MACF;AAIA,MAAA,4BAAA,CAA6B,MAAM;AACjC,QAAA,mCAAA,CAAoCA,mBAAG,cAAc,CAAA;AAAA,MACvD,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AASO,MAAM,mBAAA,GAAsB,kBAAkB,oBAAoB;;;;"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { SERVER_PORT, SERVER_ADDRESS, DB_OPERATION_BATCH_SIZE, DB_QUERY_TEXT, DB_NAMESPACE, DB_COLLECTION_NAME, DB_OPERATION_NAME, DB_SYSTEM_NAME } from '@sentry/conventions/attributes';
|
|
2
|
+
import { debug, startInactiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, isObjectLike } from '@sentry/core';
|
|
3
|
+
import { DEBUG_BUILD } from '../debug-build.js';
|
|
4
|
+
import { bindTracingChannelToSpan } from '../tracing-channel.js';
|
|
5
|
+
|
|
6
|
+
const MONGOOSE_DC_CHANNEL_QUERY = "mongoose:query";
|
|
7
|
+
const MONGOOSE_DC_CHANNEL_AGGREGATE = "mongoose:aggregate";
|
|
8
|
+
const MONGOOSE_DC_CHANNEL_MODEL_SAVE = "mongoose:model:save";
|
|
9
|
+
const MONGOOSE_DC_CHANNEL_MODEL_INSERT_MANY = "mongoose:model:insertMany";
|
|
10
|
+
const MONGOOSE_DC_CHANNEL_MODEL_BULK_WRITE = "mongoose:model:bulkWrite";
|
|
11
|
+
const MONGOOSE_DC_CHANNEL_CURSOR_NEXT = "mongoose:cursor:next";
|
|
12
|
+
const ORIGIN = "auto.db.mongoose.diagnostic_channel";
|
|
13
|
+
const DB_SYSTEM_NAME_VALUE_MONGODB = "mongodb";
|
|
14
|
+
const MAX_REDACTION_DEPTH = 10;
|
|
15
|
+
let subscribed = false;
|
|
16
|
+
function subscribeMongooseDiagnosticChannels(tracingChannel) {
|
|
17
|
+
if (subscribed) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
subscribed = true;
|
|
21
|
+
try {
|
|
22
|
+
setupChannel(tracingChannel, MONGOOSE_DC_CHANNEL_QUERY);
|
|
23
|
+
setupChannel(tracingChannel, MONGOOSE_DC_CHANNEL_AGGREGATE);
|
|
24
|
+
setupChannel(tracingChannel, MONGOOSE_DC_CHANNEL_MODEL_SAVE);
|
|
25
|
+
setupChannel(tracingChannel, MONGOOSE_DC_CHANNEL_MODEL_INSERT_MANY);
|
|
26
|
+
setupChannel(tracingChannel, MONGOOSE_DC_CHANNEL_MODEL_BULK_WRITE);
|
|
27
|
+
setupChannel(tracingChannel, MONGOOSE_DC_CHANNEL_CURSOR_NEXT);
|
|
28
|
+
} catch {
|
|
29
|
+
DEBUG_BUILD && debug.log("Mongoose node:diagnostics_channel subscription failed.");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function setupChannel(tracingChannel, channelName) {
|
|
33
|
+
bindTracingChannelToSpan(tracingChannel(channelName), (data) => {
|
|
34
|
+
const collection = data.collection;
|
|
35
|
+
const queryText = redactMongoQuery(data.args?.pipeline ?? data.args?.filter);
|
|
36
|
+
const batchSize = getBatchSize(data);
|
|
37
|
+
return startInactiveSpan({
|
|
38
|
+
name: collection ? `mongoose.${collection}.${data.operation}` : `mongoose.${data.operation}`,
|
|
39
|
+
attributes: {
|
|
40
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
41
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db",
|
|
42
|
+
[DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_MONGODB,
|
|
43
|
+
[DB_OPERATION_NAME]: data.operation,
|
|
44
|
+
[DB_COLLECTION_NAME]: collection ?? void 0,
|
|
45
|
+
[DB_NAMESPACE]: data.database ?? void 0,
|
|
46
|
+
[DB_QUERY_TEXT]: queryText ?? void 0,
|
|
47
|
+
[DB_OPERATION_BATCH_SIZE]: batchSize ?? void 0,
|
|
48
|
+
[SERVER_ADDRESS]: data.serverAddress ?? void 0,
|
|
49
|
+
[SERVER_PORT]: data.serverPort ?? void 0
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function getBatchSize(data) {
|
|
55
|
+
const args = data.args;
|
|
56
|
+
const batch = data.operation === "insertMany" ? args?.docs : data.operation === "bulkWrite" ? args?.ops : void 0;
|
|
57
|
+
return Array.isArray(batch) && batch.length > 1 ? batch.length : void 0;
|
|
58
|
+
}
|
|
59
|
+
function redactMongoQuery(value) {
|
|
60
|
+
if (value == null) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const redacted = redactValue(value, 0);
|
|
65
|
+
const text = JSON.stringify(redacted);
|
|
66
|
+
return text == null || text === "{}" || text === "[]" ? void 0 : text;
|
|
67
|
+
} catch {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function redactValue(value, depth) {
|
|
72
|
+
if (depth > MAX_REDACTION_DEPTH) {
|
|
73
|
+
return "?";
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
return value.map((item) => redactValue(item, depth + 1));
|
|
77
|
+
}
|
|
78
|
+
if (isObjectLike(value)) {
|
|
79
|
+
const out = {};
|
|
80
|
+
for (const key of Object.keys(value)) {
|
|
81
|
+
out[key] = redactValue(value[key], depth + 1);
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
return "?";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { MONGOOSE_DC_CHANNEL_AGGREGATE, MONGOOSE_DC_CHANNEL_CURSOR_NEXT, MONGOOSE_DC_CHANNEL_MODEL_BULK_WRITE, MONGOOSE_DC_CHANNEL_MODEL_INSERT_MANY, MONGOOSE_DC_CHANNEL_MODEL_SAVE, MONGOOSE_DC_CHANNEL_QUERY, subscribeMongooseDiagnosticChannels };
|
|
89
|
+
//# sourceMappingURL=mongoose-dc-subscriber.js.map
|