@sentry/server-utils 10.64.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 +10 -11
- 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/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/ioredis.js +14 -14
- package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/mysql.js +1 -1
- package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/openai.js.map +1 -1
- 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 +5 -5
- package/build/cjs/integrations/tracing-channel/postgres.js.map +1 -1
- 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 +2 -2
- package/build/cjs/integrations/tracing-channel/vercel-ai.js.map +1 -1
- package/build/cjs/mongoose/mongoose-dc-subscriber.js +1 -1
- package/build/cjs/mongoose/mongoose-dc-subscriber.js.map +1 -1
- 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/channels.js +13 -1
- 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/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/index.js +15 -2
- package/build/cjs/orchestrion/config/index.js.map +1 -1
- 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 +18 -14
- package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -1
- package/build/cjs/orchestrion/index.js +18 -1
- package/build/cjs/orchestrion/index.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/tracing-channel.js +7 -6
- 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 +138 -74
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/cjs/vercel-ai/{vercel-ai-orchestrion-v6-subscriber.js → vercel-ai-orchestrion-subscriber.js} +153 -23
- 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 +3 -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 +1 -1
- 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/ioredis.js +15 -15
- package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -1
- package/build/esm/integrations/tracing-channel/mysql.js +2 -2
- package/build/esm/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/esm/integrations/tracing-channel/openai.js +1 -1
- package/build/esm/integrations/tracing-channel/openai.js.map +1 -1
- 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 +6 -6
- package/build/esm/integrations/tracing-channel/postgres.js.map +1 -1
- 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 +1 -1
- package/build/esm/integrations/tracing-channel/vercel-ai.js.map +1 -1
- package/build/esm/mongoose/mongoose-dc-subscriber.js +2 -2
- package/build/esm/mongoose/mongoose-dc-subscriber.js.map +1 -1
- 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/channels.js +13 -1
- 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/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/index.js +15 -2
- package/build/esm/orchestrion/config/index.js.map +1 -1
- 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 +18 -14
- package/build/esm/orchestrion/config/vercel-ai.js.map +1 -1
- package/build/esm/orchestrion/index.js +14 -2
- package/build/esm/orchestrion/index.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/tracing-channel.js +8 -7
- 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 +112 -50
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/esm/vercel-ai/{vercel-ai-orchestrion-v6-subscriber.js → vercel-ai-orchestrion-subscriber.js} +153 -23
- 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 +4 -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/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/ioredis.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/mysql.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -1
- 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.map +1 -1
- 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 +1 -1
- package/build/types/mongoose/mongoose-dc-subscriber.d.ts.map +1 -1
- 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 +34 -0
- 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/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/index.d.ts.map +1 -1
- 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 +1 -0
- package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -1
- package/build/types/orchestrion/index.d.ts +31 -4
- package/build/types/orchestrion/index.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/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 +6 -2
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
- package/build/types/vercel-ai/{vercel-ai-orchestrion-v6-subscriber.d.ts → vercel-ai-orchestrion-subscriber.d.ts} +1 -1
- 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 +4 -2
- package/build/types-ts3.8/integrations/tracing-channel/amqplib.d.ts +11 -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/postgres-js.d.ts +26 -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 +1 -1
- 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 +34 -0
- package/build/types-ts3.8/orchestrion/config/amqplib.d.ts +66 -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/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 +1 -0
- package/build/types-ts3.8/orchestrion/index.d.ts +33 -4
- 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/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 +6 -2
- package/build/types-ts3.8/vercel-ai/{vercel-ai-orchestrion-v6-subscriber.d.ts → vercel-ai-orchestrion-subscriber.d.ts} +1 -1
- package/package.json +2 -2
- package/build/cjs/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js.map +0 -1
- package/build/esm/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js.map +0 -1
- package/build/types/vercel-ai/vercel-ai-orchestrion-v6-subscriber.d.ts.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const postgresJsInstrumentationConfig = (dir) => [
|
|
2
|
+
// `Query.prototype.handle` (`class Query extends Promise`) is the single
|
|
3
|
+
// funnel every query passes through (`then`/`catch`/`finally`/`.execute()`/
|
|
4
|
+
// `.forEach()`/cursor all call it), guarded by `this.executed`. `Async`
|
|
5
|
+
// because `handle` is `async`.
|
|
6
|
+
{
|
|
7
|
+
channelName: "handle",
|
|
8
|
+
module: { name: "postgres", versionRange: ">=3.0.0 <4", filePath: `${dir}/query.js` },
|
|
9
|
+
functionQuery: { className: "Query", methodName: "handle", kind: "Async" }
|
|
10
|
+
},
|
|
11
|
+
// `function Connection(options, ...)` (default export of `connection.js`)
|
|
12
|
+
// returns the connection object; used to build the endpoint registry that
|
|
13
|
+
// resolves `server.address`/`server.port`/`db.namespace`.
|
|
14
|
+
{
|
|
15
|
+
channelName: "connection",
|
|
16
|
+
module: { name: "postgres", versionRange: ">=3.0.0 <4", filePath: `${dir}/connection.js` },
|
|
17
|
+
functionQuery: { functionName: "Connection", kind: "Sync" }
|
|
18
|
+
},
|
|
19
|
+
// The nested `function execute(q)` inside `Connection`; the per-connection
|
|
20
|
+
// hook that attaches connection attributes to the query's span.
|
|
21
|
+
{
|
|
22
|
+
channelName: "execute",
|
|
23
|
+
module: { name: "postgres", versionRange: ">=3.0.0 <4", filePath: `${dir}/connection.js` },
|
|
24
|
+
functionQuery: { functionName: "execute", kind: "Sync" }
|
|
25
|
+
},
|
|
26
|
+
// The connection object's `connect(query)` method. Matched by `methodName`
|
|
27
|
+
// (an object-literal method): `functionName` would hit the unrelated
|
|
28
|
+
// socket-level `async function connect()` in the same file. `self` is the
|
|
29
|
+
// connection object and `arguments[0]` the query, so the first query that
|
|
30
|
+
// opens a connection (dispatched via a bare `execute` with no `self`) still
|
|
31
|
+
// gets connection attributes in multi-endpoint apps.
|
|
32
|
+
{
|
|
33
|
+
channelName: "connect",
|
|
34
|
+
module: { name: "postgres", versionRange: ">=3.0.0 <4", filePath: `${dir}/connection.js` },
|
|
35
|
+
functionQuery: { methodName: "connect", kind: "Sync" }
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
const postgresJsConfig = ["src", "cjs/src"].flatMap(postgresJsInstrumentationConfig);
|
|
39
|
+
const postgresJsChannels = {
|
|
40
|
+
POSTGRESJS_HANDLE: "orchestrion:postgres:handle",
|
|
41
|
+
POSTGRESJS_CONNECTION: "orchestrion:postgres:connection",
|
|
42
|
+
POSTGRESJS_EXECUTE: "orchestrion:postgres:execute",
|
|
43
|
+
POSTGRESJS_CONNECT: "orchestrion:postgres:connect"
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { postgresJsChannels, postgresJsConfig };
|
|
47
|
+
//# sourceMappingURL=postgres.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.js","sources":["../../../../src/orchestrion/config/postgres.ts"],"sourcesContent":["import type { InstrumentationConfig } from '@apm-js-collab/code-transformer';\n\n// postgres.js (`postgres` npm package, v3.x). Named after the npm package;\n// `postgres` doesn't collide with `pg.ts` (that file instruments `pg`/`pg-pool`).\n//\n// The ESM build lives under `src/*`, the CJS build under `cjs/src/*` (the\n// `cf/*` workerd build has no channel subscribers, see the integration).\n// Both builds share the same class/function shapes, so a single `flatMap`\n// over the two dirs emits one entry per (dir, target).\nconst postgresJsInstrumentationConfig = (dir: string): InstrumentationConfig[] => [\n // `Query.prototype.handle` (`class Query extends Promise`) is the single\n // funnel every query passes through (`then`/`catch`/`finally`/`.execute()`/\n // `.forEach()`/cursor all call it), guarded by `this.executed`. `Async`\n // because `handle` is `async`.\n {\n channelName: 'handle',\n module: { name: 'postgres', versionRange: '>=3.0.0 <4', filePath: `${dir}/query.js` },\n functionQuery: { className: 'Query', methodName: 'handle', kind: 'Async' },\n },\n // `function Connection(options, ...)` (default export of `connection.js`)\n // returns the connection object; used to build the endpoint registry that\n // resolves `server.address`/`server.port`/`db.namespace`.\n {\n channelName: 'connection',\n module: { name: 'postgres', versionRange: '>=3.0.0 <4', filePath: `${dir}/connection.js` },\n functionQuery: { functionName: 'Connection', kind: 'Sync' },\n },\n // The nested `function execute(q)` inside `Connection`; the per-connection\n // hook that attaches connection attributes to the query's span.\n {\n channelName: 'execute',\n module: { name: 'postgres', versionRange: '>=3.0.0 <4', filePath: `${dir}/connection.js` },\n functionQuery: { functionName: 'execute', kind: 'Sync' },\n },\n // The connection object's `connect(query)` method. Matched by `methodName`\n // (an object-literal method): `functionName` would hit the unrelated\n // socket-level `async function connect()` in the same file. `self` is the\n // connection object and `arguments[0]` the query, so the first query that\n // opens a connection (dispatched via a bare `execute` with no `self`) still\n // gets connection attributes in multi-endpoint apps.\n {\n channelName: 'connect',\n module: { name: 'postgres', versionRange: '>=3.0.0 <4', filePath: `${dir}/connection.js` },\n functionQuery: { methodName: 'connect', kind: 'Sync' },\n },\n];\n\nexport const postgresJsConfig = ['src', 'cjs/src'].flatMap(postgresJsInstrumentationConfig);\n\nexport const postgresJsChannels = {\n POSTGRESJS_HANDLE: 'orchestrion:postgres:handle',\n POSTGRESJS_CONNECTION: 'orchestrion:postgres:connection',\n POSTGRESJS_EXECUTE: 'orchestrion:postgres:execute',\n POSTGRESJS_CONNECT: 'orchestrion:postgres:connect',\n} as const;\n"],"names":[],"mappings":"AASA,MAAM,+BAAA,GAAkC,CAAC,GAAA,KAAyC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhF;AAAA,IACE,WAAA,EAAa,QAAA;AAAA,IACb,MAAA,EAAQ,EAAE,IAAA,EAAM,UAAA,EAAY,cAAc,YAAA,EAAc,QAAA,EAAU,CAAA,EAAG,GAAG,CAAA,SAAA,CAAA,EAAY;AAAA,IACpF,eAAe,EAAE,SAAA,EAAW,SAAS,UAAA,EAAY,QAAA,EAAU,MAAM,OAAA;AAAQ,GAC3E;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA,IACE,WAAA,EAAa,YAAA;AAAA,IACb,MAAA,EAAQ,EAAE,IAAA,EAAM,UAAA,EAAY,cAAc,YAAA,EAAc,QAAA,EAAU,CAAA,EAAG,GAAG,CAAA,cAAA,CAAA,EAAiB;AAAA,IACzF,aAAA,EAAe,EAAE,YAAA,EAAc,YAAA,EAAc,MAAM,MAAA;AAAO,GAC5D;AAAA;AAAA;AAAA,EAGA;AAAA,IACE,WAAA,EAAa,SAAA;AAAA,IACb,MAAA,EAAQ,EAAE,IAAA,EAAM,UAAA,EAAY,cAAc,YAAA,EAAc,QAAA,EAAU,CAAA,EAAG,GAAG,CAAA,cAAA,CAAA,EAAiB;AAAA,IACzF,aAAA,EAAe,EAAE,YAAA,EAAc,SAAA,EAAW,MAAM,MAAA;AAAO,GACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA;AAAA,IACE,WAAA,EAAa,SAAA;AAAA,IACb,MAAA,EAAQ,EAAE,IAAA,EAAM,UAAA,EAAY,cAAc,YAAA,EAAc,QAAA,EAAU,CAAA,EAAG,GAAG,CAAA,cAAA,CAAA,EAAiB;AAAA,IACzF,aAAA,EAAe,EAAE,UAAA,EAAY,SAAA,EAAW,MAAM,MAAA;AAAO;AAEzD,CAAA;AAEO,MAAM,mBAAmB,CAAC,KAAA,EAAO,SAAS,CAAA,CAAE,QAAQ,+BAA+B;AAEnF,MAAM,kBAAA,GAAqB;AAAA,EAChC,iBAAA,EAAmB,6BAAA;AAAA,EACnB,qBAAA,EAAuB,iCAAA;AAAA,EACvB,kBAAA,EAAoB,8BAAA;AAAA,EACpB,kBAAA,EAAoB;AACtB;;;;"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const redisConfig = [
|
|
2
|
+
// redis `>=2.6.0 <4` (standalone `redis`). `internal_send_command` is an
|
|
3
|
+
// anonymous prototype assignment (`expressionName`); it settles via the nested
|
|
4
|
+
// `command_obj.callback`, so `kind: 'Sync'` and the subscriber wraps that callback.
|
|
5
|
+
{
|
|
6
|
+
channelName: "command",
|
|
7
|
+
module: { name: "redis", versionRange: ">=2.6.0 <4", filePath: "index.js" },
|
|
8
|
+
functionQuery: { expressionName: "internal_send_command", kind: "Sync" }
|
|
9
|
+
},
|
|
10
|
+
// node-redis v4 (`@redis/client` v1). The real chokepoint (private `#sendCommand`)
|
|
11
|
+
// isn't matchable, so wrap both public entry points: `commandsExecutor` (friendly
|
|
12
|
+
// commands) and `sendCommand` (direct calls). They never overlap, so no double span.
|
|
13
|
+
{
|
|
14
|
+
channelName: "executor",
|
|
15
|
+
module: { name: "@redis/client", versionRange: "^1.0.0", filePath: "dist/lib/client/index.js" },
|
|
16
|
+
functionQuery: { className: "RedisClient", methodName: "commandsExecutor", kind: "Async" }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
channelName: "command",
|
|
20
|
+
module: { name: "@redis/client", versionRange: "^1.0.0", filePath: "dist/lib/client/index.js" },
|
|
21
|
+
functionQuery: { className: "RedisClient", methodName: "sendCommand", kind: "Async" }
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
channelName: "connect",
|
|
25
|
+
module: { name: "@redis/client", versionRange: "^1.0.0", filePath: "dist/lib/client/index.js" },
|
|
26
|
+
functionQuery: { className: "RedisClient", methodName: "connect", kind: "Async" }
|
|
27
|
+
},
|
|
28
|
+
// node-redis `>=5.0.0 <5.12.0` (`@redis/client` v5; >=5.12.0 has its own
|
|
29
|
+
// `node-redis:*` diagnostics_channel, see `redis-dc-subscriber.ts`). Friendly
|
|
30
|
+
// commands route through the public `sendCommand`, so it covers them all — no
|
|
31
|
+
// `executor` entry (would double-count).
|
|
32
|
+
{
|
|
33
|
+
channelName: "command",
|
|
34
|
+
module: { name: "@redis/client", versionRange: ">=5.0.0 <5.12.0", filePath: "dist/lib/client/index.js" },
|
|
35
|
+
functionQuery: { className: "RedisClient", methodName: "sendCommand", kind: "Async" }
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
channelName: "connect",
|
|
39
|
+
module: { name: "@redis/client", versionRange: ">=5.0.0 <5.12.0", filePath: "dist/lib/client/index.js" },
|
|
40
|
+
functionQuery: { className: "RedisClient", methodName: "connect", kind: "Async" }
|
|
41
|
+
},
|
|
42
|
+
// Batch (multi/pipeline) — one span per `exec`. Batched commands bypass `sendCommand`,
|
|
43
|
+
// so they go through the client's batch executors, which receive the queued commands
|
|
44
|
+
// array (→ batch size). v5 splits MULTI/PIPELINE into two methods; v4's single
|
|
45
|
+
// `multiExecutor` is MULTI when a `chainId` arg is present, PIPELINE otherwise.
|
|
46
|
+
{
|
|
47
|
+
channelName: "multi",
|
|
48
|
+
module: { name: "@redis/client", versionRange: ">=5.0.0 <5.12.0", filePath: "dist/lib/client/index.js" },
|
|
49
|
+
functionQuery: { className: "RedisClient", methodName: "_executeMulti", kind: "Async" }
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
channelName: "pipeline",
|
|
53
|
+
module: { name: "@redis/client", versionRange: ">=5.0.0 <5.12.0", filePath: "dist/lib/client/index.js" },
|
|
54
|
+
functionQuery: { className: "RedisClient", methodName: "_executePipeline", kind: "Async" }
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
channelName: "batch",
|
|
58
|
+
module: { name: "@redis/client", versionRange: "^1.0.0", filePath: "dist/lib/client/index.js" },
|
|
59
|
+
functionQuery: { className: "RedisClient", methodName: "multiExecutor", kind: "Async" }
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
const redisChannels = {
|
|
63
|
+
REDIS_COMMAND: "orchestrion:redis:command",
|
|
64
|
+
NODE_REDIS_COMMAND: "orchestrion:@redis/client:command",
|
|
65
|
+
NODE_REDIS_EXECUTOR: "orchestrion:@redis/client:executor",
|
|
66
|
+
NODE_REDIS_CONNECT: "orchestrion:@redis/client:connect",
|
|
67
|
+
NODE_REDIS_MULTI: "orchestrion:@redis/client:multi",
|
|
68
|
+
NODE_REDIS_PIPELINE: "orchestrion:@redis/client:pipeline",
|
|
69
|
+
NODE_REDIS_BATCH: "orchestrion:@redis/client:batch"
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { redisChannels, redisConfig };
|
|
73
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.js","sources":["../../../../src/orchestrion/config/redis.ts"],"sourcesContent":["import type { InstrumentationConfig } from '@apm-js-collab/code-transformer';\n\nexport const redisConfig = [\n // redis `>=2.6.0 <4` (standalone `redis`). `internal_send_command` is an\n // anonymous prototype assignment (`expressionName`); it settles via the nested\n // `command_obj.callback`, so `kind: 'Sync'` and the subscriber wraps that callback.\n {\n channelName: 'command',\n module: { name: 'redis', versionRange: '>=2.6.0 <4', filePath: 'index.js' },\n functionQuery: { expressionName: 'internal_send_command', kind: 'Sync' },\n },\n // node-redis v4 (`@redis/client` v1). The real chokepoint (private `#sendCommand`)\n // isn't matchable, so wrap both public entry points: `commandsExecutor` (friendly\n // commands) and `sendCommand` (direct calls). They never overlap, so no double span.\n {\n channelName: 'executor',\n module: { name: '@redis/client', versionRange: '^1.0.0', filePath: 'dist/lib/client/index.js' },\n functionQuery: { className: 'RedisClient', methodName: 'commandsExecutor', kind: 'Async' },\n },\n {\n channelName: 'command',\n module: { name: '@redis/client', versionRange: '^1.0.0', filePath: 'dist/lib/client/index.js' },\n functionQuery: { className: 'RedisClient', methodName: 'sendCommand', kind: 'Async' },\n },\n {\n channelName: 'connect',\n module: { name: '@redis/client', versionRange: '^1.0.0', filePath: 'dist/lib/client/index.js' },\n functionQuery: { className: 'RedisClient', methodName: 'connect', kind: 'Async' },\n },\n // node-redis `>=5.0.0 <5.12.0` (`@redis/client` v5; >=5.12.0 has its own\n // `node-redis:*` diagnostics_channel, see `redis-dc-subscriber.ts`). Friendly\n // commands route through the public `sendCommand`, so it covers them all — no\n // `executor` entry (would double-count).\n {\n channelName: 'command',\n module: { name: '@redis/client', versionRange: '>=5.0.0 <5.12.0', filePath: 'dist/lib/client/index.js' },\n functionQuery: { className: 'RedisClient', methodName: 'sendCommand', kind: 'Async' },\n },\n {\n channelName: 'connect',\n module: { name: '@redis/client', versionRange: '>=5.0.0 <5.12.0', filePath: 'dist/lib/client/index.js' },\n functionQuery: { className: 'RedisClient', methodName: 'connect', kind: 'Async' },\n },\n // Batch (multi/pipeline) — one span per `exec`. Batched commands bypass `sendCommand`,\n // so they go through the client's batch executors, which receive the queued commands\n // array (→ batch size). v5 splits MULTI/PIPELINE into two methods; v4's single\n // `multiExecutor` is MULTI when a `chainId` arg is present, PIPELINE otherwise.\n {\n channelName: 'multi',\n module: { name: '@redis/client', versionRange: '>=5.0.0 <5.12.0', filePath: 'dist/lib/client/index.js' },\n functionQuery: { className: 'RedisClient', methodName: '_executeMulti', kind: 'Async' },\n },\n {\n channelName: 'pipeline',\n module: { name: '@redis/client', versionRange: '>=5.0.0 <5.12.0', filePath: 'dist/lib/client/index.js' },\n functionQuery: { className: 'RedisClient', methodName: '_executePipeline', kind: 'Async' },\n },\n {\n channelName: 'batch',\n module: { name: '@redis/client', versionRange: '^1.0.0', filePath: 'dist/lib/client/index.js' },\n functionQuery: { className: 'RedisClient', methodName: 'multiExecutor', kind: 'Async' },\n },\n] satisfies InstrumentationConfig[];\n\nexport const redisChannels = {\n REDIS_COMMAND: 'orchestrion:redis:command',\n NODE_REDIS_COMMAND: 'orchestrion:@redis/client:command',\n NODE_REDIS_EXECUTOR: 'orchestrion:@redis/client:executor',\n NODE_REDIS_CONNECT: 'orchestrion:@redis/client:connect',\n NODE_REDIS_MULTI: 'orchestrion:@redis/client:multi',\n NODE_REDIS_PIPELINE: 'orchestrion:@redis/client:pipeline',\n NODE_REDIS_BATCH: 'orchestrion:@redis/client:batch',\n} as const;\n"],"names":[],"mappings":"AAEO,MAAM,WAAA,GAAc;AAAA;AAAA;AAAA;AAAA,EAIzB;AAAA,IACE,WAAA,EAAa,SAAA;AAAA,IACb,QAAQ,EAAE,IAAA,EAAM,SAAS,YAAA,EAAc,YAAA,EAAc,UAAU,UAAA,EAAW;AAAA,IAC1E,aAAA,EAAe,EAAE,cAAA,EAAgB,uBAAA,EAAyB,MAAM,MAAA;AAAO,GACzE;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA,IACE,WAAA,EAAa,UAAA;AAAA,IACb,QAAQ,EAAE,IAAA,EAAM,iBAAiB,YAAA,EAAc,QAAA,EAAU,UAAU,0BAAA,EAA2B;AAAA,IAC9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A;AAAQ,GACxF;AAAA,EACA;AAAA,IACE,WAAA,EAAa,UAAA;AAAA,IACb,QAAQ,EAAE,IAAA,EAAM,iBAAiB,YAAA,EAAc,iBAAA,EAAmB,UAAU,0BAAA,EAA2B;AAAA,IACvG,eAAe,EAAE,SAAA,EAAW,eAAe,UAAA,EAAY,kBAAA,EAAoB,MAAM,OAAA;AAAQ,GAC3F;AAAA,EACA;AAAA,IACE,WAAA,EAAa,OAAA;AAAA,IACb,QAAQ,EAAE,IAAA,EAAM,iBAAiB,YAAA,EAAc,QAAA,EAAU,UAAU,0BAAA,EAA2B;AAAA,IAC9F,eAAe,EAAE,SAAA,EAAW,eAAe,UAAA,EAAY,eAAA,EAAiB,MAAM,OAAA;AAAQ;AAE1F;AAEO,MAAM,aAAA,GAAgB;AAAA,EAC3B,aAAA,EAAe,2BAAA;AAAA,EACf,kBAAA,EAAoB,mCAAA;AAAA,EACpB,mBAAA,EAAqB,oCAAA;AAAA,EACrB,kBAAA,EAAoB,mCAAA;AAAA,EACpB,gBAAA,EAAkB,iCAAA;AAAA,EAClB,mBAAA,EAAqB,oCAAA;AAAA,EACrB,gBAAA,EAAkB;AACpB;;;;"}
|
|
@@ -7,32 +7,36 @@ const vercelAiConfig = [
|
|
|
7
7
|
// `streamText` returns its result synchronously (streaming is lazy), so it's
|
|
8
8
|
// `Sync`; the subscriber binds the span via `bindTracingChannelToSpan`, which
|
|
9
9
|
// ends it when the (synchronous) call returns.
|
|
10
|
-
|
|
11
|
-
...
|
|
12
|
-
...
|
|
13
|
-
...
|
|
14
|
-
...
|
|
15
|
-
...
|
|
10
|
+
// The majority of entrypoints are present in all versions we support
|
|
11
|
+
...vercelAiEntries(">=4.0.0 <7.0.0", "generateText", "generateText", "Async"),
|
|
12
|
+
...vercelAiEntries(">=4.0.0 <7.0.0", "streamText", "streamText", "Sync"),
|
|
13
|
+
...vercelAiEntries(">=4.0.0 <7.0.0", "generateObject", "generateObject", "Async"),
|
|
14
|
+
...vercelAiEntries(">=4.0.0 <7.0.0", "embed", "embed", "Async"),
|
|
15
|
+
...vercelAiEntries(">=4.0.0 <7.0.0", "embedMany", "embedMany", "Async"),
|
|
16
|
+
// The following entry is only present in v5 and later
|
|
17
|
+
...vercelAiEntries(">=5.0.0 <7.0.0", "resolveLanguageModel", "resolveLanguageModel", "Sync"),
|
|
18
|
+
// The following entry is only present in v6 and later
|
|
19
|
+
...vercelAiEntries(">=6.0.0 <7.0.0", "executeToolCall", "executeToolCall", "Async")
|
|
16
20
|
];
|
|
17
21
|
const vercelAiChannels = {
|
|
18
|
-
// Vercel AI (`ai`)
|
|
22
|
+
// Vercel AI (`ai`): orchestrion injects these so the same channel-based
|
|
19
23
|
// integration that consumes `ai`'s native `ai:telemetry` channel (v7) can
|
|
20
|
-
// also instrument v6. Each maps to a top-level function in `ai`'s bundle.
|
|
24
|
+
// also instrument v4/v5/v6. Each maps to a top-level function in `ai`'s bundle.
|
|
25
|
+
// All three versions share the same channel names (the subscriber is version-agnostic);
|
|
26
|
+
// `VERCEL_AI_EXECUTE_TOOL_CALL` is v6-only (v4/v5 have no `executeToolCall` export) and
|
|
27
|
+
// `VERCEL_AI_RESOLVE_LANGUAGE_MODEL` is v5/v6-only (v4 has no such chokepoint).
|
|
21
28
|
VERCEL_AI_GENERATE_TEXT: "orchestrion:ai:generateText",
|
|
22
29
|
VERCEL_AI_STREAM_TEXT: "orchestrion:ai:streamText",
|
|
30
|
+
VERCEL_AI_GENERATE_OBJECT: "orchestrion:ai:generateObject",
|
|
23
31
|
VERCEL_AI_EMBED: "orchestrion:ai:embed",
|
|
24
32
|
VERCEL_AI_EMBED_MANY: "orchestrion:ai:embedMany",
|
|
25
33
|
VERCEL_AI_EXECUTE_TOOL_CALL: "orchestrion:ai:executeToolCall",
|
|
26
|
-
// `resolveLanguageModel` is the single chokepoint every model call flows
|
|
27
|
-
// through; we wrap it to monkey-patch `doGenerate`/`doStream` on the returned
|
|
28
|
-
// model (the model-call site itself is an inline call with no injectable
|
|
29
|
-
// definition).
|
|
30
34
|
VERCEL_AI_RESOLVE_LANGUAGE_MODEL: "orchestrion:ai:resolveLanguageModel"
|
|
31
35
|
};
|
|
32
|
-
function
|
|
36
|
+
function vercelAiEntries(versionRange, channelName, functionName, kind) {
|
|
33
37
|
return ["dist/index.js", "dist/index.mjs"].map((filePath) => ({
|
|
34
38
|
channelName,
|
|
35
|
-
module: { name: "ai", versionRange
|
|
39
|
+
module: { name: "ai", versionRange, filePath },
|
|
36
40
|
functionQuery: { functionName, kind }
|
|
37
41
|
}));
|
|
38
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-ai.js","sources":["../../../../src/orchestrion/config/vercel-ai.ts"],"sourcesContent":["import type { InstrumentationConfig } from '@apm-js-collab/code-transformer';\n\nexport const vercelAiConfig = [\n // Vercel AI v6: mirror the v7 native `ai:telemetry` channel by injecting\n // channels into the top-level entry points. `resolveLanguageModel` is wrapped\n // not to span it, but so the subscriber can monkey-patch `doGenerate`/\n // `doStream` on the returned model (the only way to span the model call,\n // which is an inline call with no injectable definition in `ai`).\n // `streamText` returns its result synchronously (streaming is lazy), so it's\n // `Sync`; the subscriber binds the span via `bindTracingChannelToSpan`, which\n // ends it when the (synchronous) call returns.\n ...
|
|
1
|
+
{"version":3,"file":"vercel-ai.js","sources":["../../../../src/orchestrion/config/vercel-ai.ts"],"sourcesContent":["import type { InstrumentationConfig } from '@apm-js-collab/code-transformer';\n\nexport const vercelAiConfig = [\n // Vercel AI v6: mirror the v7 native `ai:telemetry` channel by injecting\n // channels into the top-level entry points. `resolveLanguageModel` is wrapped\n // not to span it, but so the subscriber can monkey-patch `doGenerate`/\n // `doStream` on the returned model (the only way to span the model call,\n // which is an inline call with no injectable definition in `ai`).\n // `streamText` returns its result synchronously (streaming is lazy), so it's\n // `Sync`; the subscriber binds the span via `bindTracingChannelToSpan`, which\n // ends it when the (synchronous) call returns.\n\n // The majority of entrypoints are present in all versions we support\n ...vercelAiEntries('>=4.0.0 <7.0.0', 'generateText', 'generateText', 'Async'),\n ...vercelAiEntries('>=4.0.0 <7.0.0', 'streamText', 'streamText', 'Sync'),\n ...vercelAiEntries('>=4.0.0 <7.0.0', 'generateObject', 'generateObject', 'Async'),\n ...vercelAiEntries('>=4.0.0 <7.0.0', 'embed', 'embed', 'Async'),\n ...vercelAiEntries('>=4.0.0 <7.0.0', 'embedMany', 'embedMany', 'Async'),\n\n // The following entry is only present in v5 and later\n ...vercelAiEntries('>=5.0.0 <7.0.0', 'resolveLanguageModel', 'resolveLanguageModel', 'Sync'),\n\n // The following entry is only present in v6 and later\n ...vercelAiEntries('>=6.0.0 <7.0.0', 'executeToolCall', 'executeToolCall', 'Async'),\n] satisfies InstrumentationConfig[];\n\nexport const vercelAiChannels = {\n // Vercel AI (`ai`): orchestrion injects these so the same channel-based\n // integration that consumes `ai`'s native `ai:telemetry` channel (v7) can\n // also instrument v4/v5/v6. Each maps to a top-level function in `ai`'s bundle.\n // All three versions share the same channel names (the subscriber is version-agnostic);\n // `VERCEL_AI_EXECUTE_TOOL_CALL` is v6-only (v4/v5 have no `executeToolCall` export) and\n // `VERCEL_AI_RESOLVE_LANGUAGE_MODEL` is v5/v6-only (v4 has no such chokepoint).\n VERCEL_AI_GENERATE_TEXT: 'orchestrion:ai:generateText',\n VERCEL_AI_STREAM_TEXT: 'orchestrion:ai:streamText',\n VERCEL_AI_GENERATE_OBJECT: 'orchestrion:ai:generateObject',\n VERCEL_AI_EMBED: 'orchestrion:ai:embed',\n VERCEL_AI_EMBED_MANY: 'orchestrion:ai:embedMany',\n VERCEL_AI_EXECUTE_TOOL_CALL: 'orchestrion:ai:executeToolCall',\n VERCEL_AI_RESOLVE_LANGUAGE_MODEL: 'orchestrion:ai:resolveLanguageModel',\n} as const;\n\n/**\n * The central list of channel injections orchestrion should perform.\n *\n * This module has NO side effects — it's the only thing both the runtime hook\n * (`runtime/import-hook.mjs`) and the bundler plugins (`bundler/vite.ts`, …)\n * import from. Adding a new instrumented method is one entry here plus one\n * subscriber in `integrations/<lib>/tracing-channel.ts`.\n *\n * `channelName` here is the unprefixed suffix; the actual diagnostics_channel\n * name is `orchestrion:${module.name}:${channelName}` (see `channels.ts`).\n */\n/**\n * `ai` ships a single bundled entry per module system, so each instrumented\n * function needs one config entry per file (the app loads whichever matches its\n * module system). This expands a single target into both.\n */\nfunction vercelAiEntries(\n versionRange: string,\n channelName: string,\n functionName: string,\n kind: 'Async' | 'Sync',\n): InstrumentationConfig[] {\n return ['dist/index.js', 'dist/index.mjs'].map(filePath => ({\n channelName,\n module: { name: 'ai', versionRange, filePath },\n functionQuery: { functionName, kind },\n }));\n}\n"],"names":[],"mappings":"AAEO,MAAM,cAAA,GAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW5B,GAAG,eAAA,CAAgB,gBAAA,EAAkB,cAAA,EAAgB,gBAAgB,OAAO,CAAA;AAAA,EAC5E,GAAG,eAAA,CAAgB,gBAAA,EAAkB,YAAA,EAAc,cAAc,MAAM,CAAA;AAAA,EACvE,GAAG,eAAA,CAAgB,gBAAA,EAAkB,gBAAA,EAAkB,kBAAkB,OAAO,CAAA;AAAA,EAChF,GAAG,eAAA,CAAgB,gBAAA,EAAkB,OAAA,EAAS,SAAS,OAAO,CAAA;AAAA,EAC9D,GAAG,eAAA,CAAgB,gBAAA,EAAkB,WAAA,EAAa,aAAa,OAAO,CAAA;AAAA;AAAA,EAGtE,GAAG,eAAA,CAAgB,gBAAA,EAAkB,sBAAA,EAAwB,wBAAwB,MAAM,CAAA;AAAA;AAAA,EAG3F,GAAG,eAAA,CAAgB,gBAAA,EAAkB,iBAAA,EAAmB,mBAAmB,OAAO;AACpF;AAEO,MAAM,gBAAA,GAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO9B,uBAAA,EAAyB,6BAAA;AAAA,EACzB,qBAAA,EAAuB,2BAAA;AAAA,EACvB,yBAAA,EAA2B,+BAAA;AAAA,EAC3B,eAAA,EAAiB,sBAAA;AAAA,EACjB,oBAAA,EAAsB,0BAAA;AAAA,EACtB,2BAAA,EAA6B,gCAAA;AAAA,EAC7B,gCAAA,EAAkC;AACpC;AAkBA,SAAS,eAAA,CACP,YAAA,EACA,WAAA,EACA,YAAA,EACA,IAAA,EACyB;AACzB,EAAA,OAAO,CAAC,eAAA,EAAiB,gBAAgB,CAAA,CAAE,IAAI,CAAA,QAAA,MAAa;AAAA,IAC1D,WAAA;AAAA,IACA,MAAA,EAAQ,EAAE,IAAA,EAAM,IAAA,EAAM,cAAc,QAAA,EAAS;AAAA,IAC7C,aAAA,EAAe,EAAE,YAAA,EAAc,IAAA;AAAK,GACtC,CAAE,CAAA;AACJ;;;;"}
|
|
@@ -1,22 +1,34 @@
|
|
|
1
|
+
import { amqplibChannelIntegration } from '../integrations/tracing-channel/amqplib.js';
|
|
1
2
|
import { anthropicChannelIntegration } from '../integrations/tracing-channel/anthropic.js';
|
|
3
|
+
import { googleGenAIChannelIntegration } from '../integrations/tracing-channel/google-genai.js';
|
|
4
|
+
import { graphqlDiagnosticsChannelIntegration } from '../integrations/tracing-channel/graphql/index.js';
|
|
5
|
+
export { graphqlChannelIntegration } from '../integrations/tracing-channel/graphql/index.js';
|
|
2
6
|
import { hapiChannelIntegration } from '../integrations/tracing-channel/hapi.js';
|
|
3
7
|
export { ioredisChannelIntegration } from '../integrations/tracing-channel/ioredis.js';
|
|
4
8
|
import { lruMemoizerChannelIntegration } from '../integrations/tracing-channel/lru-memoizer.js';
|
|
5
9
|
import { mysqlChannelIntegration } from '../integrations/tracing-channel/mysql.js';
|
|
6
10
|
import { openaiChannelIntegration } from '../integrations/tracing-channel/openai.js';
|
|
7
11
|
import { postgresChannelIntegration } from '../integrations/tracing-channel/postgres.js';
|
|
12
|
+
import { postgresJsChannelIntegration } from '../integrations/tracing-channel/postgres-js.js';
|
|
8
13
|
import { vercelAiChannelIntegration } from '../integrations/tracing-channel/vercel-ai.js';
|
|
14
|
+
import { expressChannelIntegration } from '../integrations/tracing-channel/express/index.js';
|
|
9
15
|
export { detectOrchestrionSetup, isOrchestrionInjected } from './detect.js';
|
|
16
|
+
export { redisChannelIntegration } from '../integrations/tracing-channel/redis.js';
|
|
10
17
|
|
|
11
18
|
const channelIntegrations = {
|
|
12
19
|
postgresIntegration: postgresChannelIntegration,
|
|
20
|
+
postgresJsIntegration: postgresJsChannelIntegration,
|
|
13
21
|
mysqlIntegration: mysqlChannelIntegration,
|
|
14
22
|
lruMemoizerIntegration: lruMemoizerChannelIntegration,
|
|
15
23
|
openaiIntegration: openaiChannelIntegration,
|
|
16
24
|
anthropicIntegration: anthropicChannelIntegration,
|
|
25
|
+
googleGenAIIntegration: googleGenAIChannelIntegration,
|
|
17
26
|
vercelAiIntegration: vercelAiChannelIntegration,
|
|
18
|
-
|
|
27
|
+
amqplibIntegration: amqplibChannelIntegration,
|
|
28
|
+
hapiIntegration: hapiChannelIntegration,
|
|
29
|
+
expressIntegration: expressChannelIntegration,
|
|
30
|
+
graphqlIntegration: graphqlDiagnosticsChannelIntegration
|
|
19
31
|
};
|
|
20
32
|
|
|
21
|
-
export { anthropicChannelIntegration, channelIntegrations, hapiChannelIntegration, lruMemoizerChannelIntegration, mysqlChannelIntegration, openaiChannelIntegration, postgresChannelIntegration, vercelAiChannelIntegration };
|
|
33
|
+
export { amqplibChannelIntegration, anthropicChannelIntegration, channelIntegrations, expressChannelIntegration, googleGenAIChannelIntegration, hapiChannelIntegration, lruMemoizerChannelIntegration, mysqlChannelIntegration, openaiChannelIntegration, postgresChannelIntegration, postgresJsChannelIntegration, vercelAiChannelIntegration };
|
|
22
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/orchestrion/index.ts"],"sourcesContent":["import { anthropicChannelIntegration } from '../integrations/tracing-channel/anthropic';\nimport { hapiChannelIntegration } from '../integrations/tracing-channel/hapi';\nimport { ioredisChannelIntegration } from '../integrations/tracing-channel/ioredis';\nimport { lruMemoizerChannelIntegration } from '../integrations/tracing-channel/lru-memoizer';\nimport { mysqlChannelIntegration } from '../integrations/tracing-channel/mysql';\nimport { openaiChannelIntegration } from '../integrations/tracing-channel/openai';\nimport { postgresChannelIntegration } from '../integrations/tracing-channel/postgres';\nimport { vercelAiChannelIntegration } from '../integrations/tracing-channel/vercel-ai';\n\nexport { detectOrchestrionSetup, isOrchestrionInjected } from './detect';\nexport {\n anthropicChannelIntegration,\n hapiChannelIntegration,\n ioredisChannelIntegration,\n lruMemoizerChannelIntegration,\n mysqlChannelIntegration,\n openaiChannelIntegration,\n postgresChannelIntegration,\n vercelAiChannelIntegration,\n};\nexport type { IORedisChannelIntegrationOptions, IORedisResponseHook } from '../integrations/tracing-channel/ioredis';\n\n/**\n * The canonical set of orchestrion diagnostics-channel integrations, keyed by their public\n * (OTel-parity) factory name.\n *\n * Single source of truth: add a new channel integration here and every consumer — the `@sentry/node`\n * opt-in helper (`experimentalUseDiagnosticsChannelInjection`) and its public\n * `diagnosticsChannelInjectionIntegrations()` map — picks it up automatically, so there's no separate\n * list to keep in sync.\n *\n * NOTE: `ioredisChannelIntegration`
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/orchestrion/index.ts"],"sourcesContent":["import { amqplibChannelIntegration } from '../integrations/tracing-channel/amqplib';\nimport { anthropicChannelIntegration } from '../integrations/tracing-channel/anthropic';\nimport { googleGenAIChannelIntegration } from '../integrations/tracing-channel/google-genai';\nimport {\n graphqlChannelIntegration,\n graphqlDiagnosticsChannelIntegration,\n} from '../integrations/tracing-channel/graphql';\nimport { hapiChannelIntegration } from '../integrations/tracing-channel/hapi';\nimport { ioredisChannelIntegration } from '../integrations/tracing-channel/ioredis';\nimport { lruMemoizerChannelIntegration } from '../integrations/tracing-channel/lru-memoizer';\nimport { mysqlChannelIntegration } from '../integrations/tracing-channel/mysql';\nimport { openaiChannelIntegration } from '../integrations/tracing-channel/openai';\nimport { postgresChannelIntegration } from '../integrations/tracing-channel/postgres';\nimport { postgresJsChannelIntegration } from '../integrations/tracing-channel/postgres-js';\nimport { vercelAiChannelIntegration } from '../integrations/tracing-channel/vercel-ai';\nimport { expressChannelIntegration } from '../integrations/tracing-channel/express';\n\nexport { detectOrchestrionSetup, isOrchestrionInjected } from './detect';\nexport {\n amqplibChannelIntegration,\n anthropicChannelIntegration,\n googleGenAIChannelIntegration,\n graphqlChannelIntegration,\n hapiChannelIntegration,\n ioredisChannelIntegration,\n lruMemoizerChannelIntegration,\n mysqlChannelIntegration,\n openaiChannelIntegration,\n postgresChannelIntegration,\n postgresJsChannelIntegration,\n vercelAiChannelIntegration,\n expressChannelIntegration,\n};\nexport type { IORedisChannelIntegrationOptions, IORedisResponseHook } from '../integrations/tracing-channel/ioredis';\nexport type { PostgresJsChannelIntegrationOptions } from '../integrations/tracing-channel/postgres-js';\nexport { redisChannelIntegration } from '../integrations/tracing-channel/redis';\nexport type { RedisChannelIntegrationOptions, RedisResponseHook } from '../integrations/tracing-channel/redis';\n\n// The structural `graphql` package types are the single source of truth shared with `@sentry/node`'s\n// vendored OTel graphql instrumentation (re-exported from here so the two can't drift).\nexport type * from '../integrations/tracing-channel/graphql/graphql-types';\n\n/**\n * The canonical set of orchestrion diagnostics-channel integrations, keyed by their public\n * (OTel-parity) factory name.\n *\n * Single source of truth: add a new channel integration here and every consumer — the `@sentry/node`\n * opt-in helper (`experimentalUseDiagnosticsChannelInjection`) and its public\n * `diagnosticsChannelInjectionIntegrations()` map — picks it up automatically, so there's no separate\n * list to keep in sync.\n *\n * NOTE: `ioredisChannelIntegration` and `redisChannelIntegration` are intentionally NOT here. They\n * only partially replace the composite OTel `Redis` integration and need the node SDK's redis cache\n * `responseHook` (which can't live in `server-utils`), so `@sentry/node` wires them up separately.\n */\nexport const channelIntegrations = {\n postgresIntegration: postgresChannelIntegration,\n postgresJsIntegration: postgresJsChannelIntegration,\n mysqlIntegration: mysqlChannelIntegration,\n lruMemoizerIntegration: lruMemoizerChannelIntegration,\n openaiIntegration: openaiChannelIntegration,\n anthropicIntegration: anthropicChannelIntegration,\n googleGenAIIntegration: googleGenAIChannelIntegration,\n vercelAiIntegration: vercelAiChannelIntegration,\n amqplibIntegration: amqplibChannelIntegration,\n hapiIntegration: hapiChannelIntegration,\n expressIntegration: expressChannelIntegration,\n graphqlIntegration: graphqlDiagnosticsChannelIntegration,\n} as const;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuDO,MAAM,mBAAA,GAAsB;AAAA,EACjC,mBAAA,EAAqB,0BAAA;AAAA,EACrB,qBAAA,EAAuB,4BAAA;AAAA,EACvB,gBAAA,EAAkB,uBAAA;AAAA,EAClB,sBAAA,EAAwB,6BAAA;AAAA,EACxB,iBAAA,EAAmB,wBAAA;AAAA,EACnB,oBAAA,EAAsB,2BAAA;AAAA,EACtB,sBAAA,EAAwB,6BAAA;AAAA,EACxB,mBAAA,EAAqB,0BAAA;AAAA,EACrB,kBAAA,EAAoB,yBAAA;AAAA,EACpB,eAAA,EAAiB,sBAAA;AAAA,EACjB,kBAAA,EAAoB,yBAAA;AAAA,EACpB,kBAAA,EAAoB;AACtB;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.65.0","sideEffects":false}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineIntegration, waitForTracingChannelBinding } from '@sentry/core';
|
|
2
|
+
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
3
|
+
import { subscribeRedisDiagnosticChannels } from './redis-dc-subscriber.js';
|
|
4
|
+
|
|
5
|
+
const _redisIntegration = ((options = {}) => {
|
|
6
|
+
return {
|
|
7
|
+
name: "Redis",
|
|
8
|
+
setupOnce() {
|
|
9
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
waitForTracingChannelBinding(() => {
|
|
13
|
+
subscribeRedisDiagnosticChannels(diagnosticsChannel.tracingChannel, options.responseHook);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
const redisIntegration = defineIntegration(_redisIntegration);
|
|
19
|
+
|
|
20
|
+
export { redisIntegration };
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/redis/index.ts"],"sourcesContent":["import { defineIntegration, type IntegrationFn, waitForTracingChannelBinding } from '@sentry/core';\nimport * as dc from 'node:diagnostics_channel';\nimport { type RedisDiagnosticChannelResponseHook, subscribeRedisDiagnosticChannels } from './redis-dc-subscriber';\n\n/** Options controlling the redis diagnostics-channel subscription. */\nexport interface RedisDiagnosticChannelsOptions {\n /**\n * Optional hook invoked once the redis command response arrives. Useful for attaching\n * response-derived attributes (e.g. cache hit/miss, payload size).\n */\n responseHook?: RedisDiagnosticChannelResponseHook;\n}\n\nconst _redisIntegration = ((options: RedisDiagnosticChannelsOptions = {}) => {\n return {\n name: 'Redis',\n setupOnce() {\n // Bail on runtimes without `tracingChannel` (Node <= 18.18.0).\n if (!dc.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n subscribeRedisDiagnosticChannels(dc.tracingChannel, options.responseHook);\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Auto-instrument the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries via their native\n * `node:diagnostics_channel` tracing channels (node-redis >= 5.12.0, ioredis >= 5.11.0).\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":["dc"],"mappings":";;;;AAaA,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAA0C,EAAC,KAAM;AAC3E,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAACA,mBAAG,cAAA,EAAgB;AACtB,QAAA;AAAA,MACF;AAEA,MAAA,4BAAA,CAA6B,MAAM;AACjC,QAAA,gCAAA,CAAiCA,kBAAA,CAAG,cAAA,EAAgB,OAAA,CAAQ,YAAY,CAAA;AAAA,MAC1E,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAOO,MAAM,gBAAA,GAAmB,kBAAkB,iBAAiB;;;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SERVER_PORT, SERVER_ADDRESS, DB_QUERY_TEXT, DB_SYSTEM_NAME, DB_OPERATION_BATCH_SIZE } from '@sentry/conventions/attributes';
|
|
2
|
-
import {
|
|
3
|
-
import { DEBUG_BUILD } from '../debug-build.js';
|
|
2
|
+
import { startInactiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
4
3
|
import { bindTracingChannelToSpan } from '../tracing-channel.js';
|
|
5
4
|
|
|
6
5
|
const REDIS_DC_CHANNEL_COMMAND = "node-redis:command";
|
|
@@ -10,34 +9,24 @@ const IOREDIS_DC_CHANNEL_COMMAND = "ioredis:command";
|
|
|
10
9
|
const IOREDIS_DC_CHANNEL_CONNECT = "ioredis:connect";
|
|
11
10
|
const ORIGIN = "auto.db.redis.diagnostic_channel";
|
|
12
11
|
const DB_SYSTEM_NAME_VALUE_REDIS = "redis";
|
|
13
|
-
let subscribed = false;
|
|
14
|
-
let currentResponseHook;
|
|
15
|
-
let activeUnbinds = [];
|
|
16
12
|
function subscribeRedisDiagnosticChannels(tracingChannel, responseHook) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// on the per-command payload via `batchMode`/`batchSize`.
|
|
32
|
-
setupCommandChannel(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, (data) => data.args),
|
|
33
|
-
setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT)
|
|
34
|
-
);
|
|
35
|
-
} catch {
|
|
36
|
-
DEBUG_BUILD && debug.log("Redis node:diagnostics_channel subscription failed.");
|
|
37
|
-
}
|
|
13
|
+
setupCommandChannel(
|
|
14
|
+
tracingChannel,
|
|
15
|
+
REDIS_DC_CHANNEL_COMMAND,
|
|
16
|
+
(data) => data.args.slice(1),
|
|
17
|
+
responseHook
|
|
18
|
+
);
|
|
19
|
+
setupBatchChannel(
|
|
20
|
+
tracingChannel,
|
|
21
|
+
REDIS_DC_CHANNEL_BATCH,
|
|
22
|
+
(data) => data.batchMode === "PIPELINE" ? "PIPELINE" : "MULTI"
|
|
23
|
+
);
|
|
24
|
+
setupConnectChannel(tracingChannel, REDIS_DC_CHANNEL_CONNECT);
|
|
25
|
+
setupCommandChannel(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, (data) => data.args, responseHook);
|
|
26
|
+
setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT);
|
|
38
27
|
}
|
|
39
|
-
function setupCommandChannel(tracingChannel, channelName, getCommandArgs) {
|
|
40
|
-
|
|
28
|
+
function setupCommandChannel(tracingChannel, channelName, getCommandArgs, responseHook) {
|
|
29
|
+
bindTracingChannelToSpan(
|
|
41
30
|
tracingChannel(channelName),
|
|
42
31
|
(data) => {
|
|
43
32
|
const args = getCommandArgs(data);
|
|
@@ -60,13 +49,13 @@ function setupCommandChannel(tracingChannel, channelName, getCommandArgs) {
|
|
|
60
49
|
captureError: false,
|
|
61
50
|
beforeSpanEnd(span, data) {
|
|
62
51
|
if ("error" in data) return;
|
|
63
|
-
runResponseHook(span, data.command, getCommandArgs(data), data.result);
|
|
52
|
+
runResponseHook(responseHook, span, data.command, getCommandArgs(data), data.result);
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
|
-
)
|
|
55
|
+
);
|
|
67
56
|
}
|
|
68
57
|
function setupBatchChannel(tracingChannel, channelName, getOperationName) {
|
|
69
|
-
|
|
58
|
+
bindTracingChannelToSpan(
|
|
70
59
|
tracingChannel(channelName),
|
|
71
60
|
(data) => {
|
|
72
61
|
return startInactiveSpan({
|
|
@@ -84,10 +73,10 @@ function setupBatchChannel(tracingChannel, channelName, getOperationName) {
|
|
|
84
73
|
});
|
|
85
74
|
},
|
|
86
75
|
{ captureError: false }
|
|
87
|
-
)
|
|
76
|
+
);
|
|
88
77
|
}
|
|
89
78
|
function setupConnectChannel(tracingChannel, channelName) {
|
|
90
|
-
|
|
79
|
+
bindTracingChannelToSpan(
|
|
91
80
|
tracingChannel(channelName),
|
|
92
81
|
(data) => {
|
|
93
82
|
return startInactiveSpan({
|
|
@@ -102,10 +91,9 @@ function setupConnectChannel(tracingChannel, channelName) {
|
|
|
102
91
|
});
|
|
103
92
|
},
|
|
104
93
|
{ captureError: false }
|
|
105
|
-
)
|
|
94
|
+
);
|
|
106
95
|
}
|
|
107
|
-
function runResponseHook(span, command, args, result) {
|
|
108
|
-
const hook = currentResponseHook;
|
|
96
|
+
function runResponseHook(hook, span, command, args, result) {
|
|
109
97
|
if (!hook) return;
|
|
110
98
|
try {
|
|
111
99
|
hook(span, command, args, result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis-dc-subscriber.js","sources":["../../../src/redis/redis-dc-subscriber.ts"],"sourcesContent":["import type { TracingChannel } from 'node:diagnostics_channel';\nimport {\n DB_OPERATION_BATCH_SIZE,\n DB_QUERY_TEXT,\n DB_SYSTEM_NAME,\n SERVER_ADDRESS,\n SERVER_PORT,\n} from '@sentry/conventions/attributes';\nimport type { Span } from '@sentry/core';\nimport { debug, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startInactiveSpan } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { bindTracingChannelToSpan } from '../tracing-channel';\n\n// Channel names published by node-redis >= 5.12.0 and ioredis >= 5.11.0.\n// Hardcoded so the subscriber does not have to import either library — the\n// channels just have to be subscribed to before the user's redis code\n// publishes.\nexport const REDIS_DC_CHANNEL_COMMAND = 'node-redis:command';\nexport const REDIS_DC_CHANNEL_BATCH = 'node-redis:batch';\nexport const REDIS_DC_CHANNEL_CONNECT = 'node-redis:connect';\nexport const IOREDIS_DC_CHANNEL_COMMAND = 'ioredis:command';\nexport const IOREDIS_DC_CHANNEL_CONNECT = 'ioredis:connect';\n\nconst ORIGIN = 'auto.db.redis.diagnostic_channel';\nconst DB_SYSTEM_NAME_VALUE_REDIS = 'redis';\n\n/**\n * Shape of the `node-redis:command` channel payload published by node-redis.\n *\n * Both `command` and `args` are already redacted by node-redis itself (see\n * `sanitizeArgs` in @redis/client) using the OTel `redis-common` rules. The\n * arg array is `[<command>, <safe arg>, ..., '?', ...]` — `?` replaces any\n * value the library considers sensitive. Subscribers can emit `args` directly\n * as `db.query.text` without further serialization.\n */\nexport interface RedisCommandData {\n command: string;\n /** First arg is the command name itself; consumers should slice it off. */\n args: string[];\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/**\n * Shape of the `ioredis:command` channel payload published by ioredis >= 5.11.0.\n *\n * As with node-redis, args are already sanitized by ioredis (`sanitizeArgs` in\n * `lib/tracing.ts`) before publishing. Unlike node-redis, the command name is\n * NOT prepended to `args`.\n */\nexport interface IORedisCommandData {\n command: string;\n args: string[];\n batchMode?: 'MULTI';\n batchSize?: number;\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/** Shape of the `node-redis:batch` channel payload published by node-redis. */\nexport interface RedisBatchData {\n batchMode?: 'MULTI' | 'PIPELINE';\n batchSize?: number;\n database?: number;\n clientId?: string | number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown[];\n error?: Error;\n}\n\n/** Shape of the `*:connect` channel payload published by node-redis and ioredis. */\nexport interface RedisConnectData {\n serverAddress?: string;\n serverPort?: number;\n url?: string;\n error?: Error;\n}\n\n/**\n * Optional callback invoked once the redis command response arrives. Useful\n * for attaching response-derived attributes (e.g. cache hit/miss, payload size).\n *\n * Mirrors `@opentelemetry/instrumentation-ioredis`' response hook so existing\n * Sentry node code (`cacheResponseHook`) can be reused unchanged.\n */\nexport type RedisDiagnosticChannelResponseHook = (\n span: Span,\n cmdName: string,\n cmdArgs: string[],\n result: unknown,\n) => void;\n\n/**\n * Platform-provided factory that creates a native tracing channel for the given name. The\n * subscriber binds the span and its lifecycle onto the channel via `bindTracingChannelToSpan`,\n * which propagates the active span through the runtime's async context.\n *\n * Both Node and Deno pass `node:diagnostics_channel`'s `tracingChannel` directly.\n */\nexport type RedisTracingChannelFactory = <T extends object>(name: string) => TracingChannel<T, T>;\n\nlet subscribed = false;\nlet currentResponseHook: RedisDiagnosticChannelResponseHook | undefined;\nlet activeUnbinds: Array<() => void> = [];\n\n/**\n * Subscribe Sentry span handlers to node-redis and ioredis diagnostics-channel\n * events: `node-redis:command`/`:batch`/`:connect` (published by node-redis\n * >= 5.12.0) and `ioredis:command`/`:connect` (published by ioredis >= 5.11.0).\n *\n * On older client versions the channels are never published to, so subscribers\n * are inert — there is no double-instrumentation against any IITM-based\n * patcher gated to those older versions.\n *\n * Idempotent: subsequent calls update the response hook but do not\n * re-subscribe.\n */\nexport function subscribeRedisDiagnosticChannels(\n tracingChannel: RedisTracingChannelFactory,\n responseHook?: RedisDiagnosticChannelResponseHook,\n): void {\n currentResponseHook = responseHook;\n if (subscribed) return;\n subscribed = true;\n\n try {\n // node-redis: command name appears as args[0] in the channel payload, so\n // strip it before the statement and response hook see it.\n activeUnbinds.push(\n setupCommandChannel<RedisCommandData>(tracingChannel, REDIS_DC_CHANNEL_COMMAND, data => data.args.slice(1)),\n setupBatchChannel(tracingChannel, REDIS_DC_CHANNEL_BATCH, data =>\n data.batchMode === 'PIPELINE' ? 'PIPELINE' : 'MULTI',\n ),\n setupConnectChannel(tracingChannel, REDIS_DC_CHANNEL_CONNECT),\n // ioredis: args already exclude the command name; no slicing needed. And\n // ioredis has no separate batch channel — pipeline/MULTI metadata rides\n // on the per-command payload via `batchMode`/`batchSize`.\n setupCommandChannel<IORedisCommandData>(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, data => data.args),\n setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT),\n );\n } catch {\n // The factory may rely on `node:diagnostics_channel`, which isn't always\n // available. Fail closed; the SDK simply won't emit redis spans here.\n DEBUG_BUILD && debug.log('Redis node:diagnostics_channel subscription failed.');\n }\n}\n\nfunction setupCommandChannel<T extends RedisCommandData | IORedisCommandData>(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getCommandArgs: (data: T) => string[],\n): () => void {\n return bindTracingChannelToSpan(\n tracingChannel<T>(channelName),\n data => {\n // `args` is already sanitized by the publishing library (node-redis /\n // ioredis call their own `sanitizeArgs` before publishing). Join with\n // spaces to mirror the format the libraries themselves intend.\n const args = getCommandArgs(data);\n const statement = args.length ? `${data.command} ${args.join(' ')}` : data.command;\n return startInactiveSpan({\n name: `redis-${data.command}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n [DB_QUERY_TEXT]: statement,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n {\n // Command failures are surfaced to (and usually handled by) the caller; only annotate the\n // span so we don't emit a duplicate error event for every failed command.\n captureError: false,\n beforeSpanEnd(span, data) {\n if ('error' in data) return;\n runResponseHook(span, data.command, getCommandArgs(data), data.result);\n },\n },\n ).unbind;\n}\n\nfunction setupBatchChannel(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getOperationName: (data: RedisBatchData) => string,\n): () => void {\n return bindTracingChannelToSpan(\n tracingChannel<RedisBatchData>(channelName),\n data => {\n return startInactiveSpan({\n name: getOperationName(data),\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n // should only include batch size greater than 1,\n // or else it isn't properly considered a \"batch\"\n ...(Number(data.batchSize) > 1 ? { [DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n { captureError: false },\n ).unbind;\n}\n\nfunction setupConnectChannel(tracingChannel: RedisTracingChannelFactory, channelName: string): () => void {\n return bindTracingChannelToSpan(\n tracingChannel<RedisConnectData>(channelName),\n data => {\n return startInactiveSpan({\n name: 'redis-connect',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n { captureError: false },\n ).unbind;\n}\n\nfunction runResponseHook(span: Span, command: string, args: string[], result: unknown): void {\n const hook = currentResponseHook;\n if (!hook) return;\n try {\n hook(span, command, args, result);\n } catch {\n // never let user hooks break instrumentation\n }\n}\n\n/** Test-only: detach all channel bindings and reset module-local subscribe state. */\nexport function _resetRedisDiagnosticChannelsForTesting(): void {\n activeUnbinds.forEach(unbind => unbind());\n activeUnbinds = [];\n subscribed = false;\n currentResponseHook = undefined;\n}\n"],"names":[],"mappings":";;;;;AAiBO,MAA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;AACJ;AAEA,SAAS,eAAA,CAAgB,IAAA,EAAY,OAAA,EAAiB,IAAA,EAAgB,MAAA,EAAuB;AAC3F,EAAA,MAAM,IAAA,GAAO,mBAAA;AACb,EAAA,IAAI,CAAC,IAAA,EAAM;AACX,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,MAAM,CAAA;AAAA,EAClC,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"redis-dc-subscriber.js","sources":["../../../src/redis/redis-dc-subscriber.ts"],"sourcesContent":["import type { TracingChannel } from 'node:diagnostics_channel';\nimport {\n DB_OPERATION_BATCH_SIZE,\n DB_QUERY_TEXT,\n DB_SYSTEM_NAME,\n SERVER_ADDRESS,\n SERVER_PORT,\n} from '@sentry/conventions/attributes';\nimport type { Span } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startInactiveSpan } from '@sentry/core';\nimport { bindTracingChannelToSpan } from '../tracing-channel';\n\n// Channel names published by node-redis >= 5.12.0 and ioredis >= 5.11.0.\n// Hardcoded so the subscriber does not have to import either library — the\n// channels just have to be subscribed to before the user's redis code\n// publishes.\nexport const REDIS_DC_CHANNEL_COMMAND = 'node-redis:command';\nexport const REDIS_DC_CHANNEL_BATCH = 'node-redis:batch';\nexport const REDIS_DC_CHANNEL_CONNECT = 'node-redis:connect';\nexport const IOREDIS_DC_CHANNEL_COMMAND = 'ioredis:command';\nexport const IOREDIS_DC_CHANNEL_CONNECT = 'ioredis:connect';\n\nconst ORIGIN = 'auto.db.redis.diagnostic_channel';\nconst DB_SYSTEM_NAME_VALUE_REDIS = 'redis';\n\n/**\n * Shape of the `node-redis:command` channel payload published by node-redis.\n *\n * Both `command` and `args` are already redacted by node-redis itself (see\n * `sanitizeArgs` in @redis/client) using the OTel `redis-common` rules. The\n * arg array is `[<command>, <safe arg>, ..., '?', ...]` — `?` replaces any\n * value the library considers sensitive. Subscribers can emit `args` directly\n * as `db.query.text` without further serialization.\n */\nexport interface RedisCommandData {\n command: string;\n /** First arg is the command name itself; consumers should slice it off. */\n args: string[];\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/**\n * Shape of the `ioredis:command` channel payload published by ioredis >= 5.11.0.\n *\n * As with node-redis, args are already sanitized by ioredis (`sanitizeArgs` in\n * `lib/tracing.ts`) before publishing. Unlike node-redis, the command name is\n * NOT prepended to `args`.\n */\nexport interface IORedisCommandData {\n command: string;\n args: string[];\n batchMode?: 'MULTI';\n batchSize?: number;\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/** Shape of the `node-redis:batch` channel payload published by node-redis. */\nexport interface RedisBatchData {\n batchMode?: 'MULTI' | 'PIPELINE';\n batchSize?: number;\n database?: number;\n clientId?: string | number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown[];\n error?: Error;\n}\n\n/** Shape of the `*:connect` channel payload published by node-redis and ioredis. */\nexport interface RedisConnectData {\n serverAddress?: string;\n serverPort?: number;\n url?: string;\n error?: Error;\n}\n\n/**\n * Optional callback invoked once the redis command response arrives. Useful\n * for attaching response-derived attributes (e.g. cache hit/miss, payload size).\n *\n * Mirrors `@opentelemetry/instrumentation-ioredis`' response hook so existing\n * Sentry node code (`cacheResponseHook`) can be reused unchanged.\n */\nexport type RedisDiagnosticChannelResponseHook = (\n span: Span,\n cmdName: string,\n cmdArgs: string[],\n result: unknown,\n) => void;\n\n/**\n * Platform-provided factory that creates a native tracing channel for the given name. The\n * subscriber binds the span and its lifecycle onto the channel via `bindTracingChannelToSpan`,\n * which propagates the active span through the runtime's async context.\n *\n * Both Node and Deno pass `node:diagnostics_channel`'s `tracingChannel` directly.\n */\nexport type RedisTracingChannelFactory = <T extends object>(name: string) => TracingChannel<T, T>;\n\n/**\n * Subscribe Sentry span handlers to node-redis and ioredis diagnostics-channel\n * events: `node-redis:command`/`:batch`/`:connect` (published by node-redis\n * >= 5.12.0) and `ioredis:command`/`:connect` (published by ioredis >= 5.11.0).\n *\n * On older client versions the channels are never published to, so subscribers\n * are inert — there is no double-instrumentation against any IITM-based\n * patcher gated to those older versions.\n */\nexport function subscribeRedisDiagnosticChannels(\n tracingChannel: RedisTracingChannelFactory,\n responseHook?: RedisDiagnosticChannelResponseHook,\n): void {\n // node-redis: command name appears as args[0] in the channel payload, so\n // strip it before the statement and response hook see it.\n setupCommandChannel<RedisCommandData>(\n tracingChannel,\n REDIS_DC_CHANNEL_COMMAND,\n data => data.args.slice(1),\n responseHook,\n );\n setupBatchChannel(tracingChannel, REDIS_DC_CHANNEL_BATCH, data =>\n data.batchMode === 'PIPELINE' ? 'PIPELINE' : 'MULTI',\n );\n setupConnectChannel(tracingChannel, REDIS_DC_CHANNEL_CONNECT);\n // ioredis: args already exclude the command name; no slicing needed. And\n // ioredis has no separate batch channel — pipeline/MULTI metadata rides\n // on the per-command payload via `batchMode`/`batchSize`.\n setupCommandChannel<IORedisCommandData>(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, data => data.args, responseHook);\n setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT);\n}\n\nfunction setupCommandChannel<T extends RedisCommandData | IORedisCommandData>(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getCommandArgs: (data: T) => string[],\n responseHook?: RedisDiagnosticChannelResponseHook,\n): void {\n bindTracingChannelToSpan(\n tracingChannel<T>(channelName),\n data => {\n // `args` is already sanitized by the publishing library (node-redis /\n // ioredis call their own `sanitizeArgs` before publishing). Join with\n // spaces to mirror the format the libraries themselves intend.\n const args = getCommandArgs(data);\n const statement = args.length ? `${data.command} ${args.join(' ')}` : data.command;\n return startInactiveSpan({\n name: `redis-${data.command}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n [DB_QUERY_TEXT]: statement,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n {\n // Command failures are surfaced to (and usually handled by) the caller; only annotate the\n // span so we don't emit a duplicate error event for every failed command.\n captureError: false,\n beforeSpanEnd(span, data) {\n if ('error' in data) return;\n runResponseHook(responseHook, span, data.command, getCommandArgs(data), data.result);\n },\n },\n );\n}\n\nfunction setupBatchChannel(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getOperationName: (data: RedisBatchData) => string,\n): void {\n bindTracingChannelToSpan(\n tracingChannel<RedisBatchData>(channelName),\n data => {\n return startInactiveSpan({\n name: getOperationName(data),\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n // should only include batch size greater than 1,\n // or else it isn't properly considered a \"batch\"\n ...(Number(data.batchSize) > 1 ? { [DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n { captureError: false },\n );\n}\n\nfunction setupConnectChannel(tracingChannel: RedisTracingChannelFactory, channelName: string): void {\n bindTracingChannelToSpan(\n tracingChannel<RedisConnectData>(channelName),\n data => {\n return startInactiveSpan({\n name: 'redis-connect',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n { captureError: false },\n );\n}\n\nfunction runResponseHook(\n hook: RedisDiagnosticChannelResponseHook | undefined,\n span: Span,\n command: string,\n args: string[],\n result: unknown,\n): void {\n if (!hook) return;\n try {\n hook(span, command, args, result);\n } catch {\n // never let user hooks break instrumentation\n }\n}\n"],"names":[],"mappings":";;;;AAgBO,MAAM,wBAAA,GAA2B;AACjC,MAAM,sBAAA,GAAyB;AAC/B,MAAM,wBAAA,GAA2B;AACjC,MAAM,0BAAA,GAA6B;AACnC,MAAM,0BAAA,GAA6B;AAE1C,MAAM,MAAA,GAAS,kCAAA;AACf,MAAM,0BAAA,GAA6B,OAAA;AA6F5B,SAAS,gCAAA,CACd,gBACA,YAAA,EACM;AAGN,EAAA,mBAAA;AAAA,IACE,cAAA;AAAA,IACA,wBAAA;AAAA,IACA,CAAA,IAAA,KAAQ,IAAA,CAAK,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AAAA,IACzB;AAAA,GACF;AACA,EAAA,iBAAA;AAAA,IAAkB,cAAA;AAAA,IAAgB,sBAAA;AAAA,IAAwB,CAAA,IAAA,KACxD,IAAA,CAAK,SAAA,KAAc,UAAA,GAAa,UAAA,GAAa;AAAA,GAC/C;AACA,EAAA,mBAAA,CAAoB,gBAAgB,wBAAwB,CAAA;AAI5D,EAAA,mBAAA,CAAwC,cAAA,EAAgB,0BAAA,EAA4B,CAAA,IAAA,KAAQ,IAAA,CAAK,MAAM,YAAY,CAAA;AACnH,EAAA,mBAAA,CAAoB,gBAAgB,0BAA0B,CAAA;AAChE;AAEA,SAAS,mBAAA,CACP,cAAA,EACA,WAAA,EACA,cAAA,EACA,YAAA,EACM;AACN,EAAA,wBAAA;AAAA,IACE,eAAkB,WAAW,CAAA;AAAA,IAC7B,CAAA,IAAA,KAAQ;AAIN,MAAA,MAAM,IAAA,GAAO,eAAe,IAAI,CAAA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,EACA,IAAA,EACA,OAAA,EACA,MACA,MAAA,EACM;AACN,EAAA,IAAI,CAAC,IAAA,EAAM;AACX,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,MAAM,CAAA;AAAA,EAClC,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getAsyncContextStrategy, getMainCarrier, debug,
|
|
1
|
+
import { getAsyncContextStrategy, getMainCarrier, debug, getActiveSpan, captureException, SPAN_STATUS_ERROR, isObjectLike } from '@sentry/core';
|
|
2
2
|
import { DEBUG_BUILD } from './debug-build.js';
|
|
3
3
|
import { ERROR_TYPE } from '@sentry/conventions/attributes';
|
|
4
4
|
|
|
5
5
|
const NOOP = () => {
|
|
6
6
|
};
|
|
7
7
|
function bindTracingChannelToSpan(channel, getSpan, opts) {
|
|
8
|
-
const handle = bindSpanToChannelStore(channel, getSpan);
|
|
8
|
+
const handle = bindSpanToChannelStore(channel, getSpan, opts);
|
|
9
9
|
const beforeSpanEnd = opts?.beforeSpanEnd;
|
|
10
10
|
const deferSpanEnd = opts?.deferSpanEnd;
|
|
11
11
|
const getErrorHint = (e) => {
|
|
@@ -76,7 +76,7 @@ function bindTracingChannelToSpan(channel, getSpan, opts) {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
-
function bindSpanToChannelStore(channel, getSpan) {
|
|
79
|
+
function bindSpanToChannelStore(channel, getSpan, opts) {
|
|
80
80
|
const binding = getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.();
|
|
81
81
|
if (!binding) {
|
|
82
82
|
DEBUG_BUILD && debug.log("[TracingChannel] Could not access async context binding.");
|
|
@@ -88,7 +88,8 @@ function bindSpanToChannelStore(channel, getSpan) {
|
|
|
88
88
|
const asyncLocalStorage = binding.asyncLocalStorage;
|
|
89
89
|
channel.start.bindStore(asyncLocalStorage, (data) => {
|
|
90
90
|
data._sentryCallerStore = asyncLocalStorage.getStore();
|
|
91
|
-
const
|
|
91
|
+
const shouldGetSpan = !opts?.requiresParentSpan || getActiveSpan();
|
|
92
|
+
const span = shouldGetSpan ? getSpan(data) : void 0;
|
|
92
93
|
if (!span) {
|
|
93
94
|
return data._sentryCallerStore;
|
|
94
95
|
}
|
|
@@ -115,10 +116,10 @@ function endBoundSpan(data, beforeSpanEnd) {
|
|
|
115
116
|
span.end();
|
|
116
117
|
}
|
|
117
118
|
function getErrorInfo(error) {
|
|
118
|
-
const
|
|
119
|
-
const raw =
|
|
119
|
+
const errorIsObject = isObjectLike(error);
|
|
120
|
+
const raw = errorIsObject ? "message" in error ? error.message : void 0 : error;
|
|
120
121
|
const message = raw ? String(raw) : void 0;
|
|
121
|
-
const type =
|
|
122
|
+
const type = errorIsObject && "name" in error ? String(error.name) : "unknown";
|
|
122
123
|
return {
|
|
123
124
|
message,
|
|
124
125
|
attributes: {
|