@sentry/server-utils 10.65.0 → 10.66.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 +2 -4
- package/build/cjs/graphql/graphql-dc-subscriber.js.map +1 -1
- package/build/cjs/graphql/utils.js +7 -1
- package/build/cjs/graphql/utils.js.map +1 -1
- package/build/cjs/index.js +11 -8
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/dataloader.js +95 -0
- package/build/cjs/integrations/tracing-channel/dataloader.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/generic-pool.js +34 -0
- package/build/cjs/integrations/tracing-channel/generic-pool.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/graphql/spans.js +2 -2
- package/build/cjs/integrations/tracing-channel/graphql/spans.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/ioredis.js +29 -26
- package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/kafkajs/consumer.js +71 -0
- package/build/cjs/integrations/tracing-channel/kafkajs/consumer.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/kafkajs/index.js +70 -0
- package/build/cjs/integrations/tracing-channel/kafkajs/index.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/kafkajs/semconv.js +22 -0
- package/build/cjs/integrations/tracing-channel/kafkajs/semconv.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/kafkajs/spans.js +119 -0
- package/build/cjs/integrations/tracing-channel/kafkajs/spans.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/knex.js +188 -0
- package/build/cjs/integrations/tracing-channel/knex.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/mysql2.js +83 -0
- package/build/cjs/integrations/tracing-channel/mysql2.js.map +1 -0
- package/build/cjs/orchestrion/bundler/esbuild.js +11 -0
- package/build/cjs/orchestrion/bundler/esbuild.js.map +1 -0
- package/build/cjs/orchestrion/bundler/options.js +15 -0
- package/build/cjs/orchestrion/bundler/options.js.map +1 -0
- package/build/cjs/orchestrion/bundler/rollup.js +11 -0
- package/build/cjs/orchestrion/bundler/rollup.js.map +1 -0
- package/build/cjs/orchestrion/bundler/vite.js +4 -21
- package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
- package/build/cjs/orchestrion/bundler/webpack.js +32 -0
- package/build/cjs/orchestrion/bundler/webpack.js.map +1 -0
- package/build/cjs/orchestrion/channels.js +50 -20
- package/build/cjs/orchestrion/channels.js.map +1 -1
- package/build/cjs/orchestrion/config/dataloader.js +53 -0
- package/build/cjs/orchestrion/config/dataloader.js.map +1 -0
- package/build/cjs/orchestrion/config/firebase.js +8 -0
- package/build/cjs/orchestrion/config/firebase.js.map +1 -0
- package/build/cjs/orchestrion/config/generic-pool.js +21 -0
- package/build/cjs/orchestrion/config/generic-pool.js.map +1 -0
- package/build/cjs/orchestrion/config/index.js +55 -23
- package/build/cjs/orchestrion/config/index.js.map +1 -1
- package/build/cjs/orchestrion/config/kafkajs.js +30 -0
- package/build/cjs/orchestrion/config/kafkajs.js.map +1 -0
- package/build/cjs/orchestrion/config/knex.js +43 -0
- package/build/cjs/orchestrion/config/knex.js.map +1 -0
- package/build/cjs/orchestrion/config/langchain.js +8 -0
- package/build/cjs/orchestrion/config/langchain.js.map +1 -0
- package/build/cjs/orchestrion/config/langgraph.js +8 -0
- package/build/cjs/orchestrion/config/langgraph.js.map +1 -0
- package/build/cjs/orchestrion/config/mongodb.js +8 -0
- package/build/cjs/orchestrion/config/mongodb.js.map +1 -0
- package/build/cjs/orchestrion/config/mongoose.js +8 -0
- package/build/cjs/orchestrion/config/mongoose.js.map +1 -0
- package/build/cjs/orchestrion/config/mysql2.js +32 -0
- package/build/cjs/orchestrion/config/mysql2.js.map +1 -0
- package/build/cjs/orchestrion/config/nestjs.js +122 -0
- package/build/cjs/orchestrion/config/nestjs.js.map +1 -0
- package/build/cjs/orchestrion/config/prisma.js +8 -0
- package/build/cjs/orchestrion/config/prisma.js.map +1 -0
- package/build/cjs/orchestrion/config/react-router.js +8 -0
- package/build/cjs/orchestrion/config/react-router.js.map +1 -0
- package/build/cjs/orchestrion/config/remix.js +8 -0
- package/build/cjs/orchestrion/config/remix.js.map +1 -0
- package/build/cjs/orchestrion/config/tedious.js +8 -0
- package/build/cjs/orchestrion/config/tedious.js.map +1 -0
- package/build/cjs/orchestrion/detect.js +12 -11
- package/build/cjs/orchestrion/detect.js.map +1 -1
- package/build/cjs/orchestrion/index.js +16 -1
- package/build/cjs/orchestrion/index.js.map +1 -1
- package/build/cjs/orchestrion/runtime/register.js +25 -14
- package/build/cjs/orchestrion/runtime/register.js.map +1 -1
- package/build/cjs/prisma/global.js +14 -0
- package/build/cjs/prisma/global.js.map +1 -0
- package/build/cjs/prisma/index.js +27 -0
- package/build/cjs/prisma/index.js.map +1 -0
- package/build/cjs/prisma/tracing-helper.js +211 -0
- package/build/cjs/prisma/tracing-helper.js.map +1 -0
- package/build/cjs/vercel-ai/util.js +0 -11
- package/build/cjs/vercel-ai/util.js.map +1 -1
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +9 -9
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/esm/graphql/graphql-dc-subscriber.js +3 -5
- package/build/esm/graphql/graphql-dc-subscriber.js.map +1 -1
- package/build/esm/graphql/utils.js +8 -2
- package/build/esm/graphql/utils.js.map +1 -1
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/tracing-channel/dataloader.js +93 -0
- package/build/esm/integrations/tracing-channel/dataloader.js.map +1 -0
- package/build/esm/integrations/tracing-channel/generic-pool.js +32 -0
- package/build/esm/integrations/tracing-channel/generic-pool.js.map +1 -0
- package/build/esm/integrations/tracing-channel/graphql/spans.js +3 -3
- package/build/esm/integrations/tracing-channel/graphql/spans.js.map +1 -1
- package/build/esm/integrations/tracing-channel/ioredis.js +29 -27
- package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -1
- package/build/esm/integrations/tracing-channel/kafkajs/consumer.js +67 -0
- package/build/esm/integrations/tracing-channel/kafkajs/consumer.js.map +1 -0
- package/build/esm/integrations/tracing-channel/kafkajs/index.js +68 -0
- package/build/esm/integrations/tracing-channel/kafkajs/index.js.map +1 -0
- package/build/esm/integrations/tracing-channel/kafkajs/semconv.js +12 -0
- package/build/esm/integrations/tracing-channel/kafkajs/semconv.js.map +1 -0
- package/build/esm/integrations/tracing-channel/kafkajs/spans.js +112 -0
- package/build/esm/integrations/tracing-channel/kafkajs/spans.js.map +1 -0
- package/build/esm/integrations/tracing-channel/knex.js +186 -0
- package/build/esm/integrations/tracing-channel/knex.js.map +1 -0
- package/build/esm/integrations/tracing-channel/mysql2.js +81 -0
- package/build/esm/integrations/tracing-channel/mysql2.js.map +1 -0
- package/build/esm/orchestrion/bundler/esbuild.js +9 -0
- package/build/esm/orchestrion/bundler/esbuild.js.map +1 -0
- package/build/esm/orchestrion/bundler/options.js +13 -0
- package/build/esm/orchestrion/bundler/options.js.map +1 -0
- package/build/esm/orchestrion/bundler/rollup.js +9 -0
- package/build/esm/orchestrion/bundler/rollup.js.map +1 -0
- package/build/esm/orchestrion/bundler/vite.js +5 -22
- package/build/esm/orchestrion/bundler/vite.js.map +1 -1
- package/build/esm/orchestrion/bundler/webpack.js +27 -0
- package/build/esm/orchestrion/bundler/webpack.js.map +1 -0
- package/build/esm/orchestrion/channels.js +50 -20
- package/build/esm/orchestrion/channels.js.map +1 -1
- package/build/esm/orchestrion/config/dataloader.js +50 -0
- package/build/esm/orchestrion/config/dataloader.js.map +1 -0
- package/build/esm/orchestrion/config/firebase.js +5 -0
- package/build/esm/orchestrion/config/firebase.js.map +1 -0
- package/build/esm/orchestrion/config/generic-pool.js +18 -0
- package/build/esm/orchestrion/config/generic-pool.js.map +1 -0
- package/build/esm/orchestrion/config/index.js +55 -24
- package/build/esm/orchestrion/config/index.js.map +1 -1
- package/build/esm/orchestrion/config/kafkajs.js +27 -0
- package/build/esm/orchestrion/config/kafkajs.js.map +1 -0
- package/build/esm/orchestrion/config/knex.js +40 -0
- package/build/esm/orchestrion/config/knex.js.map +1 -0
- package/build/esm/orchestrion/config/langchain.js +5 -0
- package/build/esm/orchestrion/config/langchain.js.map +1 -0
- package/build/esm/orchestrion/config/langgraph.js +5 -0
- package/build/esm/orchestrion/config/langgraph.js.map +1 -0
- package/build/esm/orchestrion/config/mongodb.js +5 -0
- package/build/esm/orchestrion/config/mongodb.js.map +1 -0
- package/build/esm/orchestrion/config/mongoose.js +5 -0
- package/build/esm/orchestrion/config/mongoose.js.map +1 -0
- package/build/esm/orchestrion/config/mysql2.js +29 -0
- package/build/esm/orchestrion/config/mysql2.js.map +1 -0
- package/build/esm/orchestrion/config/nestjs.js +119 -0
- package/build/esm/orchestrion/config/nestjs.js.map +1 -0
- package/build/esm/orchestrion/config/prisma.js +5 -0
- package/build/esm/orchestrion/config/prisma.js.map +1 -0
- package/build/esm/orchestrion/config/react-router.js +5 -0
- package/build/esm/orchestrion/config/react-router.js.map +1 -0
- package/build/esm/orchestrion/config/remix.js +5 -0
- package/build/esm/orchestrion/config/remix.js.map +1 -0
- package/build/esm/orchestrion/config/tedious.js +5 -0
- package/build/esm/orchestrion/config/tedious.js.map +1 -0
- package/build/esm/orchestrion/detect.js +13 -12
- package/build/esm/orchestrion/detect.js.map +1 -1
- package/build/esm/orchestrion/index.js +11 -2
- package/build/esm/orchestrion/index.js.map +1 -1
- package/build/esm/orchestrion/runtime/register.js +27 -16
- package/build/esm/orchestrion/runtime/register.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/prisma/global.js +12 -0
- package/build/esm/prisma/global.js.map +1 -0
- package/build/esm/prisma/index.js +24 -0
- package/build/esm/prisma/index.js.map +1 -0
- package/build/esm/prisma/tracing-helper.js +209 -0
- package/build/esm/prisma/tracing-helper.js.map +1 -0
- package/build/esm/vercel-ai/util.js +1 -11
- package/build/esm/vercel-ai/util.js.map +1 -1
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +11 -11
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/types/graphql/utils.d.ts +2 -6
- package/build/types/graphql/utils.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/dataloader.d.ts +11 -0
- package/build/types/integrations/tracing-channel/dataloader.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/generic-pool.d.ts +10 -0
- package/build/types/integrations/tracing-channel/generic-pool.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/ioredis.d.ts +20 -0
- package/build/types/integrations/tracing-channel/ioredis.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/kafkajs/consumer.d.ts +8 -0
- package/build/types/integrations/tracing-channel/kafkajs/consumer.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/kafkajs/index.d.ts +17 -0
- package/build/types/integrations/tracing-channel/kafkajs/index.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/kafkajs/semconv.d.ts +10 -0
- package/build/types/integrations/tracing-channel/kafkajs/semconv.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/kafkajs/spans.d.ts +38 -0
- package/build/types/integrations/tracing-channel/kafkajs/spans.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/kafkajs/types.d.ts +40 -0
- package/build/types/integrations/tracing-channel/kafkajs/types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/knex.d.ts +11 -0
- package/build/types/integrations/tracing-channel/knex.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/mysql2.d.ts +15 -0
- package/build/types/integrations/tracing-channel/mysql2.d.ts.map +1 -0
- package/build/types/orchestrion/bundler/esbuild.d.ts +21 -0
- package/build/types/orchestrion/bundler/esbuild.d.ts.map +1 -0
- package/build/types/orchestrion/bundler/options.d.ts +19 -0
- package/build/types/orchestrion/bundler/options.d.ts.map +1 -0
- package/build/types/orchestrion/bundler/rollup.d.ts +17 -0
- package/build/types/orchestrion/bundler/rollup.d.ts.map +1 -0
- package/build/types/orchestrion/bundler/vite.d.ts +4 -17
- package/build/types/orchestrion/bundler/vite.d.ts.map +1 -1
- package/build/types/orchestrion/bundler/webpack.d.ts +19 -0
- package/build/types/orchestrion/bundler/webpack.d.ts.map +1 -0
- package/build/types/orchestrion/channels.d.ts +64 -37
- package/build/types/orchestrion/channels.d.ts.map +1 -1
- package/build/types/orchestrion/config/dataloader.d.ts +46 -0
- package/build/types/orchestrion/config/dataloader.d.ts.map +1 -0
- package/build/types/orchestrion/config/firebase.d.ts +4 -0
- package/build/types/orchestrion/config/firebase.d.ts.map +1 -0
- package/build/types/orchestrion/config/generic-pool.d.ts +31 -0
- package/build/types/orchestrion/config/generic-pool.d.ts.map +1 -0
- package/build/types/orchestrion/config/index.d.ts +18 -5
- package/build/types/orchestrion/config/index.d.ts.map +1 -1
- package/build/types/orchestrion/config/kafkajs.d.ts +17 -0
- package/build/types/orchestrion/config/kafkajs.d.ts.map +1 -0
- package/build/types/orchestrion/config/knex.d.ts +9 -0
- package/build/types/orchestrion/config/knex.d.ts.map +1 -0
- package/build/types/orchestrion/config/langchain.d.ts +4 -0
- package/build/types/orchestrion/config/langchain.d.ts.map +1 -0
- package/build/types/orchestrion/config/langgraph.d.ts +4 -0
- package/build/types/orchestrion/config/langgraph.d.ts.map +1 -0
- package/build/types/orchestrion/config/mongodb.d.ts +4 -0
- package/build/types/orchestrion/config/mongodb.d.ts.map +1 -0
- package/build/types/orchestrion/config/mongoose.d.ts +4 -0
- package/build/types/orchestrion/config/mongoose.d.ts.map +1 -0
- package/build/types/orchestrion/config/mysql2.d.ts +18 -0
- package/build/types/orchestrion/config/mysql2.d.ts.map +1 -0
- package/build/types/orchestrion/config/nestjs.d.ts +24 -0
- package/build/types/orchestrion/config/nestjs.d.ts.map +1 -0
- package/build/types/orchestrion/config/prisma.d.ts +4 -0
- package/build/types/orchestrion/config/prisma.d.ts.map +1 -0
- package/build/types/orchestrion/config/react-router.d.ts +4 -0
- package/build/types/orchestrion/config/react-router.d.ts.map +1 -0
- package/build/types/orchestrion/config/remix.d.ts +4 -0
- package/build/types/orchestrion/config/remix.d.ts.map +1 -0
- package/build/types/orchestrion/config/tedious.d.ts +4 -0
- package/build/types/orchestrion/config/tedious.d.ts.map +1 -0
- package/build/types/orchestrion/detect.d.ts +3 -10
- package/build/types/orchestrion/detect.d.ts.map +1 -1
- package/build/types/orchestrion/index.d.ts +25 -1
- package/build/types/orchestrion/index.d.ts.map +1 -1
- package/build/types/orchestrion/runtime/register.d.ts +11 -9
- package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
- package/build/types/prisma/global.d.ts +5 -0
- package/build/types/prisma/global.d.ts.map +1 -0
- package/build/types/prisma/index.d.ts +45 -0
- package/build/types/prisma/index.d.ts.map +1 -0
- package/build/types/prisma/tracing-helper.d.ts +46 -0
- package/build/types/prisma/tracing-helper.d.ts.map +1 -0
- package/build/types/prisma/types.d.ts +37 -0
- package/build/types/prisma/types.d.ts.map +1 -0
- package/build/types/vercel-ai/util.d.ts +0 -2
- package/build/types/vercel-ai/util.d.ts.map +1 -1
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
- package/build/types-ts3.8/graphql/utils.d.ts +2 -6
- package/build/types-ts3.8/index.d.ts +2 -0
- package/build/types-ts3.8/integrations/tracing-channel/dataloader.d.ts +11 -0
- package/build/types-ts3.8/integrations/tracing-channel/generic-pool.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/ioredis.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing-channel/kafkajs/consumer.d.ts +8 -0
- package/build/types-ts3.8/integrations/tracing-channel/kafkajs/index.d.ts +17 -0
- package/build/types-ts3.8/integrations/tracing-channel/kafkajs/semconv.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/kafkajs/spans.d.ts +38 -0
- package/build/types-ts3.8/integrations/tracing-channel/kafkajs/types.d.ts +40 -0
- package/build/types-ts3.8/integrations/tracing-channel/knex.d.ts +11 -0
- package/build/types-ts3.8/integrations/tracing-channel/mysql2.d.ts +15 -0
- package/build/types-ts3.8/orchestrion/bundler/esbuild.d.ts +21 -0
- package/build/types-ts3.8/orchestrion/bundler/options.d.ts +19 -0
- package/build/types-ts3.8/orchestrion/bundler/rollup.d.ts +17 -0
- package/build/types-ts3.8/orchestrion/bundler/vite.d.ts +4 -17
- package/build/types-ts3.8/orchestrion/bundler/webpack.d.ts +19 -0
- package/build/types-ts3.8/orchestrion/channels.d.ts +64 -37
- package/build/types-ts3.8/orchestrion/config/dataloader.d.ts +46 -0
- package/build/types-ts3.8/orchestrion/config/firebase.d.ts +4 -0
- package/build/types-ts3.8/orchestrion/config/generic-pool.d.ts +31 -0
- package/build/types-ts3.8/orchestrion/config/index.d.ts +18 -5
- package/build/types-ts3.8/orchestrion/config/kafkajs.d.ts +17 -0
- package/build/types-ts3.8/orchestrion/config/knex.d.ts +9 -0
- package/build/types-ts3.8/orchestrion/config/langchain.d.ts +4 -0
- package/build/types-ts3.8/orchestrion/config/langgraph.d.ts +4 -0
- package/build/types-ts3.8/orchestrion/config/mongodb.d.ts +4 -0
- package/build/types-ts3.8/orchestrion/config/mongoose.d.ts +4 -0
- package/build/types-ts3.8/orchestrion/config/mysql2.d.ts +18 -0
- package/build/types-ts3.8/orchestrion/config/nestjs.d.ts +24 -0
- package/build/types-ts3.8/orchestrion/config/prisma.d.ts +4 -0
- package/build/types-ts3.8/orchestrion/config/react-router.d.ts +4 -0
- package/build/types-ts3.8/orchestrion/config/remix.d.ts +4 -0
- package/build/types-ts3.8/orchestrion/config/tedious.d.ts +4 -0
- package/build/types-ts3.8/orchestrion/detect.d.ts +3 -10
- package/build/types-ts3.8/orchestrion/index.d.ts +25 -1
- package/build/types-ts3.8/orchestrion/runtime/register.d.ts +11 -9
- package/build/types-ts3.8/prisma/global.d.ts +5 -0
- package/build/types-ts3.8/prisma/index.d.ts +45 -0
- package/build/types-ts3.8/prisma/tracing-helper.d.ts +52 -0
- package/build/types-ts3.8/prisma/types.d.ts +40 -0
- package/build/types-ts3.8/vercel-ai/util.d.ts +0 -2
- package/package.json +41 -8
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
2
|
+
import { defineIntegration, debug, waitForTracingChannelBinding, getActiveSpan, SPAN_STATUS_ERROR, truncate, startInactiveSpan, SPAN_KIND, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
3
|
+
import { DB_STATEMENT, NET_TRANSPORT, NET_PEER_PORT, NET_PEER_NAME, DB_USER, DB_SYSTEM, DB_NAME, DB_OPERATION } from '@sentry/conventions/attributes';
|
|
4
|
+
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
5
|
+
import { CHANNELS } from '../../orchestrion/channels.js';
|
|
6
|
+
import { bindTracingChannelToSpan } from '../../tracing-channel.js';
|
|
7
|
+
|
|
8
|
+
const INTEGRATION_NAME = "Knex";
|
|
9
|
+
const ORIGIN = "auto.db.orchestrion.knex";
|
|
10
|
+
const MAX_QUERY_LENGTH = 1021;
|
|
11
|
+
const ATTR_DB_SQL_TABLE = "db.sql.table";
|
|
12
|
+
const DB_SYSTEM_SQLITE = "sqlite";
|
|
13
|
+
const DB_SYSTEM_POSTGRESQL = "postgresql";
|
|
14
|
+
const parentSpanSymbol = /* @__PURE__ */ Symbol("sentry.orchestrion.knex.parent-span");
|
|
15
|
+
const _knexChannelIntegration = (() => {
|
|
16
|
+
return {
|
|
17
|
+
name: INTEGRATION_NAME,
|
|
18
|
+
setupOnce() {
|
|
19
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
DEBUG_BUILD && debug.log(`[orchestrion:knex] subscribing to channel "${CHANNELS.KNEX_QUERY}"`);
|
|
23
|
+
waitForTracingChannelBinding(() => {
|
|
24
|
+
subscribeBuilder(CHANNELS.KNEX_QUERY_BUILDER);
|
|
25
|
+
subscribeBuilder(CHANNELS.KNEX_SCHEMA_BUILDER);
|
|
26
|
+
subscribeBuilder(CHANNELS.KNEX_RAW);
|
|
27
|
+
subscribeQuery();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
function subscribeBuilder(channelName) {
|
|
33
|
+
diagnosticsChannel.tracingChannel(channelName).end.subscribe((message) => {
|
|
34
|
+
const builder = message.result;
|
|
35
|
+
if (!builder || typeof builder !== "object" || parentSpanSymbol in builder) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const activeSpan = getActiveSpan();
|
|
39
|
+
if (!activeSpan) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
Object.defineProperty(builder, parentSpanSymbol, { value: activeSpan });
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function subscribeQuery() {
|
|
46
|
+
bindTracingChannelToSpan(
|
|
47
|
+
diagnosticsChannel.tracingChannel(CHANNELS.KNEX_QUERY),
|
|
48
|
+
(data) => {
|
|
49
|
+
const runner = data.self;
|
|
50
|
+
const builder = runner?.builder;
|
|
51
|
+
const parentSpan = builder?.[parentSpanSymbol] ?? getActiveSpan();
|
|
52
|
+
if (!parentSpan) {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
const query = data.arguments[0];
|
|
56
|
+
const client = runner?.client;
|
|
57
|
+
const connection = client?.config?.connection;
|
|
58
|
+
const connectionString = connection?.connectionString;
|
|
59
|
+
const table = extractTableName(builder);
|
|
60
|
+
const operation = query?.method;
|
|
61
|
+
const name = connection?.filename || connection?.database || extractDatabaseFromConnectionString(connectionString);
|
|
62
|
+
const attributes = {
|
|
63
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
64
|
+
"knex.version": data.moduleVersion,
|
|
65
|
+
[DB_SYSTEM]: mapSystem(client?.driverName),
|
|
66
|
+
[ATTR_DB_SQL_TABLE]: table,
|
|
67
|
+
[DB_OPERATION]: operation,
|
|
68
|
+
[DB_USER]: connection?.user,
|
|
69
|
+
[DB_NAME]: name,
|
|
70
|
+
[NET_PEER_NAME]: connection?.host ?? extractHostFromConnectionString(connectionString),
|
|
71
|
+
[NET_PEER_PORT]: connection?.port ?? extractPortFromConnectionString(connectionString),
|
|
72
|
+
[NET_TRANSPORT]: connection?.filename === ":memory:" ? "inproc" : void 0,
|
|
73
|
+
[DB_STATEMENT]: query?.sql != null ? truncate(query.sql, MAX_QUERY_LENGTH) : void 0
|
|
74
|
+
};
|
|
75
|
+
return startInactiveSpan({
|
|
76
|
+
name: getName(name, operation, table) ?? "knex.query",
|
|
77
|
+
kind: SPAN_KIND.CLIENT,
|
|
78
|
+
op: "db",
|
|
79
|
+
parentSpan,
|
|
80
|
+
attributes
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
beforeSpanEnd(span, data) {
|
|
85
|
+
if ("error" in data) {
|
|
86
|
+
const message = cleanErrorMessage(data);
|
|
87
|
+
if (message !== void 0) {
|
|
88
|
+
span.setStatus({ code: SPAN_STATUS_ERROR, message });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
function cleanErrorMessage(data) {
|
|
96
|
+
const error = data.error;
|
|
97
|
+
if (!error || typeof error !== "object" || typeof error.message !== "string") {
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
const rawMessage = error.message;
|
|
101
|
+
const query = data.arguments[0];
|
|
102
|
+
if (!query?.sql) {
|
|
103
|
+
return rawMessage;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const formatter = getFormatter(data.self);
|
|
107
|
+
const fullQuery = formatter(query.sql, query.bindings || []);
|
|
108
|
+
return rawMessage.replace(`${fullQuery} - `, "");
|
|
109
|
+
} catch {
|
|
110
|
+
return rawMessage;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function getFormatter(runner) {
|
|
114
|
+
if (runner) {
|
|
115
|
+
const client = runner.client;
|
|
116
|
+
if (client) {
|
|
117
|
+
if (client._formatQuery) {
|
|
118
|
+
return client._formatQuery.bind(client);
|
|
119
|
+
} else if (client.SqlString) {
|
|
120
|
+
return client.SqlString.format.bind(client.SqlString);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (runner.builder?.toString) {
|
|
124
|
+
return runner.builder.toString.bind(runner.builder);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return () => "<noop formatter>";
|
|
128
|
+
}
|
|
129
|
+
function mapSystem(driverName) {
|
|
130
|
+
if (driverName === "sqlite3") {
|
|
131
|
+
return DB_SYSTEM_SQLITE;
|
|
132
|
+
}
|
|
133
|
+
if (driverName === "pg") {
|
|
134
|
+
return DB_SYSTEM_POSTGRESQL;
|
|
135
|
+
}
|
|
136
|
+
return driverName;
|
|
137
|
+
}
|
|
138
|
+
function getName(db, operation, table) {
|
|
139
|
+
if (operation && db) {
|
|
140
|
+
return table ? `${operation} ${db}.${table}` : `${operation} ${db}`;
|
|
141
|
+
}
|
|
142
|
+
return db;
|
|
143
|
+
}
|
|
144
|
+
function extractTableName(builder) {
|
|
145
|
+
const table = builder?._single?.table;
|
|
146
|
+
if (table && typeof table === "object") {
|
|
147
|
+
return extractTableName(table);
|
|
148
|
+
}
|
|
149
|
+
return typeof table === "string" ? table : void 0;
|
|
150
|
+
}
|
|
151
|
+
function extractDatabaseFromConnectionString(connectionString) {
|
|
152
|
+
if (!connectionString) {
|
|
153
|
+
return void 0;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
const db = new URL(connectionString).pathname?.replace(/^\//, "");
|
|
157
|
+
return db || void 0;
|
|
158
|
+
} catch {
|
|
159
|
+
return void 0;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function extractHostFromConnectionString(connectionString) {
|
|
163
|
+
if (!connectionString) {
|
|
164
|
+
return void 0;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
return new URL(connectionString).hostname || void 0;
|
|
168
|
+
} catch {
|
|
169
|
+
return void 0;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function extractPortFromConnectionString(connectionString) {
|
|
173
|
+
if (!connectionString) {
|
|
174
|
+
return void 0;
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const port = new URL(connectionString).port;
|
|
178
|
+
return port ? parseInt(port, 10) : void 0;
|
|
179
|
+
} catch {
|
|
180
|
+
return void 0;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const knexChannelIntegration = defineIntegration(_knexChannelIntegration);
|
|
184
|
+
|
|
185
|
+
export { knexChannelIntegration };
|
|
186
|
+
//# sourceMappingURL=knex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knex.js","sources":["../../../../src/integrations/tracing-channel/knex.ts"],"sourcesContent":["// The `@sentry/conventions` db/net attribute keys are deprecated (superseded by newer semconv), but we\n// emit them deliberately to preserve parity with what `@opentelemetry/instrumentation-knex` produced.\n/* oxlint-disable typescript/no-deprecated */\n\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn, Span, SpanAttributes } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n truncate,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport {\n DB_NAME,\n DB_OPERATION,\n DB_STATEMENT,\n DB_SYSTEM,\n DB_USER,\n NET_PEER_NAME,\n NET_PEER_PORT,\n NET_TRANSPORT,\n} from '@sentry/conventions/attributes';\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. `@sentry/node`'s `knexIntegration`\n// picks this subscriber over the vendored OTel path when orchestrion injection is active.\nconst INTEGRATION_NAME = 'Knex' as const;\nconst ORIGIN = 'auto.db.orchestrion.knex';\n\n// Max length of the query text captured in `db.statement`; \"...\" is appended when truncated, so the\n// truncated statement caps at 1024 chars (1 KiB), matching `@opentelemetry/instrumentation-knex`.\nconst MAX_QUERY_LENGTH = 1021;\n\n// `db.sql.table` is deprecated and not exported by `@sentry/conventions`, so keep it local. Matches\n// what `@opentelemetry/instrumentation-knex` emitted.\nconst ATTR_DB_SQL_TABLE = 'db.sql.table';\n\nconst DB_SYSTEM_SQLITE = 'sqlite';\nconst DB_SYSTEM_POSTGRESQL = 'postgresql';\n\n// The span active when a builder is created, reused as the parent when the query runs later (the query\n// often executes in a different async context than the builder was created in).\nconst parentSpanSymbol = Symbol('sentry.orchestrion.knex.parent-span');\n\ninterface KnexQuery {\n sql?: string;\n method?: string;\n bindings?: unknown[];\n}\n\ninterface KnexConnectionConfig {\n filename?: string;\n database?: string;\n user?: string;\n host?: string;\n port?: number;\n connectionString?: string;\n}\n\ninterface KnexBuilder {\n _single?: { table?: unknown };\n toString?: () => string;\n [parentSpanSymbol]?: Span;\n}\n\ninterface KnexClient {\n driverName?: string;\n config?: { connection?: KnexConnectionConfig };\n _formatQuery?: (sql: string, bindings: unknown[]) => string;\n SqlString?: { format: (sql: string, bindings: unknown[]) => string };\n}\n\ninterface KnexRunner {\n client?: KnexClient;\n builder?: KnexBuilder;\n}\n\n/** Context orchestrion attaches to the `orchestrion:knex:query` channel (wrapping `Runner.query`). */\ninterface KnexQueryChannelContext {\n // `arguments[0]` is the query object (`{ sql, method, bindings }`).\n arguments: [KnexQuery?];\n self?: KnexRunner;\n moduleVersion?: string;\n result?: unknown;\n error?: unknown;\n}\n\n/** Context orchestrion attaches to the `Client.queryBuilder`/`schemaBuilder`/`raw` channels. */\ninterface KnexBuilderChannelContext {\n arguments: unknown[];\n self?: unknown;\n // The builder returned by the wrapped method.\n result?: KnexBuilder;\n}\n\nconst _knexChannelIntegration = (() => {\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 DEBUG_BUILD && debug.log(`[orchestrion:knex] subscribing to channel \"${CHANNELS.KNEX_QUERY}\"`);\n\n waitForTracingChannelBinding(() => {\n subscribeBuilder(CHANNELS.KNEX_QUERY_BUILDER);\n subscribeBuilder(CHANNELS.KNEX_SCHEMA_BUILDER);\n subscribeBuilder(CHANNELS.KNEX_RAW);\n subscribeQuery();\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Bookkeeping only: stash the span active at builder-creation time onto the returned builder. It is\n * read back as the parent when the query runs (see `subscribeQuery`), because the query often executes\n * in a different async context. A `Client` builder method is synchronous, so its `result` (the builder)\n * is available on the channel's `end`.\n */\nfunction subscribeBuilder(channelName: string): void {\n diagnosticsChannel.tracingChannel(channelName).end.subscribe(message => {\n const builder = (message as KnexBuilderChannelContext).result;\n if (!builder || typeof builder !== 'object' || parentSpanSymbol in builder) {\n return;\n }\n\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n return;\n }\n\n Object.defineProperty(builder, parentSpanSymbol, { value: activeSpan });\n });\n}\n\nfunction subscribeQuery(): void {\n bindTracingChannelToSpan<KnexQueryChannelContext>(\n diagnosticsChannel.tracingChannel<KnexQueryChannelContext>(CHANNELS.KNEX_QUERY),\n data => {\n const runner = data.self;\n const builder = runner?.builder;\n\n // The builder captures the span active when it was created (see `subscribeBuilder`).\n // `onlyIfParent`: only instrument queries that run as part of an existing trace, matching OTel.\n const parentSpan = builder?.[parentSpanSymbol] ?? getActiveSpan();\n if (!parentSpan) {\n return undefined;\n }\n\n const query = data.arguments[0];\n const client = runner?.client;\n const connection = client?.config?.connection;\n const connectionString = connection?.connectionString;\n const table = extractTableName(builder);\n const operation = query?.method;\n const name =\n connection?.filename || connection?.database || extractDatabaseFromConnectionString(connectionString);\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n 'knex.version': data.moduleVersion,\n [DB_SYSTEM]: mapSystem(client?.driverName),\n [ATTR_DB_SQL_TABLE]: table,\n [DB_OPERATION]: operation,\n [DB_USER]: connection?.user,\n [DB_NAME]: name,\n [NET_PEER_NAME]: connection?.host ?? extractHostFromConnectionString(connectionString),\n [NET_PEER_PORT]: connection?.port ?? extractPortFromConnectionString(connectionString),\n [NET_TRANSPORT]: connection?.filename === ':memory:' ? 'inproc' : undefined,\n [DB_STATEMENT]: query?.sql != null ? truncate(query.sql, MAX_QUERY_LENGTH) : undefined,\n };\n\n return startInactiveSpan({\n name: getName(name, operation, table) ?? 'knex.query',\n kind: SPAN_KIND.CLIENT,\n op: 'db',\n parentSpan,\n attributes,\n });\n },\n {\n beforeSpanEnd(span, data) {\n // knex prefixes query errors with the full SQL (\"<query> - <error>\"). Strip it so the span\n // status message is just the driver error, matching the vendored OTel instrumentation.\n if ('error' in data) {\n const message = cleanErrorMessage(data);\n if (message !== undefined) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message });\n }\n }\n },\n },\n );\n}\n\nfunction cleanErrorMessage(data: KnexQueryChannelContext): string | undefined {\n const error = data.error;\n if (!error || typeof error !== 'object' || typeof (error as { message?: unknown }).message !== 'string') {\n return undefined;\n }\n\n const rawMessage = (error as { message: string }).message;\n const query = data.arguments[0];\n if (!query?.sql) {\n return rawMessage;\n }\n\n try {\n const formatter = getFormatter(data.self);\n const fullQuery = formatter(query.sql, query.bindings || []);\n return rawMessage.replace(`${fullQuery} - `, '');\n } catch {\n return rawMessage;\n }\n}\n\nfunction getFormatter(runner: KnexRunner | undefined): (sql: string, bindings: unknown[]) => string {\n if (runner) {\n const client = runner.client;\n if (client) {\n if (client._formatQuery) {\n return client._formatQuery.bind(client);\n } else if (client.SqlString) {\n return client.SqlString.format.bind(client.SqlString);\n }\n }\n if (runner.builder?.toString) {\n return runner.builder.toString.bind(runner.builder);\n }\n }\n\n return () => '<noop formatter>';\n}\n\nfunction mapSystem(driverName: string | undefined): string | undefined {\n if (driverName === 'sqlite3') {\n return DB_SYSTEM_SQLITE;\n }\n if (driverName === 'pg') {\n return DB_SYSTEM_POSTGRESQL;\n }\n return driverName;\n}\n\nfunction getName(db: string | undefined, operation?: string, table?: string): string | undefined {\n // `db` can be undefined when the database can't be determined from the knex config. Guard against\n // interpolating it (which would emit the literal \"undefined\") and let the call site fall back.\n if (operation && db) {\n return table ? `${operation} ${db}.${table}` : `${operation} ${db}`;\n }\n return db;\n}\n\nfunction extractTableName(builder: KnexBuilder | undefined): string | undefined {\n const table = builder?._single?.table;\n if (table && typeof table === 'object') {\n return extractTableName(table as KnexBuilder);\n }\n return typeof table === 'string' ? table : undefined;\n}\n\nfunction extractDatabaseFromConnectionString(connectionString: string | undefined): string | undefined {\n if (!connectionString) {\n return undefined;\n }\n try {\n const db = new URL(connectionString).pathname?.replace(/^\\//, '');\n return db || undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction extractHostFromConnectionString(connectionString: string | undefined): string | undefined {\n if (!connectionString) {\n return undefined;\n }\n try {\n return new URL(connectionString).hostname || undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction extractPortFromConnectionString(connectionString: string | undefined): number | undefined {\n if (!connectionString) {\n return undefined;\n }\n try {\n const port = new URL(connectionString).port;\n return port ? parseInt(port, 10) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * EXPERIMENTAL - orchestrion-driven knex integration.\n *\n * Subscribes to the `orchestrion:knex:*` diagnostics_channels that the orchestrion code transform\n * injects into knex's `Runner.query` (span) and `Client.queryBuilder`/`schemaBuilder`/`raw` (parent-span\n * bookkeeping). Requires the orchestrion runtime hook or bundler plugin to be active.\n */\nexport const knexChannelIntegration = defineIntegration(_knexChannelIntegration);\n"],"names":[],"mappings":";;;;;;;AAiCA,MAAM,gBAAA,GAAmB,MAAA;AACzB,MAAM,MAAA,GAA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OAAO,IAAA,GAAO,QAAA,CAAS,IAAA,EAAM,EAAE,CAAA,GAAI,KAAA,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AASO,MAAM,sBAAA,GAAyB,kBAAkB,uBAAuB;;;;"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
2
|
+
import { defineIntegration, waitForTracingChannelBinding, startInactiveSpan, SPAN_KIND, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, isObjectLike } from '@sentry/core';
|
|
3
|
+
import { subscribeMysql2DiagnosticChannels } from '../../mysql2/mysql2-dc-subscriber.js';
|
|
4
|
+
import { CHANNELS } from '../../orchestrion/channels.js';
|
|
5
|
+
import { bindTracingChannelToSpan } from '../../tracing-channel.js';
|
|
6
|
+
import { DB_STATEMENT, DB_SYSTEM, NET_PEER_PORT, NET_PEER_NAME, DB_USER, DB_NAME } from '@sentry/conventions/attributes';
|
|
7
|
+
|
|
8
|
+
const INTEGRATION_NAME = "Mysql2";
|
|
9
|
+
const ORIGIN = "auto.db.orchestrion.mysql2";
|
|
10
|
+
const DB_SYSTEM_VALUE_MYSQL = "mysql";
|
|
11
|
+
function instrumentMysql2() {
|
|
12
|
+
subscribeMysql2DiagnosticChannels(diagnosticsChannel.tracingChannel);
|
|
13
|
+
subscribeQueryChannel(CHANNELS.MYSQL2_QUERY);
|
|
14
|
+
subscribeQueryChannel(CHANNELS.MYSQL2_EXECUTE);
|
|
15
|
+
}
|
|
16
|
+
function subscribeQueryChannel(channelName) {
|
|
17
|
+
bindTracingChannelToSpan(
|
|
18
|
+
diagnosticsChannel.tracingChannel(channelName),
|
|
19
|
+
(data) => {
|
|
20
|
+
const statement = getQueryText(data.arguments);
|
|
21
|
+
return startInactiveSpan({
|
|
22
|
+
name: statement ?? "mysql2.query",
|
|
23
|
+
kind: SPAN_KIND.CLIENT,
|
|
24
|
+
attributes: {
|
|
25
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
26
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db",
|
|
27
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
28
|
+
[DB_SYSTEM]: DB_SYSTEM_VALUE_MYSQL,
|
|
29
|
+
...getConnectionAttributes(data.self?.config),
|
|
30
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
31
|
+
[DB_STATEMENT]: statement || void 0
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
{ requiresParentSpan: true }
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function getQueryText(args) {
|
|
39
|
+
return extractSql(args[0]);
|
|
40
|
+
}
|
|
41
|
+
function extractSql(firstArg) {
|
|
42
|
+
if (typeof firstArg === "string") {
|
|
43
|
+
return firstArg;
|
|
44
|
+
}
|
|
45
|
+
if (isObjectLike(firstArg) && "sql" in firstArg) {
|
|
46
|
+
const sql = firstArg.sql;
|
|
47
|
+
return typeof sql === "string" ? sql : void 0;
|
|
48
|
+
}
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
function getConnectionAttributes(config) {
|
|
52
|
+
const { host, port, database, user } = config?.connectionConfig ?? config ?? {};
|
|
53
|
+
const portNumber = typeof port === "string" ? parseInt(port, 10) : port;
|
|
54
|
+
const portIsNumber = typeof portNumber === "number" && !isNaN(portNumber);
|
|
55
|
+
return {
|
|
56
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
57
|
+
[DB_NAME]: database || void 0,
|
|
58
|
+
[DB_USER]: user || void 0,
|
|
59
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
60
|
+
[NET_PEER_NAME]: host || void 0,
|
|
61
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
62
|
+
[NET_PEER_PORT]: portIsNumber ? portNumber : void 0
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const _mysql2ChannelIntegration = (() => {
|
|
66
|
+
return {
|
|
67
|
+
name: INTEGRATION_NAME,
|
|
68
|
+
setupOnce() {
|
|
69
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
waitForTracingChannelBinding(() => {
|
|
73
|
+
instrumentMysql2();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
const mysql2ChannelIntegration = defineIntegration(_mysql2ChannelIntegration);
|
|
79
|
+
|
|
80
|
+
export { mysql2ChannelIntegration };
|
|
81
|
+
//# sourceMappingURL=mysql2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql2.js","sources":["../../../../src/integrations/tracing-channel/mysql2.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn, SpanAttributes } from '@sentry/core';\nimport {\n defineIntegration,\n isObjectLike,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { subscribeMysql2DiagnosticChannels } from '../../mysql2/mysql2-dc-subscriber';\nimport type { ChannelName } from '../../orchestrion/channels';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\nimport {\n DB_NAME,\n DB_STATEMENT,\n DB_SYSTEM,\n DB_USER,\n NET_PEER_NAME,\n NET_PEER_PORT,\n} from '@sentry/conventions/attributes';\n\nconst INTEGRATION_NAME = 'Mysql2' as const;\nconst ORIGIN = 'auto.db.orchestrion.mysql2';\nconst DB_SYSTEM_VALUE_MYSQL = 'mysql';\n\n/**\n * The shape orchestrion's transform attaches to the tracing-channel `context` object. Documented here\n * rather than imported because orchestrion's runtime doesn't export it.\n */\ninterface Mysql2QueryChannelContext {\n // The live args array passed to the wrapped `query`/`execute` call: `arguments[0]` is the SQL (a\n // string, `Query`, or `{ sql, values }`), `arguments[1]` is the values array or a callback.\n arguments: unknown[];\n self?: Mysql2Connection;\n result?: unknown;\n error?: unknown;\n}\n\ninterface Mysql2ConnectionConfig {\n host?: string;\n port?: number | string;\n database?: string;\n user?: string;\n // Pool connections nest the real config one level deeper.\n connectionConfig?: Mysql2ConnectionConfig;\n}\n\ninterface Mysql2Connection {\n config?: Mysql2ConnectionConfig;\n}\n\n/**\n * Orchestrion-driven mysql2 integration.\n *\n * Subscribes to:\n * - the `orchestrion:mysql2:query`/`:execute` channels the code transform injects into mysql2's\n * `query`/`execute` (mysql2 `< 3.20.0`), and\n * - mysql2's native `node:diagnostics_channel` tracing channels (mysql2 `>= 3.20.0`), which the\n * transform intentionally leaves alone.\n *\n * The two version ranges never overlap, so no query is double-counted. Requires the orchestrion\n * runtime hook or bundler plugin to be active — wire that up via\n * `experimentalUseDiagnosticsChannelInjection`.\n */\nfunction instrumentMysql2(): void {\n // mysql2 >= 3.20.0: native diagnostics_channel path (inert on older versions, which never publish).\n subscribeMysql2DiagnosticChannels(diagnosticsChannel.tracingChannel);\n\n // mysql2 < 3.20.0: orchestrion-injected channels (inert on >= 3.20.0, which we don't transform).\n subscribeQueryChannel(CHANNELS.MYSQL2_QUERY);\n subscribeQueryChannel(CHANNELS.MYSQL2_EXECUTE);\n}\n\nfunction subscribeQueryChannel(channelName: ChannelName): void {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<Mysql2QueryChannelContext>(channelName),\n data => {\n const statement = getQueryText(data.arguments);\n\n return startInactiveSpan({\n name: statement ?? 'mysql2.query',\n kind: SPAN_KIND.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MYSQL,\n ...getConnectionAttributes(data.self?.config),\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_STATEMENT]: statement || undefined,\n },\n });\n },\n { requiresParentSpan: true },\n );\n}\n\n/**\n * Render the `db.statement` from the wrapped call's first argument.\n */\nfunction getQueryText(args: unknown[]): string | undefined {\n return extractSql(args[0]);\n}\n\nfunction extractSql(firstArg: unknown): string | undefined {\n if (typeof firstArg === 'string') {\n return firstArg;\n }\n if (isObjectLike(firstArg) && 'sql' in firstArg) {\n const sql = (firstArg as { sql?: unknown }).sql;\n return typeof sql === 'string' ? sql : undefined;\n }\n return undefined;\n}\n\nfunction getConnectionAttributes(config: Mysql2ConnectionConfig | undefined): SpanAttributes {\n // Pool connections nest the real config under `.connectionConfig`; single connections expose it\n // directly. Matches `@opentelemetry/instrumentation-mysql2`.\n const { host, port, database, user } = config?.connectionConfig ?? config ?? {};\n const portNumber = typeof port === 'string' ? parseInt(port, 10) : port;\n const portIsNumber = typeof portNumber === 'number' && !isNaN(portNumber);\n\n return {\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_NAME]: database || undefined,\n [DB_USER]: user || undefined,\n // oxlint-disable-next-line typescript/no-deprecated\n [NET_PEER_NAME]: host || undefined,\n // oxlint-disable-next-line typescript/no-deprecated\n [NET_PEER_PORT]: portIsNumber ? portNumber : undefined,\n };\n}\n\nconst _mysql2ChannelIntegration = (() => {\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 instrumentMysql2();\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Orchestrion-driven mysql2 integration.\n *\n * Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library\n * via diagnostics-channel injection. See {@link instrumentMysql2} for how the two mysql2 version\n * ranges are covered.\n *\n * Known limitation vs. the OTel integration it replaces: the callback-less streaming form\n * (`connection.query(sql).on('result', ...)`) is not traced — see the `mysql2` orchestrion config for\n * why. The callback and promise forms (the common case) are fully instrumented.\n */\nexport const mysql2ChannelIntegration = defineIntegration(_mysql2ChannelIntegration);\n"],"names":[],"mappings":";;;;;;;AAwBA,MAAM,gBAAA,GAAmB,QAAA;AACzB,MAAM,MAAA,GAAS,4BAAA;AACf,MAAM,qBAAA,GAAwB,OAAA;AAyC9B,SAAS,gBAAA,GAAyB;AAEhC,EAAA,iCAAA,CAAkC,mBAAmB,cAAc,CAAA;AAGnE,EAAA,qBAAA,CAAsB,SAAS,YAAY,CAAA;AAC3C,EAAA,qBAAA,CAAsB,SAAS,cAAc,CAAA;AAC/C;AAEA,SAAS,sBAAsB,WAAA,EAAgC;AAC7D,EAAA,wBAAA;AAAA,IACE,kBAAA,CAAmB,eAA0C,WAAW,CAAA;AAAA,IACxE,CAAA,IAAA,KAAQ;AACN,MAAA,MAAM,SAAA,GAAY,YAAA,CAAa,IAAA,CAAK,SAAS,CAAA;AAE7C,MAAA,OAAO,iBAAA,CAAkB;AAAA,QACvB,MAAM,SAAA,IAAa,cAAA;AAAA,QACnB,MAAM,SAAA,CAAU,MAAA;AAAA,QAChB,UAAA,EAAY;AAAA,UACV,CAAC,gCAAgC,GAAG,MAAA;AAAA,UACpC,CAAC,4BAA4B,GAAG,IAAA;AAAA;AAAA,UAEhC,CAAC,SAAS,GAAG,qBAAA;AAAA,UACb,GAAG,uBAAA,CAAwB,IAAA,CAAK,IAAA,EAAM,MAAM,CAAA;AAAA;AAAA,UAE5C,CAAC,YAAY,GAAG,SAAA,IAAa;AAAA;AAC/B,OACD,CAAA;AAAA,IACH,CAAA;AAAA,IACA,EAAE,oBAAoB,IAAA;AAAK,GAC7B;AACF;AAKA,SAAS,aAAa,IAAA,EAAqC;AACzD,EAAA,OAAO,UAAA,CAAW,IAAA,CAAK,CAAC,CAAC,CAAA;AAC3B;AAEA,SAAS,WAAW,QAAA,EAAuC;AACzD,EAAA,IAAI,OA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
|
+
import codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/esbuild';
|
|
2
|
+
import { orchestrionTransformOptions } from './options.js';
|
|
3
|
+
|
|
4
|
+
function sentryOrchestrionPlugin(options = {}) {
|
|
5
|
+
return codeTransformer(orchestrionTransformOptions(options));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { sentryOrchestrionPlugin };
|
|
9
|
+
//# sourceMappingURL=esbuild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.js","sources":["../../../../src/orchestrion/bundler/esbuild.ts"],"sourcesContent":["import codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/esbuild';\nimport type { PluginOptions } from './options';\nimport { orchestrionTransformOptions } from './options';\n\n/**\n * esbuild plugin that runs the orchestrion code transform on the bundled output.\n *\n * Use when bundling a Node app with esbuild. For unbundled Node processes use the\n * runtime hook instead (`node --import @sentry/node/orchestrion app.js`).\n *\n * esbuild does not flatten nested `plugins` arrays, so this returns a single\n * plugin that strips instrumented packages from an `external` denylist before\n * delegating to the upstream transform.\n *\n * @example\n * ```ts\n * // build.mjs\n * import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/esbuild';\n * await esbuild.build({ plugins: [sentryOrchestrionPlugin()] });\n * ```\n */\nexport function sentryOrchestrionPlugin(options: PluginOptions = {}): ReturnType<typeof codeTransformer> {\n return codeTransformer(orchestrionTransformOptions(options));\n}\n"],"names":[],"mappings":";;;AAqBO,SAAS,uBAAA,CAAwB,OAAA,GAAyB,EAAC,EAAuC;AACvG,EAAA,OAAO,eAAA,CAAgB,2BAAA,CAA4B,OAAO,CAAC,CAAA;AAC7D;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SENTRY_INSTRUMENTATIONS } from '../config/index.js';
|
|
2
|
+
|
|
3
|
+
function orchestrionTransformOptions(options) {
|
|
4
|
+
return {
|
|
5
|
+
instrumentations: [...SENTRY_INSTRUMENTATIONS, ...options.instrumentations || []],
|
|
6
|
+
injectDiagnostics: (diag) => {
|
|
7
|
+
return `(globalThis.__SENTRY_ORCHESTRION__=globalThis.__SENTRY_ORCHESTRION__||{}).bundler=${JSON.stringify(diag.transformedModules)};`;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { orchestrionTransformOptions };
|
|
13
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sources":["../../../../src/orchestrion/bundler/options.ts"],"sourcesContent":["import type { InstrumentationConfig } from '@apm-js-collab/code-transformer';\nimport { SENTRY_INSTRUMENTATIONS } from '../config';\nimport type codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/rollup';\n\nexport type PluginOptions = {\n /**\n * Additional instrumentations to include with the default instrumentation.\n */\n instrumentations?: InstrumentationConfig[];\n};\n\n/**\n * The `@apm-js-collab/code-transformer-bundler-plugins` options shared by every\n * orchestrion bundler plugin.\n *\n * `injectDiagnostics` sets `globalThis.__SENTRY_ORCHESTRION__.bundler = [\"mysql\"]` at\n * app boot so the `_experimentalSetupOrchestrion()` detector can confirm the\n * bundler path ran (rather than relying on a build-time flag that wouldn't be\n * visible to the runtime).\n */\nexport function orchestrionTransformOptions(options: PluginOptions): Parameters<typeof codeTransformer>[0] {\n return {\n instrumentations: [...SENTRY_INSTRUMENTATIONS, ...(options.instrumentations || [])],\n injectDiagnostics: (diag: { transformedModules: string[]; failedModules: string[] }) => {\n return `(globalThis.__SENTRY_ORCHESTRION__=globalThis.__SENTRY_ORCHESTRION__||{}).bundler=${JSON.stringify(diag.transformedModules)};`;\n },\n };\n}\n"],"names":[],"mappings":";;AAoBO,SAAS,4BAA4B,OAAA,EAA+D;AACzG,EAAA,OAAO;AAAA,IACL,gBAAA,EAAkB,CAAC,GAAG,uBAAA,EAAyB,GAAI,OAAA,CAAQ,gBAAA,IAAoB,EAAG,CAAA;AAAA,IAClF,iBAAA,EAAmB,CAAC,IAAA,KAAoE;AACtF,MAAA,OAAO,CAAA,kFAAA,EAAqF,IAAA,CAAK,SAAA,CAAU,IAAA,CAAK,kBAAkB,CAAC,CAAA,CAAA,CAAA;AAAA,IACrI;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/rollup';
|
|
2
|
+
import { orchestrionTransformOptions } from './options.js';
|
|
3
|
+
|
|
4
|
+
function sentryOrchestrionPlugin(options = {}) {
|
|
5
|
+
return codeTransformer(orchestrionTransformOptions(options));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { sentryOrchestrionPlugin };
|
|
9
|
+
//# sourceMappingURL=rollup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup.js","sources":["../../../../src/orchestrion/bundler/rollup.ts"],"sourcesContent":["import codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/rollup';\nimport type { PluginOptions } from './options';\nimport { orchestrionTransformOptions } from './options';\n\n/**\n * Rollup plugin that runs the orchestrion code transform on the bundled output.\n *\n * Use when bundling a Node app with Rollup. For unbundled Node processes use the\n * runtime hook instead (`node --import @sentry/node/orchestrion app.js`).\n *\n * @example\n * ```ts\n * // rollup.config.js\n * import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/rollup';\n * export default { plugins: [sentryOrchestrionPlugin()] };\n * ```\n */\nexport function sentryOrchestrionPlugin(options: PluginOptions = {}): ReturnType<typeof codeTransformer> {\n return codeTransformer(orchestrionTransformOptions(options));\n}\n"],"names":[],"mappings":";;;AAiBO,SAAS,uBAAA,CAAwB,OAAA,GAAyB,EAAC,EAAuC;AACvG,EAAA,OAAO,eAAA,CAAgB,2BAAA,CAA4B,OAAO,CAAC,CAAA;AAC7D;;;;"}
|
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
import codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/vite';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { instrumentedModuleNames } from '../config/index.js';
|
|
3
|
+
import { orchestrionTransformOptions } from './options.js';
|
|
4
4
|
|
|
5
|
-
function sentryOrchestrionPlugin() {
|
|
6
|
-
const codeTransformerPlugins = codeTransformer({ instrumentations: SENTRY_INSTRUMENTATIONS });
|
|
7
|
-
const codeTransformerArray = Array.isArray(codeTransformerPlugins) ? codeTransformerPlugins : [codeTransformerPlugins];
|
|
8
|
-
return [bundlerMarkerPlugin(), ...codeTransformerArray];
|
|
9
|
-
}
|
|
10
|
-
function bundlerMarkerPlugin() {
|
|
11
|
-
const banner = [
|
|
12
|
-
"globalThis.__SENTRY_ORCHESTRION__ = (globalThis.__SENTRY_ORCHESTRION__ || {});",
|
|
13
|
-
"globalThis.__SENTRY_ORCHESTRION__.bundler = true;",
|
|
14
|
-
""
|
|
15
|
-
].join("\n");
|
|
5
|
+
function sentryOrchestrionPlugin(options = {}) {
|
|
16
6
|
return {
|
|
17
|
-
|
|
18
|
-
enforce: "pre",
|
|
7
|
+
...codeTransformer(orchestrionTransformOptions(options)),
|
|
19
8
|
config() {
|
|
20
|
-
return { ssr: { noExternal:
|
|
21
|
-
},
|
|
22
|
-
renderChunk(code, chunk) {
|
|
23
|
-
if (!chunk.isEntry) return null;
|
|
24
|
-
const ms = new MagicString(code);
|
|
25
|
-
ms.prepend(banner);
|
|
26
|
-
return { code: ms.toString(), map: ms.generateMap({ hires: true }) };
|
|
9
|
+
return { ssr: { noExternal: instrumentedModuleNames(options.instrumentations) } };
|
|
27
10
|
}
|
|
28
11
|
};
|
|
29
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","sources":["../../../../src/orchestrion/bundler/vite.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"vite.js","sources":["../../../../src/orchestrion/bundler/vite.ts"],"sourcesContent":["import codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/vite';\nimport { instrumentedModuleNames } from '../config';\nimport type { PluginOptions } from './options';\nimport { orchestrionTransformOptions } from './options';\n\n/**\n * Vite plugin that runs the orchestrion code transform on the bundled output.\n *\n * Use when bundling a Node app with Vite (e.g. Vite SSR builds, Nuxt's Nitro\n * pipeline, SvelteKit). For unbundled Node processes use the runtime hook\n * instead (`node --import @sentry/node/orchestrion app.js`).\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite';\n * export default { plugins: [sentryOrchestrionPlugin()] };\n * ```\n */\nexport function sentryOrchestrionPlugin(options: PluginOptions = {}): ReturnType<typeof codeTransformer> {\n return {\n ...codeTransformer(orchestrionTransformOptions(options)),\n config(): { ssr: { noExternal: string[] } } {\n // Force-bundle every instrumented package so the code transform actually\n // sees its source. Vite externalizes dependencies in SSR builds by\n // default, leaving them as bare `require()`/`import` calls resolved from\n // `node_modules` at runtime — those copies are untouched and the\n // diagnostics_channel calls never get injected. Vite merges array\n // `noExternal` entries with the user's config, so we don't overwrite\n // their additions.\n return { ssr: { noExternal: instrumentedModuleNames(options.instrumentations) } };\n },\n };\n}\n"],"names":[],"mappings":";;;;AAmBO,SAAS,uBAAA,CAAwB,OAAA,GAAyB,EAAC,EAAuC;AACvG,EAAA,OAAO;AAAA,IACL,GAAG,eAAA,CAAgB,2BAAA,CAA4B,OAAO,CAAC,CAAA;AAAA,IACvD,MAAA,GAA4C;AAQ1C,MAAA,OAAO,EAAE,KAAK,EAAE,UAAA,EAAY,wBAAwB,OAAA,CAAQ,gBAAgB,GAAE,EAAE;AAAA,IAClF;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { SENTRY_INSTRUMENTATIONS } from '../config/index.js';
|
|
4
|
+
|
|
5
|
+
function getOrchestrionRequire() {
|
|
6
|
+
let nodeRequire;
|
|
7
|
+
nodeRequire = createRequire(import.meta.url);
|
|
8
|
+
return nodeRequire;
|
|
9
|
+
}
|
|
10
|
+
function getOrchestrionLoaderPath() {
|
|
11
|
+
return getOrchestrionRequire().resolve("@apm-js-collab/code-transformer-bundler-plugins/webpack-loader");
|
|
12
|
+
}
|
|
13
|
+
function getTracingHooksDirectory() {
|
|
14
|
+
const packageJsonPath = getOrchestrionRequire().resolve("@apm-js-collab/tracing-hooks/package.json");
|
|
15
|
+
return dirname(packageJsonPath).replace(/\\/g, "/");
|
|
16
|
+
}
|
|
17
|
+
function getSentryInstrumentations() {
|
|
18
|
+
return SENTRY_INSTRUMENTATIONS;
|
|
19
|
+
}
|
|
20
|
+
function sentryOrchestrionWebpackPlugin() {
|
|
21
|
+
const mod = getOrchestrionRequire()("@apm-js-collab/code-transformer-bundler-plugins/webpack");
|
|
22
|
+
const codeTransformerWebpack = mod.default ?? mod;
|
|
23
|
+
return codeTransformerWebpack({ instrumentations: SENTRY_INSTRUMENTATIONS });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { getOrchestrionLoaderPath, getSentryInstrumentations, getTracingHooksDirectory, sentryOrchestrionWebpackPlugin };
|
|
27
|
+
//# sourceMappingURL=webpack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack.js","sources":["../../../../src/orchestrion/bundler/webpack.ts"],"sourcesContent":["// EXPERIMENTAL — orchestrion code-transform loader + webpack plugin. The loader is exposed\n// separately because Turbopack can only take webpack loaders (via `turbopack.rules`), not plugins.\n\nimport { createRequire } from 'node:module';\nimport { dirname } from 'node:path';\nimport type { InstrumentationConfig } from '@apm-js-collab/code-transformer';\nimport { SENTRY_INSTRUMENTATIONS } from '../config';\n\n// Both branches use `createRequire` (never alias the CJS `require`) so bundlers consuming this\n// module don't emit a \"Critical dependency\" warning.\nfunction getOrchestrionRequire(): ReturnType<typeof createRequire> {\n let nodeRequire: ReturnType<typeof createRequire>;\n /*! rollup-include-cjs-only */\n nodeRequire = createRequire(__filename);\n /*! rollup-include-cjs-only-end */\n /*! rollup-include-esm-only */\n nodeRequire = createRequire(import.meta.url);\n /*! rollup-include-esm-only-end */\n return nodeRequire;\n}\n\n/** Absolute path to the code-transform loader (a webpack loader; also usable as a Turbopack loader). */\nexport function getOrchestrionLoaderPath(): string {\n return getOrchestrionRequire().resolve('@apm-js-collab/code-transformer-bundler-plugins/webpack-loader');\n}\n\n/**\n * Absolute path to the `@apm-js-collab/tracing-hooks` package directory, resolved from this\n * package's own dependency graph. SDKs inject it at build time so the runtime module hook can\n * load the package even where the bare specifier doesn't resolve (bundled SDK code under\n * isolated installs, e.g. pnpm).\n */\nexport function getTracingHooksDirectory(): string {\n const packageJsonPath = getOrchestrionRequire().resolve('@apm-js-collab/tracing-hooks/package.json');\n // This avoids any backslash-escaping concerns on Windows\n return dirname(packageJsonPath).replace(/\\\\/g, '/');\n}\n\n/** The central instrumentation config, to pass as the loader's `instrumentations` option. */\nexport function getSentryInstrumentations(): InstrumentationConfig[] {\n return SENTRY_INSTRUMENTATIONS;\n}\n\n/**\n * The code-transform webpack plugin, pre-fed the instrumentation config. Unlike the Vite plugin it\n * does NOT inject the `__SENTRY_ORCHESTRION__.bundler` marker — that would disable the runtime\n * module hook, which externalized packages still need (hybrid setup).\n */\nexport function sentryOrchestrionWebpackPlugin(): unknown {\n const mod = getOrchestrionRequire()('@apm-js-collab/code-transformer-bundler-plugins/webpack') as {\n default?: (options: { instrumentations: InstrumentationConfig[] }) => unknown;\n };\n const codeTransformerWebpack = mod.default ?? (mod as unknown as NonNullable<typeof mod.default>);\n return codeTransformerWebpack({ instrumentations: SENTRY_INSTRUMENTATIONS });\n}\n"],"names":[],"mappings":";;;;AAUA,SAAS,qBAAA,GAA0D;AACjE,EAAA,IAAI,WAAA;AAAA,EACJ,WAAA,GAAA,aAAA,CAAA,MAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AACA,EAAA,OAAA;AAAsC;AAEtC,SAAA,wBAAA,GAAA;AACA,EAAA,OAAA,qBAA4B,2EAAe,CAAA;AAAA;AAE3C,SAAO,wBAAA,GAAA;AACT,EAAA,MAAA,eAAA,GAAA,qBAAA,EAAA,CAAA,OAAA,CAAA,2CAAA,CAAA;AAGO,EAAA,OAAA,OAAS,CAAA,eAAA,CAAA,CAAA,OAAA,CAAA,KAAmC,EAAA,GAAA,CAAA;AACjD;AACF,SAAA,yBAAA,GAAA;AAQO,EAAA,OAAA,uBAAS;AACd;AAEA,SAAO,iCAAwC;AACjD,EAAA,MAAA,GAAA,GAAA,qBAAA,EAAA,CAAA,yDAAA,CAAA;AAGO,EAAA,MAAA,sBAAS,GAAA,GAAA,CAAA,OAAqD,IAAA,GAAA;AACnE,EAAA,OAAO,sBAAA,CAAA,EAAA,gBAAA,EAAA,uBAAA,EAAA,CAAA;AACT;;;;"}
|
|
@@ -1,33 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { lruMemoizerChannels } from './config/lru-memoizer.js';
|
|
3
|
-
import { ioredisChannels } from './config/ioredis.js';
|
|
4
|
-
import { pgChannels } from './config/pg.js';
|
|
5
|
-
import { postgresJsChannels } from './config/postgres.js';
|
|
6
|
-
import { openaiChannels } from './config/openai.js';
|
|
1
|
+
import { amqplibChannels } from './config/amqplib.js';
|
|
7
2
|
import { anthropicAiChannels } from './config/anthropic-ai.js';
|
|
3
|
+
import { dataloaderChannels } from './config/dataloader.js';
|
|
4
|
+
import { expressChannels } from './config/express.js';
|
|
5
|
+
import { firebaseChannels } from './config/firebase.js';
|
|
6
|
+
import { genericPoolChannels } from './config/generic-pool.js';
|
|
8
7
|
import { googleGenAiChannels } from './config/google-genai.js';
|
|
9
|
-
import {
|
|
10
|
-
import { amqplibChannels } from './config/amqplib.js';
|
|
8
|
+
import { graphqlChannels } from './config/graphql.js';
|
|
11
9
|
import { hapiChannels } from './config/hapi.js';
|
|
10
|
+
import { ioredisChannels } from './config/ioredis.js';
|
|
11
|
+
import { kafkajsChannels } from './config/kafkajs.js';
|
|
12
|
+
import { knexChannels } from './config/knex.js';
|
|
13
|
+
import { langchainChannels } from './config/langchain.js';
|
|
14
|
+
import { langgraphChannels } from './config/langgraph.js';
|
|
15
|
+
import { lruMemoizerChannels } from './config/lru-memoizer.js';
|
|
16
|
+
import { mongodbChannels } from './config/mongodb.js';
|
|
17
|
+
import { mongooseChannels } from './config/mongoose.js';
|
|
18
|
+
import { mysql2Channels } from './config/mysql2.js';
|
|
19
|
+
import { mysqlChannels } from './config/mysql.js';
|
|
20
|
+
import { nestjsChannels } from './config/nestjs.js';
|
|
21
|
+
import { openaiChannels } from './config/openai.js';
|
|
22
|
+
import { pgChannels } from './config/pg.js';
|
|
23
|
+
import { postgresJsChannels } from './config/postgres.js';
|
|
24
|
+
import { prismaChannels } from './config/prisma.js';
|
|
25
|
+
import { reactRouterChannels } from './config/react-router.js';
|
|
12
26
|
import { redisChannels } from './config/redis.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
27
|
+
import { remixChannels } from './config/remix.js';
|
|
28
|
+
import { tediousChannels } from './config/tedious.js';
|
|
29
|
+
import { vercelAiChannels } from './config/vercel-ai.js';
|
|
15
30
|
|
|
16
31
|
const CHANNELS = {
|
|
17
|
-
...
|
|
18
|
-
...lruMemoizerChannels,
|
|
19
|
-
...ioredisChannels,
|
|
20
|
-
...pgChannels,
|
|
21
|
-
...postgresJsChannels,
|
|
22
|
-
...openaiChannels,
|
|
32
|
+
...amqplibChannels,
|
|
23
33
|
...anthropicAiChannels,
|
|
34
|
+
...dataloaderChannels,
|
|
35
|
+
...expressChannels,
|
|
36
|
+
...firebaseChannels,
|
|
37
|
+
...genericPoolChannels,
|
|
24
38
|
...googleGenAiChannels,
|
|
25
|
-
...
|
|
26
|
-
...amqplibChannels,
|
|
39
|
+
...graphqlChannels,
|
|
27
40
|
...hapiChannels,
|
|
41
|
+
...ioredisChannels,
|
|
42
|
+
...kafkajsChannels,
|
|
43
|
+
...knexChannels,
|
|
44
|
+
...langchainChannels,
|
|
45
|
+
...langgraphChannels,
|
|
46
|
+
...lruMemoizerChannels,
|
|
47
|
+
...mongodbChannels,
|
|
48
|
+
...mongooseChannels,
|
|
49
|
+
...mysql2Channels,
|
|
50
|
+
...mysqlChannels,
|
|
51
|
+
...nestjsChannels,
|
|
52
|
+
...openaiChannels,
|
|
53
|
+
...pgChannels,
|
|
54
|
+
...postgresJsChannels,
|
|
55
|
+
...prismaChannels,
|
|
56
|
+
...reactRouterChannels,
|
|
28
57
|
...redisChannels,
|
|
29
|
-
...
|
|
30
|
-
...
|
|
58
|
+
...remixChannels,
|
|
59
|
+
...tediousChannels,
|
|
60
|
+
...vercelAiChannels
|
|
31
61
|
};
|
|
32
62
|
|
|
33
63
|
export { CHANNELS };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels.js","sources":["../../../src/orchestrion/channels.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"channels.js","sources":["../../../src/orchestrion/channels.ts"],"sourcesContent":["import { amqplibChannels } from './config/amqplib';\nimport { anthropicAiChannels } from './config/anthropic-ai';\nimport { dataloaderChannels } from './config/dataloader';\nimport { expressChannels } from './config/express';\nimport { firebaseChannels } from './config/firebase';\nimport { genericPoolChannels } from './config/generic-pool';\nimport { googleGenAiChannels } from './config/google-genai';\nimport { graphqlChannels } from './config/graphql';\nimport { hapiChannels } from './config/hapi';\nimport { ioredisChannels } from './config/ioredis';\nimport { kafkajsChannels } from './config/kafkajs';\nimport { knexChannels } from './config/knex';\nimport { langchainChannels } from './config/langchain';\nimport { langgraphChannels } from './config/langgraph';\nimport { lruMemoizerChannels } from './config/lru-memoizer';\nimport { mongodbChannels } from './config/mongodb';\nimport { mongooseChannels } from './config/mongoose';\nimport { mysql2Channels } from './config/mysql2';\nimport { mysqlChannels } from './config/mysql';\nimport { nestjsChannels } from './config/nestjs';\nimport { openaiChannels } from './config/openai';\nimport { pgChannels } from './config/pg';\nimport { postgresJsChannels } from './config/postgres';\nimport { prismaChannels } from './config/prisma';\nimport { reactRouterChannels } from './config/react-router';\nimport { redisChannels } from './config/redis';\nimport { remixChannels } from './config/remix';\nimport { tediousChannels } from './config/tedious';\nimport { vercelAiChannels } from './config/vercel-ai';\n\n/**\n * Fully-qualified `diagnostics_channel` names that orchestrion publishes to.\n *\n * Orchestrion's transform always prefixes the configured `channelName` with\n * `orchestrion:${module.name}:`. So a config of\n * `{ channelName: 'query', module: { name: 'mysql' } }`\n * publishes to `orchestrion:mysql:query`.\n *\n * Subscribers (`integrations/<lib>/tracing-channel.ts`) consume the full\n * prefixed string from this map; the config files set only the unprefixed\n * suffix in `channelName`. Keeping both pieces in one file is what guarantees\n * they don't drift apart and silently stop firing.\n *\n * Kept sorted alphabetically by module so concurrent additions insert at different\n * points rather than all appending to the end (fewer merge conflicts).\n */\nexport const CHANNELS = {\n ...amqplibChannels,\n ...anthropicAiChannels,\n ...dataloaderChannels,\n ...expressChannels,\n ...firebaseChannels,\n ...genericPoolChannels,\n ...googleGenAiChannels,\n ...graphqlChannels,\n ...hapiChannels,\n ...ioredisChannels,\n ...kafkajsChannels,\n ...knexChannels,\n ...langchainChannels,\n ...langgraphChannels,\n ...lruMemoizerChannels,\n ...mongodbChannels,\n ...mongooseChannels,\n ...mysql2Channels,\n ...mysqlChannels,\n ...nestjsChannels,\n ...openaiChannels,\n ...pgChannels,\n ...postgresJsChannels,\n ...prismaChannels,\n ...reactRouterChannels,\n ...redisChannels,\n ...remixChannels,\n ...tediousChannels,\n ...vercelAiChannels,\n} as const;\n\nexport type ChannelName = (typeof CHANNELS)[keyof typeof CHANNELS];\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CO,MAAM,QAAA,GAAW;AAAA,EACtB,GAAG,eAAA;AAAA,EACH,GAAG,mBAAA;AAAA,EACH,GAAG,kBAAA;AAAA,EACH,GAAG,eAAA;AAAA,EACH,GAAG,gBAAA;AAAA,EACH,GAAG,mBAAA;AAAA,EACH,GAAG,mBAAA;AAAA,EACH,GAAG,eAAA;AAAA,EACH,GAAG,YAAA;AAAA,EACH,GAAG,eAAA;AAAA,EACH,GAAG,eAAA;AAAA,EACH,GAAG,YAAA;AAAA,EACH,GAAG,iBAAA;AAAA,EACH,GAAG,iBAAA;AAAA,EACH,GAAG,mBAAA;AAAA,EACH,GAAG,eAAA;AAAA,EACH,GAAG,gBAAA;AAAA,EACH,GAAG,cAAA;AAAA,EACH,GAAG,aAAA;AAAA,EACH,GAAG,cAAA;AAAA,EACH,GAAG,cAAA;AAAA,EACH,GAAG,UAAA;AAAA,EACH,GAAG,kBAAA;AAAA,EACH,GAAG,cAAA;AAAA,EACH,GAAG,mBAAA;AAAA,EACH,GAAG,aAAA;AAAA,EACH,GAAG,aAAA;AAAA,EACH,GAAG,eAAA;AAAA,EACH,GAAG;AACL;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const module$1 = { name: "dataloader", versionRange: ">=2.0.0 <3", filePath: "index.js" };
|
|
2
|
+
const dataloaderConfig = [
|
|
3
|
+
// Wrap the constructor so the subscriber can wrap the user's `batchLoadFn` (arg 0). The batch span
|
|
4
|
+
// is opened when that wrapped function actually runs (on the deferred dispatch tick), mirroring the
|
|
5
|
+
// vendored OTel instrumentation which also wraps `batchLoadFn` at construction time.
|
|
6
|
+
{
|
|
7
|
+
channelName: "construct",
|
|
8
|
+
module: module$1,
|
|
9
|
+
functionQuery: { functionName: "DataLoader", kind: "Sync" }
|
|
10
|
+
},
|
|
11
|
+
// `load`/`loadMany` return Promises, so they're `Async`: the span ends on `asyncEnd` (when the
|
|
12
|
+
// load resolves), capturing the real latency and enclosing the deferred `batch` span — matching the
|
|
13
|
+
// vendored OTel `startSpan`. `prime`/`clear`/`clearAll` return `this` synchronously, so they stay `Sync`.
|
|
14
|
+
{
|
|
15
|
+
channelName: "load",
|
|
16
|
+
module: module$1,
|
|
17
|
+
functionQuery: { expressionName: "load", kind: "Async" }
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
channelName: "loadMany",
|
|
21
|
+
module: module$1,
|
|
22
|
+
functionQuery: { expressionName: "loadMany", kind: "Async" }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
channelName: "prime",
|
|
26
|
+
module: module$1,
|
|
27
|
+
functionQuery: { expressionName: "prime", kind: "Sync" }
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
channelName: "clear",
|
|
31
|
+
module: module$1,
|
|
32
|
+
functionQuery: { expressionName: "clear", kind: "Sync" }
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
channelName: "clearAll",
|
|
36
|
+
module: module$1,
|
|
37
|
+
functionQuery: { expressionName: "clearAll", kind: "Sync" }
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
const dataloaderChannels = {
|
|
41
|
+
DATALOADER_CONSTRUCT: "orchestrion:dataloader:construct",
|
|
42
|
+
DATALOADER_LOAD: "orchestrion:dataloader:load",
|
|
43
|
+
DATALOADER_LOAD_MANY: "orchestrion:dataloader:loadMany",
|
|
44
|
+
DATALOADER_PRIME: "orchestrion:dataloader:prime",
|
|
45
|
+
DATALOADER_CLEAR: "orchestrion:dataloader:clear",
|
|
46
|
+
DATALOADER_CLEAR_ALL: "orchestrion:dataloader:clearAll"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { dataloaderChannels, dataloaderConfig };
|
|
50
|
+
//# sourceMappingURL=dataloader.js.map
|