@sentry/server-utils 10.65.0 → 10.67.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 +18 -8
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/aws-sdk/constants.js +16 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/constants.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/index.js +154 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/index.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js +46 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js +47 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js +419 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/dynamodb.js +131 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/dynamodb.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/kinesis.js +21 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/kinesis.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/lambda.js +64 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/lambda.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/s3.js +21 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/s3.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/secretsmanager.js +27 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/secretsmanager.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/sns.js +63 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/sns.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/sqs.js +116 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/sqs.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/stepfunctions.js +25 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/services/stepfunctions.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/utils.js +30 -0
- package/build/cjs/integrations/tracing-channel/aws-sdk/utils.js.map +1 -0
- 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/express/instrumentation.js +1 -6
- package/build/cjs/integrations/tracing-channel/express/instrumentation.js.map +1 -1
- 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/koa.js +146 -0
- package/build/cjs/integrations/tracing-channel/koa.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/langchain.js +63 -0
- package/build/cjs/integrations/tracing-channel/langchain.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/langgraph.js +100 -0
- package/build/cjs/integrations/tracing-channel/langgraph.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/mongodb.js +104 -0
- package/build/cjs/integrations/tracing-channel/mongodb.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/mongoose.js +110 -0
- package/build/cjs/integrations/tracing-channel/mongoose.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/integrations/tracing-channel/openai.js +1 -3
- package/build/cjs/integrations/tracing-channel/openai.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/redis.js +25 -34
- package/build/cjs/integrations/tracing-channel/redis.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/tedious.js +145 -0
- package/build/cjs/integrations/tracing-channel/tedious.js.map +1 -0
- package/build/cjs/mongodb/mongodb-span.js +133 -0
- package/build/cjs/mongodb/mongodb-span.js.map +1 -0
- package/build/cjs/mongoose/index.js.map +1 -1
- package/build/cjs/mongoose/mongoose-legacy-span.js +40 -0
- package/build/cjs/mongoose/mongoose-legacy-span.js.map +1 -0
- package/build/cjs/orchestrion/bundler/esbuild.js +15 -0
- package/build/cjs/orchestrion/bundler/esbuild.js.map +1 -0
- package/build/cjs/orchestrion/bundler/options.js +24 -0
- package/build/cjs/orchestrion/bundler/options.js.map +1 -0
- package/build/cjs/orchestrion/bundler/rollup.js +15 -0
- package/build/cjs/orchestrion/bundler/rollup.js.map +1 -0
- package/build/cjs/orchestrion/bundler/vite.js +8 -21
- package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
- package/build/cjs/orchestrion/bundler/webpack.js +36 -0
- package/build/cjs/orchestrion/bundler/webpack.js.map +1 -0
- package/build/cjs/orchestrion/channels.js +54 -20
- package/build/cjs/orchestrion/channels.js.map +1 -1
- package/build/cjs/orchestrion/config/amqplib.js.map +1 -1
- package/build/cjs/orchestrion/config/anthropic-ai.js.map +1 -1
- package/build/cjs/orchestrion/config/aws-sdk.js +28 -0
- package/build/cjs/orchestrion/config/aws-sdk.js.map +1 -0
- package/build/cjs/orchestrion/config/dataloader.js +53 -0
- package/build/cjs/orchestrion/config/dataloader.js.map +1 -0
- package/build/cjs/orchestrion/config/express.js +9 -8
- package/build/cjs/orchestrion/config/express.js.map +1 -1
- 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/google-genai.js.map +1 -1
- package/build/cjs/orchestrion/config/graphql.js.map +1 -1
- package/build/cjs/orchestrion/config/hapi.js.map +1 -1
- package/build/cjs/orchestrion/config/index.js +64 -23
- package/build/cjs/orchestrion/config/index.js.map +1 -1
- package/build/cjs/orchestrion/config/ioredis.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/koa.js +16 -0
- package/build/cjs/orchestrion/config/koa.js.map +1 -0
- package/build/cjs/orchestrion/config/langchain.js +52 -0
- package/build/cjs/orchestrion/config/langchain.js.map +1 -0
- package/build/cjs/orchestrion/config/langgraph.js +28 -0
- package/build/cjs/orchestrion/config/langgraph.js.map +1 -0
- package/build/cjs/orchestrion/config/lru-memoizer.js.map +1 -1
- package/build/cjs/orchestrion/config/mongodb.js +67 -0
- package/build/cjs/orchestrion/config/mongodb.js.map +1 -0
- package/build/cjs/orchestrion/config/mongoose.js +107 -0
- package/build/cjs/orchestrion/config/mongoose.js.map +1 -0
- package/build/cjs/orchestrion/config/mysql.js.map +1 -1
- 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/openai.js +5 -5
- package/build/cjs/orchestrion/config/openai.js.map +1 -1
- package/build/cjs/orchestrion/config/pg.js.map +1 -1
- package/build/cjs/orchestrion/config/postgres.js.map +1 -1
- 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/redis.js.map +1 -1
- package/build/cjs/orchestrion/config/remix.js +54 -0
- package/build/cjs/orchestrion/config/remix.js.map +1 -0
- package/build/cjs/orchestrion/config/tedious.js +24 -0
- package/build/cjs/orchestrion/config/tedious.js.map +1 -0
- package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -1
- package/build/cjs/orchestrion/detect.js +12 -11
- package/build/cjs/orchestrion/detect.js.map +1 -1
- package/build/cjs/orchestrion/index.js +44 -6
- package/build/cjs/orchestrion/index.js.map +1 -1
- package/build/cjs/orchestrion/runtime/register.js +45 -21
- 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/redis/redis-dc-subscriber.js +27 -38
- package/build/cjs/redis/redis-dc-subscriber.js.map +1 -1
- 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/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js +16 -3
- package/build/cjs/vercel-ai/vercel-ai-orchestrion-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 +3 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/tracing-channel/aws-sdk/constants.js +9 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/constants.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/index.js +152 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/index.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js +41 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js +45 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js +417 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/dynamodb.js +129 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/dynamodb.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/kinesis.js +19 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/kinesis.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/lambda.js +62 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/lambda.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/s3.js +19 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/s3.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/secretsmanager.js +25 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/secretsmanager.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/sns.js +61 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/sns.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/sqs.js +114 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/sqs.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/stepfunctions.js +23 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/services/stepfunctions.js.map +1 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/utils.js +26 -0
- package/build/esm/integrations/tracing-channel/aws-sdk/utils.js.map +1 -0
- 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/express/instrumentation.js +1 -6
- package/build/esm/integrations/tracing-channel/express/instrumentation.js.map +1 -1
- 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/koa.js +144 -0
- package/build/esm/integrations/tracing-channel/koa.js.map +1 -0
- package/build/esm/integrations/tracing-channel/langchain.js +61 -0
- package/build/esm/integrations/tracing-channel/langchain.js.map +1 -0
- package/build/esm/integrations/tracing-channel/langgraph.js +98 -0
- package/build/esm/integrations/tracing-channel/langgraph.js.map +1 -0
- package/build/esm/integrations/tracing-channel/mongodb.js +102 -0
- package/build/esm/integrations/tracing-channel/mongodb.js.map +1 -0
- package/build/esm/integrations/tracing-channel/mongoose.js +108 -0
- package/build/esm/integrations/tracing-channel/mongoose.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/integrations/tracing-channel/openai.js +1 -3
- package/build/esm/integrations/tracing-channel/openai.js.map +1 -1
- package/build/esm/integrations/tracing-channel/redis.js +25 -34
- package/build/esm/integrations/tracing-channel/redis.js.map +1 -1
- package/build/esm/integrations/tracing-channel/tedious.js +143 -0
- package/build/esm/integrations/tracing-channel/tedious.js.map +1 -0
- package/build/esm/mongodb/mongodb-span.js +126 -0
- package/build/esm/mongodb/mongodb-span.js.map +1 -0
- package/build/esm/mongoose/index.js.map +1 -1
- package/build/esm/mongoose/mongoose-legacy-span.js +38 -0
- package/build/esm/mongoose/mongoose-legacy-span.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 +22 -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 +54 -20
- package/build/esm/orchestrion/channels.js.map +1 -1
- package/build/esm/orchestrion/config/amqplib.js.map +1 -1
- package/build/esm/orchestrion/config/anthropic-ai.js.map +1 -1
- package/build/esm/orchestrion/config/aws-sdk.js +25 -0
- package/build/esm/orchestrion/config/aws-sdk.js.map +1 -0
- package/build/esm/orchestrion/config/dataloader.js +50 -0
- package/build/esm/orchestrion/config/dataloader.js.map +1 -0
- package/build/esm/orchestrion/config/express.js +9 -8
- package/build/esm/orchestrion/config/express.js.map +1 -1
- 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/google-genai.js.map +1 -1
- package/build/esm/orchestrion/config/graphql.js.map +1 -1
- package/build/esm/orchestrion/config/hapi.js.map +1 -1
- package/build/esm/orchestrion/config/index.js +64 -24
- package/build/esm/orchestrion/config/index.js.map +1 -1
- package/build/esm/orchestrion/config/ioredis.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/koa.js +13 -0
- package/build/esm/orchestrion/config/koa.js.map +1 -0
- package/build/esm/orchestrion/config/langchain.js +48 -0
- package/build/esm/orchestrion/config/langchain.js.map +1 -0
- package/build/esm/orchestrion/config/langgraph.js +25 -0
- package/build/esm/orchestrion/config/langgraph.js.map +1 -0
- package/build/esm/orchestrion/config/lru-memoizer.js.map +1 -1
- package/build/esm/orchestrion/config/mongodb.js +64 -0
- package/build/esm/orchestrion/config/mongodb.js.map +1 -0
- package/build/esm/orchestrion/config/mongoose.js +103 -0
- package/build/esm/orchestrion/config/mongoose.js.map +1 -0
- package/build/esm/orchestrion/config/mysql.js.map +1 -1
- 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/openai.js +5 -5
- package/build/esm/orchestrion/config/openai.js.map +1 -1
- package/build/esm/orchestrion/config/pg.js.map +1 -1
- package/build/esm/orchestrion/config/postgres.js.map +1 -1
- 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/redis.js.map +1 -1
- package/build/esm/orchestrion/config/remix.js +51 -0
- package/build/esm/orchestrion/config/remix.js.map +1 -0
- package/build/esm/orchestrion/config/tedious.js +21 -0
- package/build/esm/orchestrion/config/tedious.js.map +1 -0
- package/build/esm/orchestrion/config/vercel-ai.js.map +1 -1
- package/build/esm/orchestrion/detect.js +13 -12
- package/build/esm/orchestrion/detect.js.map +1 -1
- package/build/esm/orchestrion/index.js +26 -2
- package/build/esm/orchestrion/index.js.map +1 -1
- package/build/esm/orchestrion/runtime/register.js +47 -23
- 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/redis/redis-dc-subscriber.js +27 -38
- package/build/esm/redis/redis-dc-subscriber.js.map +1 -1
- 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/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js +17 -4
- package/build/esm/vercel-ai/vercel-ai-orchestrion-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 +7 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/aws-sdk/aws-sdk.types.d.ts +43 -0
- package/build/types/integrations/tracing-channel/aws-sdk/aws-sdk.types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/constants.d.ts +15 -0
- package/build/types/integrations/tracing-channel/aws-sdk/constants.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/index.d.ts +15 -0
- package/build/types/integrations/tracing-channel/aws-sdk/index.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/MessageAttributes.d.ts +23 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/MessageAttributes.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/ServiceExtension.d.ts +9 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/ServiceExtension.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.d.ts +10 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.d.ts +14 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/dynamodb.d.ts +8 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/dynamodb.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/index.d.ts +2 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/index.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/kinesis.d.ts +6 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/kinesis.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/lambda.d.ts +9 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/lambda.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/s3.d.ts +6 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/s3.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/secretsmanager.d.ts +8 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/secretsmanager.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/sns.d.ts +9 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/sns.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/sqs.d.ts +9 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/sqs.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/stepfunctions.d.ts +6 -0
- package/build/types/integrations/tracing-channel/aws-sdk/services/stepfunctions.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/types.d.ts +26 -0
- package/build/types/integrations/tracing-channel/aws-sdk/types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/aws-sdk/utils.d.ts +5 -0
- package/build/types/integrations/tracing-channel/aws-sdk/utils.d.ts.map +1 -0
- 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/express/instrumentation.d.ts.map +1 -1
- 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/koa.d.ts +14 -0
- package/build/types/integrations/tracing-channel/koa.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/langchain.d.ts +10 -0
- package/build/types/integrations/tracing-channel/langchain.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/langgraph.d.ts +10 -0
- package/build/types/integrations/tracing-channel/langgraph.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/mongodb.d.ts +12 -0
- package/build/types/integrations/tracing-channel/mongodb.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/mongoose.d.ts +15 -0
- package/build/types/integrations/tracing-channel/mongoose.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/integrations/tracing-channel/openai.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/redis.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/tedious.d.ts +11 -0
- package/build/types/integrations/tracing-channel/tedious.d.ts.map +1 -0
- package/build/types/mongodb/mongodb-span.d.ts +66 -0
- package/build/types/mongodb/mongodb-span.d.ts.map +1 -0
- package/build/types/mongoose/index.d.ts +2 -0
- package/build/types/mongoose/index.d.ts.map +1 -1
- package/build/types/mongoose/mongoose-legacy-span.d.ts +29 -0
- package/build/types/mongoose/mongoose-legacy-span.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 +29 -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 +94 -37
- package/build/types/orchestrion/channels.d.ts.map +1 -1
- package/build/types/orchestrion/config/aws-sdk.d.ts +19 -0
- package/build/types/orchestrion/config/aws-sdk.d.ts.map +1 -0
- 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/express.d.ts +2 -4
- package/build/types/orchestrion/config/express.d.ts.map +1 -1
- 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 +19 -6
- package/build/types/orchestrion/config/index.d.ts.map +1 -1
- package/build/types/orchestrion/config/ioredis.d.ts +1 -1
- package/build/types/orchestrion/config/ioredis.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/koa.d.ts +17 -0
- package/build/types/orchestrion/config/koa.d.ts.map +1 -0
- package/build/types/orchestrion/config/langchain.d.ts +18 -0
- package/build/types/orchestrion/config/langchain.d.ts.map +1 -0
- package/build/types/orchestrion/config/langgraph.d.ts +21 -0
- package/build/types/orchestrion/config/langgraph.d.ts.map +1 -0
- package/build/types/orchestrion/config/mongodb.d.ts +59 -0
- package/build/types/orchestrion/config/mongodb.d.ts.map +1 -0
- package/build/types/orchestrion/config/mongoose.d.ts +40 -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/openai.d.ts +0 -2
- package/build/types/orchestrion/config/openai.d.ts.map +1 -1
- package/build/types/orchestrion/config/postgres.d.ts +1 -1
- package/build/types/orchestrion/config/postgres.d.ts.map +1 -1
- 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 +9 -0
- package/build/types/orchestrion/config/remix.d.ts.map +1 -0
- package/build/types/orchestrion/config/tedious.d.ts +12 -0
- package/build/types/orchestrion/config/tedious.d.ts.map +1 -0
- package/build/types/orchestrion/config/vercel-ai.d.ts +1 -1
- package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -1
- 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 +56 -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/vercel-ai/vercel-ai-orchestrion-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 +7 -1
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/aws-sdk.types.d.ts +43 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/constants.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/index.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/MessageAttributes.d.ts +23 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/ServiceExtension.d.ts +9 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.d.ts +14 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/dynamodb.d.ts +8 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/index.d.ts +2 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/kinesis.d.ts +6 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/lambda.d.ts +9 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/s3.d.ts +6 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/secretsmanager.d.ts +8 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/sns.d.ts +9 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/sqs.d.ts +9 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/stepfunctions.d.ts +6 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/types.d.ts +26 -0
- package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/utils.d.ts +5 -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/koa.d.ts +14 -0
- package/build/types-ts3.8/integrations/tracing-channel/langchain.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/langgraph.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/mongodb.d.ts +12 -0
- package/build/types-ts3.8/integrations/tracing-channel/mongoose.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing-channel/mysql2.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing-channel/tedious.d.ts +11 -0
- package/build/types-ts3.8/mongodb/mongodb-span.d.ts +66 -0
- package/build/types-ts3.8/mongoose/index.d.ts +2 -0
- package/build/types-ts3.8/mongoose/mongoose-legacy-span.d.ts +29 -0
- package/build/types-ts3.8/orchestrion/bundler/esbuild.d.ts +21 -0
- package/build/types-ts3.8/orchestrion/bundler/options.d.ts +29 -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 +94 -37
- package/build/types-ts3.8/orchestrion/config/aws-sdk.d.ts +19 -0
- package/build/types-ts3.8/orchestrion/config/dataloader.d.ts +46 -0
- package/build/types-ts3.8/orchestrion/config/express.d.ts +2 -4
- 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 +19 -6
- package/build/types-ts3.8/orchestrion/config/ioredis.d.ts +1 -1
- 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/koa.d.ts +17 -0
- package/build/types-ts3.8/orchestrion/config/langchain.d.ts +18 -0
- package/build/types-ts3.8/orchestrion/config/langgraph.d.ts +21 -0
- package/build/types-ts3.8/orchestrion/config/mongodb.d.ts +59 -0
- package/build/types-ts3.8/orchestrion/config/mongoose.d.ts +40 -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/openai.d.ts +0 -2
- package/build/types-ts3.8/orchestrion/config/postgres.d.ts +1 -1
- 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 +9 -0
- package/build/types-ts3.8/orchestrion/config/tedious.d.ts +12 -0
- package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +1 -1
- package/build/types-ts3.8/orchestrion/detect.d.ts +3 -10
- package/build/types-ts3.8/orchestrion/index.d.ts +56 -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 +40 -8
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const diagnosticsChannel = require('node:diagnostics_channel');
|
|
4
|
+
const core = require('@sentry/core');
|
|
5
|
+
const debugBuild = require('../../debug-build.js');
|
|
6
|
+
const channels = require('../../orchestrion/channels.js');
|
|
7
|
+
const tracingChannel = require('../../tracing-channel.js');
|
|
8
|
+
|
|
9
|
+
const INTEGRATION_NAME = core.LANGGRAPH_INTEGRATION_NAME;
|
|
10
|
+
let subscribed = false;
|
|
11
|
+
let insideCreateReactAgent = false;
|
|
12
|
+
const _langGraphChannelIntegration = ((options = {}) => {
|
|
13
|
+
return {
|
|
14
|
+
name: INTEGRATION_NAME,
|
|
15
|
+
setupOnce() {
|
|
16
|
+
if (!diagnosticsChannel.tracingChannel || subscribed) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
subscribed = true;
|
|
20
|
+
const resolvedOptions = core.resolveAIRecordingOptions(options);
|
|
21
|
+
const sentryHandler = core.createLangChainCallbackHandler(resolvedOptions);
|
|
22
|
+
core.waitForTracingChannelBinding(() => {
|
|
23
|
+
debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion:langgraph] subscribing to channel "${channels.CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE}"`);
|
|
24
|
+
tracingChannel.bindTracingChannelToSpan(
|
|
25
|
+
diagnosticsChannel.tracingChannel(channels.CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE),
|
|
26
|
+
(data) => {
|
|
27
|
+
if (insideCreateReactAgent) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
const compileOptions = getFirstArgObject(data.arguments);
|
|
31
|
+
const name = typeof compileOptions?.name === "string" ? compileOptions.name : void 0;
|
|
32
|
+
return core.startInactiveSpan(core._INTERNAL_getLangGraphCreateAgentSpanOptions(name));
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
beforeSpanEnd: (_span, data) => {
|
|
36
|
+
wrapCompiledGraphInvoke(
|
|
37
|
+
data.result,
|
|
38
|
+
getFirstArgObject(data.arguments) ?? {},
|
|
39
|
+
resolvedOptions,
|
|
40
|
+
null,
|
|
41
|
+
sentryHandler
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion:langgraph] subscribing to channel "${channels.CHANNELS.LANGGRAPH_CREATE_REACT_AGENT}"`);
|
|
47
|
+
const reactAgentChannel = diagnosticsChannel.tracingChannel(
|
|
48
|
+
channels.CHANNELS.LANGGRAPH_CREATE_REACT_AGENT
|
|
49
|
+
);
|
|
50
|
+
reactAgentChannel.start.subscribe((message) => {
|
|
51
|
+
insideCreateReactAgent = true;
|
|
52
|
+
try {
|
|
53
|
+
const { arguments: args } = message;
|
|
54
|
+
const params = getFirstArgObject(args);
|
|
55
|
+
if (params && Array.isArray(params.tools) && params.tools.length > 0) {
|
|
56
|
+
core.wrapToolsWithSpans(params.tools, resolvedOptions, core.extractAgentNameFromParams(args) ?? void 0);
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
debugBuild.DEBUG_BUILD && core.debug.error("[orchestrion:langgraph] failed to wrap createReactAgent tools", error);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
reactAgentChannel.end.subscribe((message) => {
|
|
63
|
+
insideCreateReactAgent = false;
|
|
64
|
+
const { arguments: args, result } = message;
|
|
65
|
+
const agentName = core.extractAgentNameFromParams(args) ?? void 0;
|
|
66
|
+
const compileOptions = agentName ? { name: agentName } : {};
|
|
67
|
+
wrapCompiledGraphInvoke(result, compileOptions, resolvedOptions, core.extractLLMFromParams(args), sentryHandler);
|
|
68
|
+
});
|
|
69
|
+
reactAgentChannel.error.subscribe(() => {
|
|
70
|
+
insideCreateReactAgent = false;
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
function getFirstArgObject(args) {
|
|
77
|
+
const first = (args ?? [])[0];
|
|
78
|
+
return typeof first === "object" && first !== null ? first : void 0;
|
|
79
|
+
}
|
|
80
|
+
function wrapCompiledGraphInvoke(graph, compileOptions, options, llm, sentryHandler) {
|
|
81
|
+
if (!graph || typeof graph !== "object") {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const compiledGraph = graph;
|
|
85
|
+
const originalInvoke = compiledGraph.invoke;
|
|
86
|
+
if (typeof originalInvoke === "function") {
|
|
87
|
+
compiledGraph.invoke = core.instrumentCompiledGraphInvoke(
|
|
88
|
+
originalInvoke.bind(compiledGraph),
|
|
89
|
+
compiledGraph,
|
|
90
|
+
compileOptions,
|
|
91
|
+
options,
|
|
92
|
+
llm,
|
|
93
|
+
sentryHandler
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const langGraphChannelIntegration = core.defineIntegration(_langGraphChannelIntegration);
|
|
98
|
+
|
|
99
|
+
exports.langGraphChannelIntegration = langGraphChannelIntegration;
|
|
100
|
+
//# sourceMappingURL=langgraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langgraph.js","sources":["../../../../src/integrations/tracing-channel/langgraph.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { CompiledGraph, IntegrationFn, LangGraphOptions } from '@sentry/core';\nimport {\n _INTERNAL_getLangGraphCreateAgentSpanOptions,\n createLangChainCallbackHandler,\n debug,\n defineIntegration,\n extractAgentNameFromParams,\n extractLLMFromParams,\n instrumentCompiledGraphInvoke,\n LANGGRAPH_INTEGRATION_NAME,\n resolveAIRecordingOptions,\n startInactiveSpan,\n waitForTracingChannelBinding,\n wrapToolsWithSpans,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Same name as the OTel integration by design: when enabled, the OTel 'LangGraph' integration is\n// dropped from the default set (see the Node opt-in loader).\nconst INTEGRATION_NAME = LANGGRAPH_INTEGRATION_NAME;\n\ninterface CompileChannelContext {\n arguments: unknown[];\n result?: unknown;\n}\n\ninterface CreateReactAgentChannelContext {\n arguments: unknown[];\n result?: unknown;\n}\n\nlet subscribed = false;\n\n// `createReactAgent` compiles a `StateGraph` internally; suppress the `create_agent` span for that\n// nested compile so a react agent gets a single `invoke_agent` span, matching the OTel path.\nlet insideCreateReactAgent = false;\n\nconst _langGraphChannelIntegration = ((options: LangGraphOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19, and a second `init()` would double-subscribe.\n if (!diagnosticsChannel.tracingChannel || subscribed) {\n return;\n }\n subscribed = true;\n\n const resolvedOptions = resolveAIRecordingOptions(options);\n const sentryHandler = createLangChainCallbackHandler(resolvedOptions);\n\n // `bindTracingChannelToSpan` needs the async-context binding that `initOpenTelemetry()` registers\n // after `setupOnce` runs, so wait for it before subscribing.\n waitForTracingChannelBinding(() => {\n // StateGraph.compile → `create_agent` span, then wrap the returned graph's `invoke`.\n DEBUG_BUILD &&\n debug.log(`[orchestrion:langgraph] subscribing to channel \"${CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE}\"`);\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<CompileChannelContext>(CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE),\n data => {\n if (insideCreateReactAgent) {\n return undefined;\n }\n const compileOptions = getFirstArgObject(data.arguments);\n const name = typeof compileOptions?.name === 'string' ? compileOptions.name : undefined;\n\n return startInactiveSpan(_INTERNAL_getLangGraphCreateAgentSpanOptions(name));\n },\n {\n beforeSpanEnd: (_span, data) => {\n wrapCompiledGraphInvoke(\n data.result,\n getFirstArgObject(data.arguments) ?? {},\n resolvedOptions,\n null,\n sentryHandler,\n );\n },\n },\n );\n\n // createReactAgent has no `create_agent` span of its own; it only wraps tools and the returned\n // graph's `invoke`. Tools are wrapped at `start` (before the agent runs), invoke at `end`.\n DEBUG_BUILD &&\n debug.log(`[orchestrion:langgraph] subscribing to channel \"${CHANNELS.LANGGRAPH_CREATE_REACT_AGENT}\"`);\n const reactAgentChannel = diagnosticsChannel.tracingChannel<CreateReactAgentChannelContext>(\n CHANNELS.LANGGRAPH_CREATE_REACT_AGENT,\n );\n reactAgentChannel.start.subscribe(message => {\n // `createReactAgent` runs synchronously and compiles a `StateGraph` internally, so the flag\n // must be on for the duration and off by `end`. It's set here (never in a branch that can\n // throw) and cleared in both `end` and `error`, so it can neither stick on across calls nor\n // stay off during this call's nested compile. Tool wrapping is guarded for the same reason.\n insideCreateReactAgent = true;\n try {\n const { arguments: args } = message as CreateReactAgentChannelContext;\n const params = getFirstArgObject(args);\n if (params && Array.isArray(params.tools) && params.tools.length > 0) {\n wrapToolsWithSpans(params.tools, resolvedOptions, extractAgentNameFromParams(args) ?? undefined);\n }\n } catch (error) {\n DEBUG_BUILD && debug.error('[orchestrion:langgraph] failed to wrap createReactAgent tools', error);\n }\n });\n reactAgentChannel.end.subscribe(message => {\n insideCreateReactAgent = false;\n const { arguments: args, result } = message as CreateReactAgentChannelContext;\n const agentName = extractAgentNameFromParams(args) ?? undefined;\n const compileOptions = agentName ? { name: agentName } : {};\n wrapCompiledGraphInvoke(result, compileOptions, resolvedOptions, extractLLMFromParams(args), sentryHandler);\n });\n // Make sure a thrown `createReactAgent` doesn't leave the suppression flag stuck on.\n reactAgentChannel.error.subscribe(() => {\n insideCreateReactAgent = false;\n });\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction getFirstArgObject(args: unknown[] | undefined): Record<string, unknown> | undefined {\n const first = (args ?? [])[0];\n\n return typeof first === 'object' && first !== null ? (first as Record<string, unknown>) : undefined;\n}\n\n/**\n * Wrap the compiled graph's `invoke` with the shared `invoke_agent` instrumentation, exactly as the\n * OTel path does on the returned graph.\n */\nfunction wrapCompiledGraphInvoke(\n graph: unknown,\n compileOptions: Record<string, unknown>,\n options: LangGraphOptions,\n llm: ReturnType<typeof extractLLMFromParams>,\n sentryHandler: unknown,\n): void {\n if (!graph || typeof graph !== 'object') {\n return;\n }\n\n const compiledGraph = graph as CompiledGraph;\n const originalInvoke = compiledGraph.invoke;\n if (typeof originalInvoke === 'function') {\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph),\n compiledGraph,\n compileOptions,\n options,\n llm,\n sentryHandler,\n );\n }\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven LangGraph integration. Subscribes to the diagnostics_channels\n * injected into `@langchain/langgraph`'s `StateGraph.compile` and `createReactAgent`, so it requires\n * the orchestrion runtime hook or bundler plugin.\n */\nexport const langGraphChannelIntegration = defineIntegration(_langGraphChannelIntegration);\n"],"names":["LANGGRAPH_INTEGRATION_NAME","resolveAIRecordingOptions","createLangChainCallbackHandler","waitForTracingChannelBinding","DEBUG_BUILD","debug","CHANNELS","bindTracingChannelToSpan","startInactiveSpan","_INTERNAL_getLangGraphCreateAgentSpanOptions","wrapToolsWithSpans","extractAgentNameFromParams","extractLLMFromParams","instrumentCompiledGraphInvoke","defineIntegration"],"mappings":";;;;;;;;AAsBA,MAAM,gBAAA,GAAmBA,+BAAA;AAYzB,IAAI,UAAA,GAAa,KAAA;AAIjB,IAAI,sBAAA,GAAyB,KAAA;AAE7B,MAAM,4BAAA,IAAgC,CAAC,OAAA,GAA4B,EAAC,KAAM;AACxE,EAAA,OAAO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,QAC3B,CAAC,CAAA;AAAA,MACH,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAEA,SAAS,kBAAkB,IAAA,EAAkE;AAC3F,EAAA,MAAM,KAAA,GAAA,CAAS,IAAA,IAAQ,EAAC,EAAG,CAAC,CAAA;AAE5B,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,OAAQ,KAAA,GAAoC,MAAA;AAC5F;AAMA,SAAS,uBAAA,CACP,KAAA,EACA,cAAA,EACA,OAAA,EACA,KACA,aAAA,EACM;AACN,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACvC,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,aAAA,GAAgB,KAAA;AACtB,EAAA,MAAM,iBAAiB,aAAA,CAAc,MAAA;AACrC,EAAA,IAAI,OAAO,mBAAmB,UAAA,EAAY;AACxC,IAAA,aAAA,CAAc,MAAA,GAASC,kCAAA;AAAA,MACrB,cAAA,CAAe,KAAK,aAAa,CAAA;AAAA,MACjC,aAAA;AAAA,MACA,cAAA;AAAA,MACA,OAAA;AAAA,MACA,GAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;AAOO,MAAM,2BAAA,GAA8BC,uBAAkB,4BAA4B;;;;"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const diagnosticsChannel = require('node:diagnostics_channel');
|
|
4
|
+
const core = require('@sentry/core');
|
|
5
|
+
const mongodbSpan = require('../../mongodb/mongodb-span.js');
|
|
6
|
+
const channels = require('../../orchestrion/channels.js');
|
|
7
|
+
const tracingChannel = require('../../tracing-channel.js');
|
|
8
|
+
|
|
9
|
+
const INTEGRATION_NAME = "Mongo";
|
|
10
|
+
const ORIGIN = "auto.db.orchestrion.mongo";
|
|
11
|
+
const V3_DEDICATED_COMMANDS = /* @__PURE__ */ new Set(["insert", "update", "delete", "find", "getMore", "killCursors"]);
|
|
12
|
+
const _mongodbChannelIntegration = (() => {
|
|
13
|
+
return {
|
|
14
|
+
name: INTEGRATION_NAME,
|
|
15
|
+
setupOnce() {
|
|
16
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
core.waitForTracingChannelBinding(() => {
|
|
20
|
+
subscribeV4Command();
|
|
21
|
+
subscribeV4Checkout();
|
|
22
|
+
subscribeV3Wireprotocol();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
function subscribeV4Command() {
|
|
28
|
+
tracingChannel.bindTracingChannelToSpan(
|
|
29
|
+
diagnosticsChannel.tracingChannel(channels.CHANNELS.MONGODB_COMMAND),
|
|
30
|
+
(data) => {
|
|
31
|
+
const args = data.arguments ?? [];
|
|
32
|
+
const ns = args[0];
|
|
33
|
+
const cmd = args[1];
|
|
34
|
+
if (!ns || !cmd || typeof cmd !== "object" || cmd.ismaster || cmd.hello) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
const operation = Object.keys(cmd)[0];
|
|
38
|
+
return mongodbSpan.startMongoSpan(mongodbSpan.getV4SpanAttributes(data.self, ns, cmd, operation, ORIGIN));
|
|
39
|
+
},
|
|
40
|
+
// Matches otel's `shouldSkipInstrumentation`: only trace when there is
|
|
41
|
+
// an active parent span, to avoid emitting orphaned mongodb spans.
|
|
42
|
+
{ requiresParentSpan: true }
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function subscribeV4Checkout() {
|
|
46
|
+
tracingChannel.bindTracingChannelToSpan(diagnosticsChannel.tracingChannel(channels.CHANNELS.MONGODB_CHECKOUT), () => void 0);
|
|
47
|
+
}
|
|
48
|
+
function subscribeV3Wireprotocol() {
|
|
49
|
+
for (const operation of ["insert", "update", "remove"]) {
|
|
50
|
+
const channel = operation === "insert" ? channels.CHANNELS.MONGODB_V3_INSERT : operation === "update" ? channels.CHANNELS.MONGODB_V3_UPDATE : channels.CHANNELS.MONGODB_V3_REMOVE;
|
|
51
|
+
bindV3(channel, (args) => ({
|
|
52
|
+
topology: args[0],
|
|
53
|
+
ns: args[1],
|
|
54
|
+
command: args[2]?.[0],
|
|
55
|
+
operation
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
bindV3(channels.CHANNELS.MONGODB_V3_COMMAND, (args) => {
|
|
59
|
+
const command = args[2];
|
|
60
|
+
const type = command ? Object.keys(command)[0] : void 0;
|
|
61
|
+
if (type && V3_DEDICATED_COMMANDS.has(type)) {
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
topology: args[0],
|
|
66
|
+
ns: args[1],
|
|
67
|
+
command,
|
|
68
|
+
operation: command ? mongodbSpan.getV3CommandOperation(command) : void 0
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
bindV3(channels.CHANNELS.MONGODB_V3_QUERY, (args) => ({
|
|
72
|
+
topology: args[0],
|
|
73
|
+
ns: args[1],
|
|
74
|
+
command: args[2],
|
|
75
|
+
operation: "find"
|
|
76
|
+
}));
|
|
77
|
+
bindV3(channels.CHANNELS.MONGODB_V3_GET_MORE, (args) => ({
|
|
78
|
+
topology: args[0],
|
|
79
|
+
ns: args[1],
|
|
80
|
+
command: args[2]?.cmd,
|
|
81
|
+
operation: "getMore"
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
function bindV3(channelName, extract) {
|
|
85
|
+
tracingChannel.bindTracingChannelToSpan(
|
|
86
|
+
diagnosticsChannel.tracingChannel(channelName),
|
|
87
|
+
(data) => {
|
|
88
|
+
const args = data.arguments;
|
|
89
|
+
if (!args) {
|
|
90
|
+
return void 0;
|
|
91
|
+
}
|
|
92
|
+
const info = extract(args);
|
|
93
|
+
if (!info || typeof info.ns !== "string") {
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
return mongodbSpan.startMongoSpan(mongodbSpan.getV3SpanAttributes(info.ns, info.topology, info.command, info.operation, ORIGIN));
|
|
97
|
+
},
|
|
98
|
+
{ requiresParentSpan: true }
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const mongodbChannelIntegration = core.defineIntegration(_mongodbChannelIntegration);
|
|
102
|
+
|
|
103
|
+
exports.mongodbChannelIntegration = mongodbChannelIntegration;
|
|
104
|
+
//# sourceMappingURL=mongodb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodb.js","sources":["../../../../src/integrations/tracing-channel/mongodb.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, waitForTracingChannelBinding } from '@sentry/core';\nimport type { MongodbNamespace, MongoV3Topology } from '../../mongodb/mongodb-span';\nimport {\n getV3CommandOperation,\n getV3SpanAttributes,\n getV4SpanAttributes,\n startMongoSpan,\n} from '../../mongodb/mongodb-span';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\nconst INTEGRATION_NAME = 'Mongo' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.mongo';\n\n/**\n * what orchestrion's transform attaches to a channel context:\n * `self` is the `this`, plus args.\n */\ninterface MongoChannelContext {\n self?: { address?: string };\n arguments?: unknown[];\n}\n\n// Details extracted from a v3 wireprotocol call's arguments to build its span.\ninterface V3CallInfo {\n topology: MongoV3Topology | undefined;\n ns: string;\n command: Record<string, unknown> | undefined;\n operation: string | undefined;\n}\n\n// Command doc first-keys whose span the `v3_command` channel must suppress.\n// The `insert`/`update`/`remove`/`query`/`getMore` functions call the shared\n// `command` function internally. Orchestrion transforms the `command` *source*\n// (unlike the vendored OTel patch, which wraps the module's exported reference\n// and misses internal calls), so `v3_command` would double-span the ones that\n// already have their own dedicated channel (`v3_insert`/`update`/`remove`/\n// `query`/`get_more`) without this guard.\n//\n// `killCursors` has no dedicated channel, but is suppressed too for OTel\n// parity: OTel wraps `wireprotocol/index.js`'s `command` property, which never\n// intercepts `kill_cursors.js`'s direct `require('./command')` call — so OTel\n// emits no killCursors span, and neither should we.\nconst V3_DEDICATED_COMMANDS = new Set(['insert', 'update', 'delete', 'find', 'getMore', 'killCursors']);\n\nconst _mongodbChannelIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n subscribeV4Command();\n subscribeV4Checkout();\n subscribeV3Wireprotocol();\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * `Connection.prototype.command` (mongodb >=4.0) one span per command.\n * Handles both the >=6.4 promise form and the >=4.0 <6.4 callback form\n * (both publish to this channel).\n */\nfunction subscribeV4Command(): void {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<MongoChannelContext>(CHANNELS.MONGODB_COMMAND),\n data => {\n const args = data.arguments ?? [];\n const ns = args[0] as MongodbNamespace | undefined;\n const cmd = args[1] as Record<string, unknown> | undefined;\n // Skip handshake/heartbeat commands (matches otel).\n if (!ns || !cmd || typeof cmd !== 'object' || cmd.ismaster || cmd.hello) {\n return undefined;\n }\n const operation = Object.keys(cmd)[0];\n return startMongoSpan(getV4SpanAttributes(data.self, ns, cmd, operation, ORIGIN));\n },\n // Matches otel's `shouldSkipInstrumentation`: only trace when there is\n // an active parent span, to avoid emitting orphaned mongodb spans.\n { requiresParentSpan: true },\n );\n}\n\n/**\n * `ConnectionPool.prototype.checkOut` (mongodb 4.0 - 6.3, callback form).\n * Creates no span (`getSpan` returns `undefined`) but the binding re-runs\n * the checkout callback under the caller's captured context, so the pooled\n * `command()` invoked inside it re-inherits the active span.\n */\nfunction subscribeV4Checkout(): void {\n bindTracingChannelToSpan(diagnosticsChannel.tracingChannel(CHANNELS.MONGODB_CHECKOUT), () => undefined);\n}\n\n/**\n * mongodb >=3.3 <4 had no unified `command`; each operation is a separate\n * `lib/core/wireprotocol` function with its own argument layout, so each\n * channel extracts topology/namespace/command/op differently before building\n * the span.\n */\nfunction subscribeV3Wireprotocol(): void {\n for (const operation of ['insert', 'update', 'remove'] as const) {\n const channel =\n operation === 'insert'\n ? CHANNELS.MONGODB_V3_INSERT\n : operation === 'update'\n ? CHANNELS.MONGODB_V3_UPDATE\n : CHANNELS.MONGODB_V3_REMOVE;\n bindV3(channel, args => ({\n topology: args[0] as MongoV3Topology | undefined,\n ns: args[1] as string,\n command: (args[2] as Record<string, unknown>[] | undefined)?.[0],\n operation,\n }));\n }\n\n // `command`(server, ns, cmd, options, callback) operation derived from the\n // command doc. Skips commands that have a dedicated channel. See set above.\n bindV3(CHANNELS.MONGODB_V3_COMMAND, args => {\n const command = args[2] as Record<string, unknown> | undefined;\n const type = command ? Object.keys(command)[0] : undefined;\n if (type && V3_DEDICATED_COMMANDS.has(type)) {\n return undefined;\n }\n return {\n topology: args[0] as MongoV3Topology | undefined,\n ns: args[1] as string,\n command,\n operation: command ? getV3CommandOperation(command) : undefined,\n };\n });\n\n // `query`(server, ns, cmd, cursorState, options, callback). a find.\n bindV3(CHANNELS.MONGODB_V3_QUERY, args => ({\n topology: args[0] as MongoV3Topology | undefined,\n ns: args[1] as string,\n command: args[2] as Record<string, unknown> | undefined,\n operation: 'find',\n }));\n\n // `getMore`(server, ns, cursorState, batchSize, options, callback)\n // command doc is `cursorState.cmd`.\n bindV3(CHANNELS.MONGODB_V3_GET_MORE, args => ({\n topology: args[0] as MongoV3Topology | undefined,\n ns: args[1] as string,\n command: (args[2] as { cmd?: Record<string, unknown> } | undefined)?.cmd,\n operation: 'getMore',\n }));\n}\n\nfunction bindV3(channelName: string, extract: (args: unknown[]) => V3CallInfo | undefined): void {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<MongoChannelContext>(channelName),\n data => {\n const args = data.arguments;\n if (!args) {\n return undefined;\n }\n const info = extract(args);\n if (!info || typeof info.ns !== 'string') {\n return undefined;\n }\n return startMongoSpan(getV3SpanAttributes(info.ns, info.topology, info.command, info.operation, ORIGIN));\n },\n { requiresParentSpan: true },\n );\n}\n\n/**\n * EXPERIMENTAL: orchestrion-driven mongodb integration.\n *\n * Reproduces the vendored `@opentelemetry/instrumentation-mongodb` span shape\n * (legacy db/net semantic conventions, `mongodb.<op>` names, scrubbed\n * `db.statement`) via the `orchestrion:mongodb:*` diagnostics_channels\n * injected by the orchestrion code transform.\n */\nexport const mongodbChannelIntegration = defineIntegration(_mongodbChannelIntegration);\n"],"names":["waitForTracingChannelBinding","bindTracingChannelToSpan","CHANNELS","startMongoSpan","getV4SpanAttributes","getV3CommandOperation","getV3SpanAttributes","defineIntegration"],"mappings":";;;;;;;;AAaA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,MAAA,GAAS,2BAAA;AA+Bf,MAAM,qBAAA,mBAAwB,IAAI,GAAA,CAAI,CAAC,QAAA,EAAU,UAAU,QAAA,EAAU,MAAA,EAAQ,SAAA,EAAW,aAAa,CAAC,CAAA;AAEtG,MAAM,8BAA8B,MAAM;AACxC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,IAAI,CAAC,mBAAmB,cAAA,EAAgB;AACtC,QAAA;AAAA,MACF;AAEA,MAAAA,iCAAA,CAA6B,MAAM;AACjC,QAAA,kBAAA,EAAmB;AACnB,QAAA,mBAAA,EAAoB;AACpB,QAAA,uBAAA,EAAwB;AAAA,MAC1B,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAOA,SAAS,kBAAA,GAA2B;AAClC,EAAAC,uCAAA;AAAA,IACE,kBAAA,CAAmB,cAAA,CAAoCC,iBAAA,CAAS,eAAe,CAAA;AAAA,IAC/E,CAAA,IAAA,KAAQ;AACN,MAAA,MAAM,IAAA,GAAO,IAAA,CAAK,SAAA,IAAa,EAAC;AAChC,MAAA,MAAM,EAAA,GAAK,KAAK,CAAC,CAAA;AACjB,MAA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I,CAAC,IAAA,IAAQ,OAAO,IAAA,CAAK,OAAO,QAAA,EAAU;AACxC,QAAA,OAAO,MAAA;AAAA,MACT;AACA,MAAA,OAAOE,0BAAA,CAAeG,+BAAA,CAAoB,IAAA,CAAK,EAAA,EAAI,IAAA,CAAK,QAAA,EAAU,IAAA,CAAK,OAAA,EAAS,IAAA,CAAK,SAAA,EAAW,MAAM,CAAC,CAAA;AAAA,IACzG,CAAA;AAAA,IACA,EAAE,oBAAoB,IAAA;AAAK,GAC7B;AACF;AAUO,MAAM,yBAAA,GAA4BC,uBAAkB,0BAA0B;;;;"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const diagnosticsChannel = require('node:diagnostics_channel');
|
|
4
|
+
const core = require('@sentry/core');
|
|
5
|
+
const mongooseDcSubscriber = require('../../mongoose/mongoose-dc-subscriber.js');
|
|
6
|
+
const mongooseLegacySpan = require('../../mongoose/mongoose-legacy-span.js');
|
|
7
|
+
const channels = require('../../orchestrion/channels.js');
|
|
8
|
+
const mongoose = require('../../orchestrion/config/mongoose.js');
|
|
9
|
+
const debugBuild = require('../../debug-build.js');
|
|
10
|
+
const tracingChannel = require('../../tracing-channel.js');
|
|
11
|
+
|
|
12
|
+
const INTEGRATION_NAME = "Mongoose";
|
|
13
|
+
const ORIGIN = "auto.db.orchestrion.mongoose";
|
|
14
|
+
const STORED_PARENT_SPAN = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
let orchestrionSubscribed = false;
|
|
16
|
+
const _mongooseChannelIntegration = (() => {
|
|
17
|
+
return {
|
|
18
|
+
name: INTEGRATION_NAME,
|
|
19
|
+
setupOnce() {
|
|
20
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
core.waitForTracingChannelBinding(() => {
|
|
24
|
+
mongooseDcSubscriber.subscribeMongooseDiagnosticChannels(diagnosticsChannel.tracingChannel);
|
|
25
|
+
subscribeOrchestrionMongooseChannels();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
function subscribeOrchestrionMongooseChannels() {
|
|
31
|
+
if (orchestrionSubscribed) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
orchestrionSubscribed = true;
|
|
35
|
+
debugBuild.DEBUG_BUILD && core.debug.log("[orchestrion:mongoose] subscribing to injected channels");
|
|
36
|
+
for (const channelName of mongoose.MONGOOSE_CONTEXT_CAPTURE_CHANNELS) {
|
|
37
|
+
channel(channelName).subscribe({
|
|
38
|
+
start(message) {
|
|
39
|
+
stashParentSpan(message.self);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
channel(channels.CHANNELS.MONGOOSE_MODEL_AGGREGATE).subscribe({
|
|
44
|
+
end(message) {
|
|
45
|
+
const result = message.result;
|
|
46
|
+
if (result && typeof result === "object") {
|
|
47
|
+
stashParentSpan(result);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
bindExecSpan(channels.CHANNELS.MONGOOSE_QUERY_EXEC, (self) => {
|
|
52
|
+
const query = self;
|
|
53
|
+
return startSpan(
|
|
54
|
+
query.mongooseCollection,
|
|
55
|
+
query.model?.modelName,
|
|
56
|
+
query.op ?? "exec",
|
|
57
|
+
STORED_PARENT_SPAN.get(self)
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
bindExecSpan(channels.CHANNELS.MONGOOSE_AGGREGATE_EXEC, (self) => {
|
|
61
|
+
const model = self._model;
|
|
62
|
+
return startSpan(model?.collection, model?.modelName, "aggregate", STORED_PARENT_SPAN.get(self));
|
|
63
|
+
});
|
|
64
|
+
bindExecSpan(channels.CHANNELS.MONGOOSE_MODEL_SAVE, (self) => {
|
|
65
|
+
const ctor = self.constructor;
|
|
66
|
+
return startSpan(ctor.collection, ctor.modelName, "save");
|
|
67
|
+
});
|
|
68
|
+
bindExecSpan(channels.CHANNELS.MONGOOSE_MODEL_REMOVE, (self) => {
|
|
69
|
+
const ctor = self.constructor;
|
|
70
|
+
return startSpan(ctor.collection, ctor.modelName, "remove");
|
|
71
|
+
});
|
|
72
|
+
bindExecSpan(channels.CHANNELS.MONGOOSE_MODEL_INSERT_MANY, (self) => {
|
|
73
|
+
const model = self;
|
|
74
|
+
return startSpan(model.collection, model.modelName, "insertMany");
|
|
75
|
+
});
|
|
76
|
+
bindExecSpan(channels.CHANNELS.MONGOOSE_MODEL_BULK_WRITE, (self) => {
|
|
77
|
+
const model = self;
|
|
78
|
+
return startSpan(model.collection, model.modelName, "bulkWrite");
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function startSpan(collection, modelName, operation, parentSpan) {
|
|
82
|
+
return mongooseLegacySpan.startMongooseLegacySpan({ collection, modelName, operation, origin: ORIGIN, parentSpan });
|
|
83
|
+
}
|
|
84
|
+
function channel(channelName) {
|
|
85
|
+
return diagnosticsChannel.tracingChannel(
|
|
86
|
+
channelName
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function bindExecSpan(channelName, getSpan) {
|
|
90
|
+
tracingChannel.bindTracingChannelToSpan(
|
|
91
|
+
diagnosticsChannel.tracingChannel(channelName),
|
|
92
|
+
(data) => {
|
|
93
|
+
const self = data.self;
|
|
94
|
+
if (!self) {
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
return getSpan(self);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
function stashParentSpan(self) {
|
|
102
|
+
const active = core.getActiveSpan();
|
|
103
|
+
if (self && active) {
|
|
104
|
+
STORED_PARENT_SPAN.set(self, active);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const mongooseChannelIntegration = core.defineIntegration(_mongooseChannelIntegration);
|
|
108
|
+
|
|
109
|
+
exports.mongooseChannelIntegration = mongooseChannelIntegration;
|
|
110
|
+
//# sourceMappingURL=mongoose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoose.js","sources":["../../../../src/integrations/tracing-channel/mongoose.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport { debug, defineIntegration, getActiveSpan, waitForTracingChannelBinding } from '@sentry/core';\nimport { subscribeMongooseDiagnosticChannels } from '../../mongoose/mongoose-dc-subscriber';\nimport type { MongooseLegacyCollection } from '../../mongoose/mongoose-legacy-span';\nimport { startMongooseLegacySpan } from '../../mongoose/mongoose-legacy-span';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { MONGOOSE_CONTEXT_CAPTURE_CHANNELS } from '../../orchestrion/config/mongoose';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport type { SentryTracingChannel } from '../../tracing-channel';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\nconst INTEGRATION_NAME = 'Mongoose' as const;\n\n// Origin distinguishes the orchestrion path from the OTel/IITM path\n// (`auto.db.otel.mongoose`) and the native diagnostics_channel path\n// (`auto.db.mongoose.diagnostic_channel`).\nconst ORIGIN = 'auto.db.orchestrion.mongoose';\n\ninterface MongooseQuery {\n mongooseCollection?: MongooseLegacyCollection;\n model?: { modelName?: string };\n op?: string;\n}\n\ninterface MongooseAggregate {\n _model?: { collection?: MongooseLegacyCollection; modelName?: string };\n}\n\ninterface MongooseModelStatic {\n collection?: MongooseLegacyCollection;\n modelName?: string;\n}\n\ninterface MongooseDocument {\n constructor: { collection?: MongooseLegacyCollection; modelName?: string };\n}\n\n/**\n * The shape orchestrion's transform attaches to the tracing-channel context\n * object. `self` is the `this` of the traced method\n */\ninterface MongooseChannelContext {\n self?: object;\n arguments?: unknown[];\n result?: unknown;\n error?: unknown;\n moduleVersion?: string;\n}\n\n// The active span captured when a query/aggregate was *built*, keyed by the\n// query/aggregate object.\n//\n// Used as the parent for the span created at `exec()` so a query parents to\n// where it was built, not where it happens to be awaited. A WeakMap avoids\n// mutating mongoose's own objects.\nconst STORED_PARENT_SPAN = new WeakMap<object, Span>();\n\nlet orchestrionSubscribed = false;\n\nconst _mongooseChannelIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n // mongoose >= 9.7 publishes via its own diagnostics_channel; reuse\n // the shared native subscriber so this single integration covers all\n // versions after it replaces the OTel one. Idempotent and inert on\n // < 9.7 (those channels just never get published to)\n subscribeMongooseDiagnosticChannels(diagnosticsChannel.tracingChannel);\n\n // mongoose < 9.7 is covered by the orchestrion-injected channels.\n subscribeOrchestrionMongooseChannels();\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction subscribeOrchestrionMongooseChannels(): void {\n if (orchestrionSubscribed) {\n return;\n }\n orchestrionSubscribed = true;\n\n DEBUG_BUILD && debug.log('[orchestrion:mongoose] subscribing to injected channels');\n\n // Context-capture builders: stash the active span at build time so `exec()`\n // can parent to it.\n for (const channelName of MONGOOSE_CONTEXT_CAPTURE_CHANNELS) {\n channel(channelName).subscribe({\n start(message) {\n stashParentSpan(message.self);\n },\n });\n }\n\n // `Model.aggregate()` returns the aggregate it builds; stash the parent on\n // the returned object.\n channel(CHANNELS.MONGOOSE_MODEL_AGGREGATE).subscribe({\n end(message) {\n const result = message.result;\n if (result && typeof result === 'object') {\n stashParentSpan(result);\n }\n },\n });\n\n // Query execution.\n bindExecSpan(CHANNELS.MONGOOSE_QUERY_EXEC, self => {\n const query = self as MongooseQuery;\n return startSpan(\n query.mongooseCollection,\n query.model?.modelName,\n query.op ?? 'exec',\n STORED_PARENT_SPAN.get(self),\n );\n });\n\n // Aggregation execution.\n bindExecSpan(CHANNELS.MONGOOSE_AGGREGATE_EXEC, self => {\n const model = (self as MongooseAggregate)._model;\n return startSpan(model?.collection, model?.modelName, 'aggregate', STORED_PARENT_SPAN.get(self));\n });\n\n // `doc.save()` (and the `$save` alias).\n bindExecSpan(CHANNELS.MONGOOSE_MODEL_SAVE, self => {\n const ctor = (self as MongooseDocument).constructor;\n return startSpan(ctor.collection, ctor.modelName, 'save');\n });\n\n // `doc.remove()` (mongoose 5/6).\n bindExecSpan(CHANNELS.MONGOOSE_MODEL_REMOVE, self => {\n const ctor = (self as MongooseDocument).constructor;\n return startSpan(ctor.collection, ctor.modelName, 'remove');\n });\n\n // Static batch operations. `self` is the Model.\n bindExecSpan(CHANNELS.MONGOOSE_MODEL_INSERT_MANY, self => {\n const model = self as MongooseModelStatic;\n return startSpan(model.collection, model.modelName, 'insertMany');\n });\n bindExecSpan(CHANNELS.MONGOOSE_MODEL_BULK_WRITE, self => {\n const model = self as MongooseModelStatic;\n return startSpan(model.collection, model.modelName, 'bulkWrite');\n });\n}\n\nfunction startSpan(\n collection: MongooseLegacyCollection | undefined,\n modelName: string | undefined,\n operation: string,\n parentSpan?: Span,\n): Span {\n return startMongooseLegacySpan({ collection, modelName, operation, origin: ORIGIN, parentSpan });\n}\n\n// `SentryTracingChannel` relaxes Node's subscriber type to a `Partial`, so a\n// `start`-only (or `end`-only) subscriber for the context-capture channels\n// is accepted.\nfunction channel(channelName: string): SentryTracingChannel<MongooseChannelContext> {\n return diagnosticsChannel.tracingChannel<MongooseChannelContext>(\n channelName,\n ) as unknown as SentryTracingChannel<MongooseChannelContext>;\n}\n\nfunction bindExecSpan(channelName: string, getSpan: (self: object) => Span): void {\n bindTracingChannelToSpan<MongooseChannelContext>(\n diagnosticsChannel.tracingChannel<MongooseChannelContext>(channelName),\n data => {\n const self = data.self;\n if (!self) {\n return undefined;\n }\n return getSpan(self);\n },\n );\n}\n\nfunction stashParentSpan(self: object | undefined): void {\n const active = getActiveSpan();\n if (self && active) {\n STORED_PARENT_SPAN.set(self, active);\n }\n}\n\n/**\n * EXPERIMENTAL: orchestrion-driven mongoose integration.\n *\n * Reproduces the vendored `@opentelemetry/instrumentation-mongoose` span\n * shape (legacy db/net semantic conventions, `mongoose.<Model>.<op>` names,\n * build-time span parenting) via the `orchestrion:mongoose:*`\n * diagnostics_channels injected into mongoose `< 9.7` by the orchestrion\n * code transform. For mongoose `>= 9.7` it also drives the native\n * diagnostics_channel subscription, so this single integration covers every\n * supported version once it replaces the OTel one.\n */\nexport const mongooseChannelIntegration = defineIntegration(_mongooseChannelIntegration);\n"],"names":["waitForTracingChannelBinding","subscribeMongooseDiagnosticChannels","DEBUG_BUILD","debug","MONGOOSE_CONTEXT_CAPTURE_CHANNELS","CHANNELS","startMongooseLegacySpan","bindTracingChannelToSpan","getActiveSpan","defineIntegration"],"mappings":";;;;;;;;;;;AAYA,MAAM,gBAAA,GAAmB,UAAA;AAKzB,MAAM,MAAA,GAAS,8BAAA;AAuCf,MAAM,kBAAA,uBAAyB,OAAA,EAAsB;AAErD,IAAI,qBAAA,GAAwB,KAAA;AAE5B,MAAM,+BAA+B,MAAM;AACzC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,IAAI,CAAC,mBAAmB,cAAA,EAAgB;AACtC,QAAA;AAAA,MACF;AAEA,MAAAA,iCAAA,CAA6B,MAAM;AAKjC,QAAAC,wDAAA,CAAoC,mBAAmB,cAAc,CAAA;AAGrE,QAAA,oCAAA,EAAqC;AAAA,MACvC,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAEA,SAAS,oCAAA,GAA6C;AACpD,EAAA,IAAI,qBAAA,EAAuB;AACzB,IAAA;AAAA,EACF;AACA,EAAA,qBAAA,GAAwB,IAAA;AAExB,EAAAC,sBAAA,IAAeC,UAAA,CAAM,IAAI,yDAAyD,CAAA;AAIlF,EAAA,KAAA,MAAW,eAAeC,0CAAA,EAAmC;AAC3D,IAAA,OAAA,CAAQ,WAAW,EAAE,SAAA,CAAU;AAAA,MAC7B,MAAM,OAAA,EAAS;AACb,QAAA,eAAA,CAAgB,QAAQ,IAAI,CAAA;AAAA,MAC9B;AAAA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CAAI,MAAM,MAAM,CAAA;AAAA,EACrC;AACF;AAaO,MAAM,0BAAA,GAA6BC,uBAAkB,2BAA2B;;;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const diagnosticsChannel = require('node:diagnostics_channel');
|
|
4
|
+
const core = require('@sentry/core');
|
|
5
|
+
const mysql2DcSubscriber = require('../../mysql2/mysql2-dc-subscriber.js');
|
|
6
|
+
const channels = require('../../orchestrion/channels.js');
|
|
7
|
+
const tracingChannel = require('../../tracing-channel.js');
|
|
8
|
+
const attributes = require('@sentry/conventions/attributes');
|
|
9
|
+
|
|
10
|
+
const INTEGRATION_NAME = "Mysql2";
|
|
11
|
+
const ORIGIN = "auto.db.orchestrion.mysql2";
|
|
12
|
+
const DB_SYSTEM_VALUE_MYSQL = "mysql";
|
|
13
|
+
function instrumentMysql2() {
|
|
14
|
+
mysql2DcSubscriber.subscribeMysql2DiagnosticChannels(diagnosticsChannel.tracingChannel);
|
|
15
|
+
subscribeQueryChannel(channels.CHANNELS.MYSQL2_QUERY);
|
|
16
|
+
subscribeQueryChannel(channels.CHANNELS.MYSQL2_EXECUTE);
|
|
17
|
+
}
|
|
18
|
+
function subscribeQueryChannel(channelName) {
|
|
19
|
+
tracingChannel.bindTracingChannelToSpan(
|
|
20
|
+
diagnosticsChannel.tracingChannel(channelName),
|
|
21
|
+
(data) => {
|
|
22
|
+
const statement = getQueryText(data.arguments);
|
|
23
|
+
return core.startInactiveSpan({
|
|
24
|
+
name: statement ?? "mysql2.query",
|
|
25
|
+
kind: core.SPAN_KIND.CLIENT,
|
|
26
|
+
attributes: {
|
|
27
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
28
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db",
|
|
29
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
30
|
+
[attributes.DB_SYSTEM]: DB_SYSTEM_VALUE_MYSQL,
|
|
31
|
+
...getConnectionAttributes(data.self?.config),
|
|
32
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
33
|
+
[attributes.DB_STATEMENT]: statement || void 0
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
{ requiresParentSpan: true }
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function getQueryText(args) {
|
|
41
|
+
return extractSql(args[0]);
|
|
42
|
+
}
|
|
43
|
+
function extractSql(firstArg) {
|
|
44
|
+
if (typeof firstArg === "string") {
|
|
45
|
+
return firstArg;
|
|
46
|
+
}
|
|
47
|
+
if (core.isObjectLike(firstArg) && "sql" in firstArg) {
|
|
48
|
+
const sql = firstArg.sql;
|
|
49
|
+
return typeof sql === "string" ? sql : void 0;
|
|
50
|
+
}
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
function getConnectionAttributes(config) {
|
|
54
|
+
const { host, port, database, user } = config?.connectionConfig ?? config ?? {};
|
|
55
|
+
const portNumber = typeof port === "string" ? parseInt(port, 10) : port;
|
|
56
|
+
const portIsNumber = typeof portNumber === "number" && !isNaN(portNumber);
|
|
57
|
+
return {
|
|
58
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
59
|
+
[attributes.DB_NAME]: database || void 0,
|
|
60
|
+
[attributes.DB_USER]: user || void 0,
|
|
61
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
62
|
+
[attributes.NET_PEER_NAME]: host || void 0,
|
|
63
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
64
|
+
[attributes.NET_PEER_PORT]: portIsNumber ? portNumber : void 0
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const _mysql2ChannelIntegration = (() => {
|
|
68
|
+
return {
|
|
69
|
+
name: INTEGRATION_NAME,
|
|
70
|
+
setupOnce() {
|
|
71
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
core.waitForTracingChannelBinding(() => {
|
|
75
|
+
instrumentMysql2();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
const mysql2ChannelIntegration = core.defineIntegration(_mysql2ChannelIntegration);
|
|
81
|
+
|
|
82
|
+
exports.mysql2ChannelIntegration = mysql2ChannelIntegration;
|
|
83
|
+
//# 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":["subscribeMysql2DiagnosticChannels","CHANNELS","bindTracingChannelToSpan","startInactiveSpan","SPAN_KIND","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","DB_SYSTEM","DB_STATEMENT","isObjectLike","DB_NAME","DB_USER","NET_PEER_NAME","NET_PEER_PORT","waitForTracingChannelBinding","defineIntegration"],"mappings":";;;;;;;;;AAwBA,MAAM,gBAAA,GAAmB,QAAA;AACzB,MAAM,MAAA,GAAS,4BAAA;AACf,MAAM,qBAAA,GAAwB,OAAA;AAyC9B,SAAS,gBAAA,GAAyB;AAEhC,EAAAA,oDAAA,CAAkC,mBAAmB,cAAc,CAAA;AAGnE,EAAA,qBAAA,CAAsBC,kBAAS,YAAY,CAAA;AAC3C,EAAA,qBAAA,CAAsBA,kBAAS,cAAc,CAAA;AAC/C;AAEA,SAAS,sBAAsB,WAAA,EAAgC;AAC7D,EAAAC,uCAAA;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,OAAOC,sBAAA,CAAkB;AAAA,QACvB,MAAM,SAAA,IAAa,cAAA;AAAA,QACnB,MAAMC,cAAA,CAAU,MAAA;AAAA,QAChB,UAAA,EAAY;AAAA,UACV,CAACC,qCAAgC,GAAG,MAAA;AAAA,UACpC,CAACC,iCAA4B,GAAG,IAAA;AAAA;AAAA,UAEhC,CAACC,oBAAS,GAAG,qBAAA;AAAA,UACb,GAAG,uBAAA,CAAwB,IAAA,CAAK,IAAA,EAAM,MAAM,CAAA;AAAA;AAAA,UAE5C,CAACC,uBAAY,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,UAA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,GACF;AACF,CAAA,CAAA;AAaO,MAAM,wBAAA,GAA2BC,uBAAkB,yBAAyB;;;;"}
|
|
@@ -10,9 +10,7 @@ const INTEGRATION_NAME = "OpenAI";
|
|
|
10
10
|
const ORIGIN = "auto.ai.orchestrion.openai";
|
|
11
11
|
const INSTRUMENTED_CHANNELS = [
|
|
12
12
|
{ channel: channels.CHANNELS.OPENAI_CHAT, operation: "chat" },
|
|
13
|
-
{ channel: channels.CHANNELS.
|
|
14
|
-
{ channel: channels.CHANNELS.OPENAI_EMBEDDINGS, operation: "embeddings" },
|
|
15
|
-
{ channel: channels.CHANNELS.OPENAI_CONVERSATIONS, operation: "chat" }
|
|
13
|
+
{ channel: channels.CHANNELS.OPENAI_EMBEDDINGS, operation: "embeddings" }
|
|
16
14
|
];
|
|
17
15
|
let subscribed = false;
|
|
18
16
|
const _openaiChannelIntegration = ((options = {}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sources":["../../../../src/integrations/tracing-channel/openai.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn, OpenAiOptions, Span, SpanAttributeValue } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n addOpenAiRequestAttributes,\n addOpenAiResponseAttributes,\n debug,\n defineIntegration,\n extractOpenAiRequestAttributes,\n instrumentOpenAiStream,\n resolveAIRecordingOptions,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n shouldEnableTruncation,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Same name as the OTel integration by design: when enabled, the OTel 'OpenAI'\n// integration is dropped from the default set (see the Node opt-in loader).\nconst INTEGRATION_NAME = 'OpenAI' as const;\n\n// Distinct from the proxy's `auto.ai.openai` so spans from the orchestrion path\n// are attributable separately from the OTel/proxy one.\nconst ORIGIN = 'auto.ai.orchestrion.openai';\n\n// Each instrumented `create` method maps to the gen_ai operation its span reports.\nconst INSTRUMENTED_CHANNELS = [\n { channel: CHANNELS.OPENAI_CHAT, operation: 'chat' },\n { channel: CHANNELS.
|
|
1
|
+
{"version":3,"file":"openai.js","sources":["../../../../src/integrations/tracing-channel/openai.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn, OpenAiOptions, Span, SpanAttributeValue } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n addOpenAiRequestAttributes,\n addOpenAiResponseAttributes,\n debug,\n defineIntegration,\n extractOpenAiRequestAttributes,\n instrumentOpenAiStream,\n resolveAIRecordingOptions,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n shouldEnableTruncation,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Same name as the OTel integration by design: when enabled, the OTel 'OpenAI'\n// integration is dropped from the default set (see the Node opt-in loader).\nconst INTEGRATION_NAME = 'OpenAI' as const;\n\n// Distinct from the proxy's `auto.ai.openai` so spans from the orchestrion path\n// are attributable separately from the OTel/proxy one.\nconst ORIGIN = 'auto.ai.orchestrion.openai';\n\n// Each instrumented `create` method maps to the gen_ai operation its span reports.\nconst INSTRUMENTED_CHANNELS = [\n { channel: CHANNELS.OPENAI_CHAT, operation: 'chat' },\n { channel: CHANNELS.OPENAI_EMBEDDINGS, operation: 'embeddings' },\n] as const;\n\n/**\n * The context object orchestrion shares across the tracing-channel lifecycle hooks: `arguments` is the\n * live args array passed to `Completions.create(body, options)`, and Node's `tracingChannel` attaches\n * `result` when the returned promise settles.\n */\ninterface OpenAiChatChannelContext {\n arguments: unknown[];\n result?: unknown;\n}\n\nlet subscribed = false;\n\nconst _openaiChannelIntegration = ((options: OpenAiOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19, and a second `init()` would double-subscribe.\n if (!diagnosticsChannel.tracingChannel || subscribed) {\n return;\n }\n subscribed = true;\n\n // `bindTracingChannelToSpan` needs the async-context binding that `initOpenTelemetry()` registers\n // after `setupOnce` runs, so wait for it before subscribing.\n waitForTracingChannelBinding(() => {\n for (const { channel, operation } of INSTRUMENTED_CHANNELS) {\n DEBUG_BUILD && debug.log(`[orchestrion:openai] subscribing to channel \"${channel}\"`);\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<OpenAiChatChannelContext>(channel),\n data => createGenAiSpan(data, operation, options),\n {\n beforeSpanEnd: (span, data) => {\n addOpenAiResponseAttributes(span, data.result, resolveAIRecordingOptions(options).recordOutputs);\n },\n // Streaming: the result is a `Stream` consumed later, so instrument it and let it end the span.\n deferSpanEnd: ({ span, data }) => wrapStreamResult(span, data, options),\n },\n );\n }\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Build the span for an instrumented `create` call.\n * Returning `undefined` opts the payload out so no span is opened.\n */\nfunction createGenAiSpan(data: OpenAiChatChannelContext, operation: string, options: OpenAiOptions): Span | undefined {\n // When another provider (e.g. LangChain) is driving the SDK, it records the spans itself and marks this\n // provider as skipped; skip here to avoid double spans.\n if (_INTERNAL_shouldSkipAiProviderWrapping(INTEGRATION_NAME)) {\n return undefined;\n }\n\n const args = data.arguments ?? [];\n const params = args[0] as Record<string, unknown> | undefined;\n\n const { recordInputs } = resolveAIRecordingOptions(options);\n const enableTruncation = shouldEnableTruncation(options.enableTruncation);\n\n const attributes = extractOpenAiRequestAttributes(args, operation);\n attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = ORIGIN;\n const model = (params?.model as string) || 'unknown';\n\n const span = startInactiveSpan({\n name: `${operation} ${model}`,\n op: `gen_ai.${operation}`,\n attributes: attributes as Record<string, SpanAttributeValue>,\n });\n\n if (recordInputs && params) {\n addOpenAiRequestAttributes(span, params, operation, enableTruncation);\n }\n\n return span;\n}\n\ntype AsyncIterableStream = { [Symbol.asyncIterator]: () => AsyncIterator<unknown> };\n\nfunction isAsyncIterable(value: unknown): value is AsyncIterableStream {\n return !!value && typeof (value as AsyncIterableStream)[Symbol.asyncIterator] === 'function';\n}\n\n/**\n * For a streaming `create({ stream: true })` the result is a `Stream` the caller consumes later. We can't\n * swap what `create` returns, but the `Stream` in `data.result` is the same instance the caller holds and\n * `asyncEnd` fires before the caller iterates — so we patch its async iterator in place to run through\n * `instrumentOpenAiStream`, which accumulates the streamed attributes and ends the span when iteration finishes.\n * Only a streaming call resolves to an async-iterable, so that check alone distinguishes it. Returns `true`\n * to hand span-ending ownership to `instrumentOpenAiStream`; `false` for non-streaming/errored results, which end\n * via the normal `beforeSpanEnd` path.\n */\nfunction wrapStreamResult(span: Span, data: OpenAiChatChannelContext, options: OpenAiOptions): boolean {\n const result = data.result;\n if (!isAsyncIterable(result)) {\n return false;\n }\n\n const { recordOutputs } = resolveAIRecordingOptions(options);\n const iterate = result[Symbol.asyncIterator].bind(result);\n const instrumented = instrumentOpenAiStream({ [Symbol.asyncIterator]: iterate }, span, recordOutputs ?? false);\n result[Symbol.asyncIterator] = () => instrumented;\n\n return true;\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven OpenAI integration. Subscribes to the `orchestrion:openai:*`\n * diagnostics_channels injected into `openai`'s `create` methods (chat completions, responses, embeddings,\n * conversations), so it requires the orchestrion runtime hook or bundler plugin.\n */\nexport const openaiChannelIntegration = defineIntegration(_openaiChannelIntegration);\n"],"names":["CHANNELS","waitForTracingChannelBinding","DEBUG_BUILD","debug","bindTracingChannelToSpan","addOpenAiResponseAttributes","resolveAIRecordingOptions","_INTERNAL_shouldSkipAiProviderWrapping","shouldEnableTruncation","extractOpenAiRequestAttributes","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","startInactiveSpan","addOpenAiRequestAttributes","inst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A,MAAM,SAAS,IAAA,CAAK,MAAA;AACpB,EAAA,IAAI,CAAC,eAAA,CAAgB,MAAM,CAAA,EAAG;AAC5B,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,EAAE,aAAA,EAAc,GAAIN,8BAAA,CAA0B,OAAO,CAAA;AAC3D,EAAA,MAAM,UAAU,MAAA,CAAO,MAAA,CAAO,aAAa,CAAA,CAAE,KAAK,MAAM,CAAA;AACxD,EAAA,MAAM,YAAA,GAAeO,2BAAA,CAAuB,EAAE,CAAC,MAAA,CAAO,aAAa,GAAG,OAAA,EAAQ,EAAG,IAAA,EAAM,aAAA,IAAiB,KAAK,CAAA;AAC7G,EAAA,MAAA,CAAO,MAAA,CAAO,aAAa,CAAA,GAAI,MAAM,YAAA;AAErC,EAAA,OAAO,IAAA;AACT;AAOO,MAAM,wBAAA,GAA2BC,uBAAkB,yBAAyB;;;;"}
|
|
@@ -129,7 +129,6 @@ function bindNodeRedisCommandChannel(channelName, getWireArgs, responseHook) {
|
|
|
129
129
|
return startCommandSpan(commandName, wireArgs.slice(1), nodeRedisAttributes(options));
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
|
-
captureError: false,
|
|
133
132
|
beforeSpanEnd(span, data) {
|
|
134
133
|
if ("error" in data || !responseHook) {
|
|
135
134
|
return;
|
|
@@ -160,42 +159,34 @@ function getExecutorArgs(data) {
|
|
|
160
159
|
}
|
|
161
160
|
function bindNodeRedisConnectChannel() {
|
|
162
161
|
const channel = diagnosticsChannel.tracingChannel(channels.CHANNELS.NODE_REDIS_CONNECT);
|
|
163
|
-
tracingChannel.bindTracingChannelToSpan(
|
|
164
|
-
|
|
165
|
-
(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
{ captureError: false }
|
|
174
|
-
);
|
|
162
|
+
tracingChannel.bindTracingChannelToSpan(channel, (data) => {
|
|
163
|
+
const options = data.self?.options;
|
|
164
|
+
return core.startInactiveSpan({
|
|
165
|
+
name: "redis-connect",
|
|
166
|
+
kind: core.SPAN_KIND.CLIENT,
|
|
167
|
+
attributes: { ...nodeRedisAttributes(options), [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db" }
|
|
168
|
+
});
|
|
169
|
+
});
|
|
175
170
|
}
|
|
176
171
|
function bindNodeRedisBatchChannel(channelName, getOperation) {
|
|
177
172
|
const channel = diagnosticsChannel.tracingChannel(channelName);
|
|
178
|
-
tracingChannel.bindTracingChannelToSpan(
|
|
179
|
-
|
|
180
|
-
(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
},
|
|
197
|
-
{ captureError: false }
|
|
198
|
-
);
|
|
173
|
+
tracingChannel.bindTracingChannelToSpan(channel, (data) => {
|
|
174
|
+
const commands = data.arguments?.[0];
|
|
175
|
+
const size = Array.isArray(commands) ? commands.length : void 0;
|
|
176
|
+
const socket = data.self?.options?.socket;
|
|
177
|
+
return core.startInactiveSpan({
|
|
178
|
+
name: getOperation(data),
|
|
179
|
+
kind: core.SPAN_KIND.CLIENT,
|
|
180
|
+
attributes: {
|
|
181
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
182
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db.redis",
|
|
183
|
+
[attributes.DB_SYSTEM_NAME]: DB_SYSTEM_VALUE_REDIS,
|
|
184
|
+
...size && size > 1 ? { [attributes.DB_OPERATION_BATCH_SIZE]: size } : {},
|
|
185
|
+
...socket?.host != null ? { [attributes.SERVER_ADDRESS]: socket.host } : {},
|
|
186
|
+
...socket?.port != null ? { [attributes.SERVER_PORT]: socket.port } : {}
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
199
190
|
}
|
|
200
191
|
const _redisChannelIntegration = ((options = {}) => {
|
|
201
192
|
const responseHook = options.responseHook;
|