@sentry/server-utils 10.62.0 → 10.64.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/index.js +10 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/anthropic.js +101 -0
- package/build/cjs/integrations/tracing-channel/anthropic.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/fastify/errors.js +42 -0
- package/build/cjs/integrations/tracing-channel/fastify/errors.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/fastify/index.js +34 -0
- package/build/cjs/integrations/tracing-channel/fastify/index.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js +279 -0
- package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/fastify/utils.js +11 -0
- package/build/cjs/integrations/tracing-channel/fastify/utils.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/hapi-types.js +30 -0
- package/build/cjs/integrations/tracing-channel/hapi-types.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/hapi-utils.js +177 -0
- package/build/cjs/integrations/tracing-channel/hapi-utils.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/hapi.js +52 -0
- package/build/cjs/integrations/tracing-channel/hapi.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/ioredis.js +96 -0
- package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/lru-memoizer.js +31 -0
- package/build/cjs/integrations/tracing-channel/lru-memoizer.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/mysql.js +46 -83
- package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/openai.js +83 -0
- package/build/cjs/integrations/tracing-channel/openai.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/postgres.js +170 -0
- package/build/cjs/integrations/tracing-channel/postgres.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/vercel-ai.js +25 -0
- package/build/cjs/integrations/tracing-channel/vercel-ai.js.map +1 -0
- package/build/cjs/mongoose/index.js +23 -0
- package/build/cjs/mongoose/index.js.map +1 -0
- package/build/cjs/mongoose/mongoose-dc-subscriber.js +97 -0
- package/build/cjs/mongoose/mongoose-dc-subscriber.js.map +1 -0
- package/build/cjs/orchestrion/bundler/vite.js +3 -3
- package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
- package/build/cjs/orchestrion/channels.js +17 -1
- package/build/cjs/orchestrion/channels.js.map +1 -1
- package/build/cjs/orchestrion/config/anthropic-ai.js +43 -0
- package/build/cjs/orchestrion/config/anthropic-ai.js.map +1 -0
- package/build/cjs/orchestrion/config/hapi.js +26 -0
- package/build/cjs/orchestrion/config/hapi.js.map +1 -0
- package/build/cjs/orchestrion/config/index.js +35 -0
- package/build/cjs/orchestrion/config/index.js.map +1 -0
- package/build/cjs/orchestrion/config/ioredis.js +35 -0
- package/build/cjs/orchestrion/config/ioredis.js.map +1 -0
- package/build/cjs/orchestrion/config/lru-memoizer.js +17 -0
- package/build/cjs/orchestrion/config/lru-memoizer.js.map +1 -0
- package/build/cjs/orchestrion/config/mysql.js +16 -0
- package/build/cjs/orchestrion/config/mysql.js.map +1 -0
- package/build/cjs/orchestrion/config/openai.js +40 -0
- package/build/cjs/orchestrion/config/openai.js.map +1 -0
- package/build/cjs/orchestrion/config/pg.js +51 -0
- package/build/cjs/orchestrion/config/pg.js.map +1 -0
- package/build/cjs/orchestrion/config/vercel-ai.js +44 -0
- package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -0
- package/build/cjs/orchestrion/detect.js +6 -1
- package/build/cjs/orchestrion/detect.js.map +1 -1
- package/build/cjs/orchestrion/index.js +27 -3
- package/build/cjs/orchestrion/index.js.map +1 -1
- package/build/cjs/orchestrion/runtime/register.js +10 -7
- package/build/cjs/orchestrion/runtime/register.js.map +1 -1
- package/build/cjs/redis/redis-statement-serializer.js +34 -0
- package/build/cjs/redis/redis-statement-serializer.js.map +1 -0
- package/build/cjs/tracing-channel.js +50 -11
- package/build/cjs/tracing-channel.js.map +1 -1
- package/build/cjs/vercel-ai/index.js +5 -3
- package/build/cjs/vercel-ai/index.js.map +1 -1
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +11 -4
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/cjs/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js +256 -0
- package/build/cjs/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js.map +1 -0
- package/build/esm/index.js +3 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/tracing-channel/anthropic.js +99 -0
- package/build/esm/integrations/tracing-channel/anthropic.js.map +1 -0
- package/build/esm/integrations/tracing-channel/fastify/errors.js +39 -0
- package/build/esm/integrations/tracing-channel/fastify/errors.js.map +1 -0
- package/build/esm/integrations/tracing-channel/fastify/index.js +30 -0
- package/build/esm/integrations/tracing-channel/fastify/index.js.map +1 -0
- package/build/esm/integrations/tracing-channel/fastify/instrumentation.js +277 -0
- package/build/esm/integrations/tracing-channel/fastify/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing-channel/fastify/utils.js +8 -0
- package/build/esm/integrations/tracing-channel/fastify/utils.js.map +1 -0
- package/build/esm/integrations/tracing-channel/hapi-types.js +25 -0
- package/build/esm/integrations/tracing-channel/hapi-types.js.map +1 -0
- package/build/esm/integrations/tracing-channel/hapi-utils.js +172 -0
- package/build/esm/integrations/tracing-channel/hapi-utils.js.map +1 -0
- package/build/esm/integrations/tracing-channel/hapi.js +50 -0
- package/build/esm/integrations/tracing-channel/hapi.js.map +1 -0
- package/build/esm/integrations/tracing-channel/ioredis.js +94 -0
- package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -0
- package/build/esm/integrations/tracing-channel/lru-memoizer.js +29 -0
- package/build/esm/integrations/tracing-channel/lru-memoizer.js.map +1 -0
- package/build/esm/integrations/tracing-channel/mysql.js +47 -84
- package/build/esm/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/esm/integrations/tracing-channel/openai.js +81 -0
- package/build/esm/integrations/tracing-channel/openai.js.map +1 -0
- package/build/esm/integrations/tracing-channel/postgres.js +168 -0
- package/build/esm/integrations/tracing-channel/postgres.js.map +1 -0
- package/build/esm/integrations/tracing-channel/vercel-ai.js +23 -0
- package/build/esm/integrations/tracing-channel/vercel-ai.js.map +1 -0
- package/build/esm/mongoose/index.js +21 -0
- package/build/esm/mongoose/index.js.map +1 -0
- package/build/esm/mongoose/mongoose-dc-subscriber.js +89 -0
- package/build/esm/mongoose/mongoose-dc-subscriber.js.map +1 -0
- package/build/esm/orchestrion/bundler/vite.js +1 -1
- package/build/esm/orchestrion/channels.js +17 -1
- package/build/esm/orchestrion/channels.js.map +1 -1
- package/build/esm/orchestrion/config/anthropic-ai.js +40 -0
- package/build/esm/orchestrion/config/anthropic-ai.js.map +1 -0
- package/build/esm/orchestrion/config/hapi.js +23 -0
- package/build/esm/orchestrion/config/hapi.js.map +1 -0
- package/build/esm/orchestrion/config/index.js +31 -0
- package/build/esm/orchestrion/config/index.js.map +1 -0
- package/build/esm/orchestrion/config/ioredis.js +32 -0
- package/build/esm/orchestrion/config/ioredis.js.map +1 -0
- package/build/esm/orchestrion/config/lru-memoizer.js +14 -0
- package/build/esm/orchestrion/config/lru-memoizer.js.map +1 -0
- package/build/esm/orchestrion/config/mysql.js +13 -0
- package/build/esm/orchestrion/config/mysql.js.map +1 -0
- package/build/esm/orchestrion/config/openai.js +37 -0
- package/build/esm/orchestrion/config/openai.js.map +1 -0
- package/build/esm/orchestrion/config/pg.js +48 -0
- package/build/esm/orchestrion/config/pg.js.map +1 -0
- package/build/esm/orchestrion/config/vercel-ai.js +41 -0
- package/build/esm/orchestrion/config/vercel-ai.js.map +1 -0
- package/build/esm/orchestrion/detect.js +6 -2
- package/build/esm/orchestrion/detect.js.map +1 -1
- package/build/esm/orchestrion/index.js +21 -2
- package/build/esm/orchestrion/index.js.map +1 -1
- package/build/esm/orchestrion/runtime/register.js +8 -4
- package/build/esm/orchestrion/runtime/register.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/redis/redis-statement-serializer.js +32 -0
- package/build/esm/redis/redis-statement-serializer.js.map +1 -0
- package/build/esm/tracing-channel.js +51 -12
- package/build/esm/tracing-channel.js.map +1 -1
- package/build/esm/vercel-ai/index.js +6 -4
- package/build/esm/vercel-ai/index.js.map +1 -1
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +14 -8
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/esm/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js +254 -0
- package/build/esm/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js.map +1 -0
- package/build/types/index.d.ts +3 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/anthropic.d.ts +10 -0
- package/build/types/integrations/tracing-channel/anthropic.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/fastify/errors.d.ts +12 -0
- package/build/types/integrations/tracing-channel/fastify/errors.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/fastify/index.d.ts +66 -0
- package/build/types/integrations/tracing-channel/fastify/index.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/fastify/instrumentation.d.ts +10 -0
- package/build/types/integrations/tracing-channel/fastify/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/fastify/types.d.ts +32 -0
- package/build/types/integrations/tracing-channel/fastify/types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/fastify/utils.d.ts +9 -0
- package/build/types/integrations/tracing-channel/fastify/utils.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/hapi-types.d.ts +53 -0
- package/build/types/integrations/tracing-channel/hapi-types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/hapi-utils.d.ts +25 -0
- package/build/types/integrations/tracing-channel/hapi-utils.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/hapi.d.ts +9 -0
- package/build/types/integrations/tracing-channel/hapi.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/ioredis.d.ts +17 -0
- package/build/types/integrations/tracing-channel/ioredis.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/lru-memoizer.d.ts +10 -0
- package/build/types/integrations/tracing-channel/lru-memoizer.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/mysql.d.ts +3 -1
- package/build/types/integrations/tracing-channel/mysql.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/openai.d.ts +10 -0
- package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/postgres.d.ts +15 -0
- package/build/types/integrations/tracing-channel/postgres.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/vercel-ai.d.ts +13 -0
- package/build/types/integrations/tracing-channel/vercel-ai.d.ts.map +1 -0
- package/build/types/mongoose/index.d.ts +11 -0
- package/build/types/mongoose/index.d.ts.map +1 -0
- package/build/types/mongoose/mongoose-dc-subscriber.d.ts +63 -0
- package/build/types/mongoose/mongoose-dc-subscriber.d.ts.map +1 -0
- package/build/types/orchestrion/channels.d.ts +21 -0
- package/build/types/orchestrion/channels.d.ts.map +1 -1
- package/build/types/orchestrion/config/anthropic-ai.d.ts +31 -0
- package/build/types/orchestrion/config/anthropic-ai.d.ts.map +1 -0
- package/build/types/orchestrion/config/hapi.d.ts +17 -0
- package/build/types/orchestrion/config/hapi.d.ts.map +1 -0
- package/build/types/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
- package/build/types/orchestrion/config/index.d.ts.map +1 -0
- package/build/types/orchestrion/config/ioredis.d.ts +7 -0
- package/build/types/orchestrion/config/ioredis.d.ts.map +1 -0
- package/build/types/orchestrion/config/lru-memoizer.d.ts +16 -0
- package/build/types/orchestrion/config/lru-memoizer.d.ts.map +1 -0
- package/build/types/orchestrion/config/mysql.d.ts +16 -0
- package/build/types/orchestrion/config/mysql.d.ts.map +1 -0
- package/build/types/orchestrion/config/openai.d.ts +20 -0
- package/build/types/orchestrion/config/openai.d.ts.map +1 -0
- package/build/types/orchestrion/config/pg.d.ts +33 -0
- package/build/types/orchestrion/config/pg.d.ts.map +1 -0
- package/build/types/orchestrion/config/vercel-ai.d.ts +11 -0
- package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -0
- package/build/types/orchestrion/detect.d.ts +10 -0
- package/build/types/orchestrion/detect.d.ts.map +1 -1
- package/build/types/orchestrion/index.d.ts +53 -2
- package/build/types/orchestrion/index.d.ts.map +1 -1
- package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
- package/build/types/redis/redis-statement-serializer.d.ts +6 -0
- package/build/types/redis/redis-statement-serializer.d.ts.map +1 -0
- package/build/types/tracing-channel.d.ts +22 -0
- package/build/types/tracing-channel.d.ts.map +1 -1
- package/build/types/vercel-ai/index.d.ts +3 -1
- package/build/types/vercel-ai/index.d.ts.map +1 -1
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts +10 -4
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
- package/build/types/vercel-ai/vercel-ai-orchestrion-v6-subscriber.d.ts +12 -0
- package/build/types/vercel-ai/vercel-ai-orchestrion-v6-subscriber.d.ts.map +1 -0
- package/build/types-ts3.8/index.d.ts +4 -0
- package/build/types-ts3.8/integrations/tracing-channel/anthropic.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/fastify/errors.d.ts +12 -0
- package/build/types-ts3.8/integrations/tracing-channel/fastify/index.d.ts +66 -0
- package/build/types-ts3.8/integrations/tracing-channel/fastify/instrumentation.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/fastify/types.d.ts +32 -0
- package/build/types-ts3.8/integrations/tracing-channel/fastify/utils.d.ts +9 -0
- package/build/types-ts3.8/integrations/tracing-channel/hapi-types.d.ts +65 -0
- package/build/types-ts3.8/integrations/tracing-channel/hapi-utils.d.ts +25 -0
- package/build/types-ts3.8/integrations/tracing-channel/hapi.d.ts +9 -0
- package/build/types-ts3.8/integrations/tracing-channel/ioredis.d.ts +17 -0
- package/build/types-ts3.8/integrations/tracing-channel/lru-memoizer.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/mysql.d.ts +3 -1
- package/build/types-ts3.8/integrations/tracing-channel/openai.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/postgres.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing-channel/vercel-ai.d.ts +13 -0
- package/build/types-ts3.8/mongoose/index.d.ts +11 -0
- package/build/types-ts3.8/mongoose/mongoose-dc-subscriber.d.ts +63 -0
- package/build/types-ts3.8/node-diagnostics-channel.d.ts +19 -0
- package/build/types-ts3.8/orchestrion/channels.d.ts +21 -0
- package/build/types-ts3.8/orchestrion/config/anthropic-ai.d.ts +31 -0
- package/build/types-ts3.8/orchestrion/config/hapi.d.ts +17 -0
- package/build/types-ts3.8/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
- package/build/types-ts3.8/orchestrion/config/ioredis.d.ts +7 -0
- package/build/types-ts3.8/orchestrion/config/lru-memoizer.d.ts +16 -0
- package/build/types-ts3.8/orchestrion/config/mysql.d.ts +16 -0
- package/build/types-ts3.8/orchestrion/config/openai.d.ts +20 -0
- package/build/types-ts3.8/orchestrion/config/pg.d.ts +33 -0
- package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +11 -0
- package/build/types-ts3.8/orchestrion/detect.d.ts +10 -0
- package/build/types-ts3.8/orchestrion/index.d.ts +53 -2
- package/build/types-ts3.8/redis/redis-statement-serializer.d.ts +6 -0
- package/build/types-ts3.8/tracing-channel.d.ts +22 -0
- package/build/types-ts3.8/vercel-ai/index.d.ts +3 -1
- package/build/types-ts3.8/vercel-ai/vercel-ai-dc-subscriber.d.ts +10 -4
- package/build/types-ts3.8/vercel-ai/vercel-ai-orchestrion-v6-subscriber.d.ts +12 -0
- package/package.json +10 -10
- package/build/cjs/orchestrion/config.js +0 -38
- package/build/cjs/orchestrion/config.js.map +0 -1
- package/build/esm/orchestrion/config.js +0 -34
- package/build/esm/orchestrion/config.js.map +0 -1
- package/build/types/orchestrion/config.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hapi-types.js","sources":["../../../../src/integrations/tracing-channel/hapi-types.ts"],"sourcesContent":["/*\n * Structural type definitions and constants ported from the vendored\n * `@opentelemetry/instrumentation-hapi` types, with all `@hapi/*` and\n * `@opentelemetry/*` dependencies removed. Only the shapes actually accessed by\n * the orchestrion hapi subscriber are kept.\n */\n\n// Single source of truth for the request lifecycle extension points, so the\n// `ServerRequestExtType` union and the runtime `HapiLifecycleMethodNames` set\n// below can't drift apart.\nconst LIFECYCLE_EXT_POINTS = [\n 'onPreAuth',\n 'onCredentials',\n 'onPostAuth',\n 'onPreHandler',\n 'onPostHandler',\n 'onPreResponse',\n 'onRequest',\n] as const;\n\nexport type ServerRequestExtType = (typeof LIFECYCLE_EXT_POINTS)[number];\n\nexport type LifecycleMethod = (request: unknown, h: unknown, err?: Error) => unknown;\n\nexport interface ServerRouteOptions {\n handler?: LifecycleMethod | unknown;\n [key: string]: unknown;\n}\n\nexport interface ServerRoute {\n path: string;\n method: string;\n handler?: LifecycleMethod | unknown;\n options?: ((server: unknown) => ServerRouteOptions) | ServerRouteOptions;\n [key: string]: unknown;\n}\n\nexport interface ServerExtEventsObject {\n type: string;\n [key: string]: unknown;\n}\n\nexport interface ServerExtEventsRequestObject {\n type: ServerRequestExtType;\n method: LifecycleMethod;\n [key: string]: unknown;\n}\n\nexport interface ServerExtOptions {\n [key: string]: unknown;\n}\n\n/**\n * This symbol is used to mark a Hapi route handler or server extension handler as\n * already patched, since it's possible to use these handlers multiple times\n * i.e. when allowing multiple versions of one plugin, or when registering a plugin\n * multiple times on different servers.\n */\nexport const handlerPatched: unique symbol = Symbol('hapi-handler-patched');\n\nexport type PatchableServerRoute = ServerRoute & {\n [handlerPatched]?: boolean;\n};\n\nexport type PatchableExtMethod = LifecycleMethod & {\n [handlerPatched]?: boolean;\n};\n\nexport type ServerExtDirectInput = [ServerRequestExtType, LifecycleMethod, (ServerExtOptions | undefined)?];\n\nexport const HapiLayerType = {\n ROUTER: 'router',\n PLUGIN: 'plugin',\n EXT: 'server.ext',\n} as const;\n\nexport const HapiLifecycleMethodNames = new Set<string>(LIFECYCLE_EXT_POINTS);\n\nexport enum AttributeNames {\n HAPI_TYPE = 'hapi.type',\n PLUGIN_NAME = 'hapi.plugin.name',\n EXT_TYPE = 'server.ext.type',\n}\n"],"names":["AttributeNames"],"mappings":";;AAUA,MAAM,oBAAA,GAAuB;AAAA,EAC3B,WAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAA;AAwCO,MAAM,cAAA,0BAAuC,sBAAsB;AAYnE,MAAM,aAAA,GAAgB;AAAA,EAC3B,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,GAAA,EAAK;AACP;AAEO,MAAM,wBAAA,GAA2B,IAAI,GAAA,CAAY,oBAAoB;AAErE,IAAK,cAAA,qBAAAA,eAAAA,KAAL;AACL,EAAAA,gBAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,gBAAA,aAAA,CAAA,GAAc,kBAAA;AACd,EAAAA,gBAAA,UAAA,CAAA,GAAW,iBAAA;AAHD,EAAA,OAAAA,eAAAA;AAAA,CAAA,EAAA,cAAA,IAAA,EAAA;;;;;;;"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const attributes = require('@sentry/conventions/attributes');
|
|
5
|
+
const hapiTypes = require('./hapi-types.js');
|
|
6
|
+
|
|
7
|
+
function setHttpServerSpanRouteAttribute(route) {
|
|
8
|
+
const activeSpan = core.getActiveSpan();
|
|
9
|
+
if (!activeSpan) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const rootSpan = core.getRootSpan(activeSpan);
|
|
13
|
+
if (!rootSpan) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (core.spanToJSON(rootSpan).data[core.SEMANTIC_ATTRIBUTE_SENTRY_OP] !== "http.server") {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
rootSpan.setAttribute(attributes.HTTP_ROUTE, route);
|
|
20
|
+
}
|
|
21
|
+
const isLifecycleExtType = (variableToCheck) => {
|
|
22
|
+
return typeof variableToCheck === "string" && hapiTypes.HapiLifecycleMethodNames.has(variableToCheck);
|
|
23
|
+
};
|
|
24
|
+
const isLifecycleExtEventObj = (variableToCheck) => {
|
|
25
|
+
const event = variableToCheck?.type;
|
|
26
|
+
return event !== void 0 && isLifecycleExtType(event);
|
|
27
|
+
};
|
|
28
|
+
const isDirectExtInput = (variableToCheck) => {
|
|
29
|
+
return Array.isArray(variableToCheck) && variableToCheck.length <= 3 && isLifecycleExtType(variableToCheck[0]) && typeof variableToCheck[1] === "function";
|
|
30
|
+
};
|
|
31
|
+
const isPatchableExtMethod = (variableToCheck) => {
|
|
32
|
+
return !Array.isArray(variableToCheck);
|
|
33
|
+
};
|
|
34
|
+
const getRouteMetadata = (route, pluginName) => {
|
|
35
|
+
const attributes$1 = {
|
|
36
|
+
[attributes.HTTP_ROUTE]: route.path,
|
|
37
|
+
// eslint-disable-next-line typescript/no-deprecated -- TODO(v11): Replace deprecated attributes
|
|
38
|
+
[attributes.HTTP_METHOD]: route.method
|
|
39
|
+
};
|
|
40
|
+
let name;
|
|
41
|
+
if (pluginName) {
|
|
42
|
+
attributes$1[hapiTypes.AttributeNames.HAPI_TYPE] = hapiTypes.HapiLayerType.PLUGIN;
|
|
43
|
+
attributes$1[hapiTypes.AttributeNames.PLUGIN_NAME] = pluginName;
|
|
44
|
+
name = `${pluginName}: route - ${route.path}`;
|
|
45
|
+
} else {
|
|
46
|
+
attributes$1[hapiTypes.AttributeNames.HAPI_TYPE] = hapiTypes.HapiLayerType.ROUTER;
|
|
47
|
+
name = `route - ${route.path}`;
|
|
48
|
+
}
|
|
49
|
+
return { attributes: attributes$1, name };
|
|
50
|
+
};
|
|
51
|
+
const getExtMetadata = (extPoint, pluginName, methodName) => {
|
|
52
|
+
let baseName = `ext - ${extPoint}`;
|
|
53
|
+
if (methodName && methodName !== "method") {
|
|
54
|
+
baseName = `ext - ${extPoint} - ${methodName}`;
|
|
55
|
+
}
|
|
56
|
+
if (pluginName) {
|
|
57
|
+
return {
|
|
58
|
+
attributes: {
|
|
59
|
+
[hapiTypes.AttributeNames.EXT_TYPE]: extPoint,
|
|
60
|
+
[hapiTypes.AttributeNames.HAPI_TYPE]: hapiTypes.HapiLayerType.EXT,
|
|
61
|
+
[hapiTypes.AttributeNames.PLUGIN_NAME]: pluginName
|
|
62
|
+
},
|
|
63
|
+
name: `${pluginName}: ${baseName}`
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
attributes: {
|
|
68
|
+
[hapiTypes.AttributeNames.EXT_TYPE]: extPoint,
|
|
69
|
+
[hapiTypes.AttributeNames.HAPI_TYPE]: hapiTypes.HapiLayerType.EXT
|
|
70
|
+
},
|
|
71
|
+
name: baseName
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
function startMetadataSpan(metadata, original) {
|
|
75
|
+
return core.startSpan(
|
|
76
|
+
{
|
|
77
|
+
name: metadata.name,
|
|
78
|
+
op: `${metadata.attributes[hapiTypes.AttributeNames.HAPI_TYPE]}.hapi`,
|
|
79
|
+
attributes: {
|
|
80
|
+
...metadata.attributes,
|
|
81
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.http.orchestrion.hapi"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
original
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
function wrapRouteHandler(route, pluginName) {
|
|
88
|
+
if (route[hapiTypes.handlerPatched] === true) return route;
|
|
89
|
+
route[hapiTypes.handlerPatched] = true;
|
|
90
|
+
const wrapHandler = (oldHandler) => {
|
|
91
|
+
return function(...params) {
|
|
92
|
+
if (!core.getActiveSpan()) {
|
|
93
|
+
return oldHandler.call(this, ...params);
|
|
94
|
+
}
|
|
95
|
+
setHttpServerSpanRouteAttribute(route.path);
|
|
96
|
+
const metadata = getRouteMetadata(route, pluginName);
|
|
97
|
+
return startMetadataSpan(metadata, () => oldHandler.call(this, ...params));
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
if (typeof route.handler === "function") {
|
|
101
|
+
route.handler = wrapHandler(route.handler);
|
|
102
|
+
} else if (typeof route.options === "function") {
|
|
103
|
+
const oldOptions = route.options;
|
|
104
|
+
route.options = function(server) {
|
|
105
|
+
const options = oldOptions(server);
|
|
106
|
+
if (typeof options.handler === "function") {
|
|
107
|
+
options.handler = wrapHandler(options.handler);
|
|
108
|
+
}
|
|
109
|
+
return options;
|
|
110
|
+
};
|
|
111
|
+
} else if (typeof route.options?.handler === "function") {
|
|
112
|
+
route.options.handler = wrapHandler(route.options.handler);
|
|
113
|
+
}
|
|
114
|
+
return route;
|
|
115
|
+
}
|
|
116
|
+
function wrapExtMethods(method, extPoint, pluginName) {
|
|
117
|
+
if (Array.isArray(method)) {
|
|
118
|
+
for (let i = 0; i < method.length; i++) {
|
|
119
|
+
method[i] = wrapExtMethods(method[i], extPoint);
|
|
120
|
+
}
|
|
121
|
+
return method;
|
|
122
|
+
} else if (isPatchableExtMethod(method)) {
|
|
123
|
+
if (method[hapiTypes.handlerPatched] === true) return method;
|
|
124
|
+
method[hapiTypes.handlerPatched] = true;
|
|
125
|
+
const newHandler = function(...params) {
|
|
126
|
+
if (!core.getActiveSpan()) {
|
|
127
|
+
return method.apply(this, params);
|
|
128
|
+
}
|
|
129
|
+
const metadata = getExtMetadata(extPoint, pluginName, method.name);
|
|
130
|
+
return startMetadataSpan(metadata, () => method.apply(void 0, params));
|
|
131
|
+
};
|
|
132
|
+
newHandler[hapiTypes.handlerPatched] = true;
|
|
133
|
+
return newHandler;
|
|
134
|
+
}
|
|
135
|
+
return method;
|
|
136
|
+
}
|
|
137
|
+
function wrapRouteArguments(args, pluginName) {
|
|
138
|
+
const route = args[0];
|
|
139
|
+
if (Array.isArray(route)) {
|
|
140
|
+
for (let i = 0; i < route.length; i++) {
|
|
141
|
+
route[i] = wrapRouteHandler(route[i], pluginName);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
args[0] = wrapRouteHandler(route, pluginName);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function wrapExtArguments(args, pluginName) {
|
|
148
|
+
if (Array.isArray(args[0])) {
|
|
149
|
+
const eventsList = args[0];
|
|
150
|
+
for (let i = 0; i < eventsList.length; i++) {
|
|
151
|
+
const eventObj = eventsList[i];
|
|
152
|
+
if (isLifecycleExtType(eventObj.type)) {
|
|
153
|
+
const lifecycleEventObj = eventObj;
|
|
154
|
+
const handler = wrapExtMethods(lifecycleEventObj.method, eventObj.type, pluginName);
|
|
155
|
+
lifecycleEventObj.method = handler;
|
|
156
|
+
eventsList[i] = lifecycleEventObj;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
} else if (isDirectExtInput(args)) {
|
|
161
|
+
const extInput = args;
|
|
162
|
+
const method = extInput[1];
|
|
163
|
+
const handler = wrapExtMethods(method, extInput[0], pluginName);
|
|
164
|
+
args[1] = handler;
|
|
165
|
+
return;
|
|
166
|
+
} else if (isLifecycleExtEventObj(args[0])) {
|
|
167
|
+
const lifecycleEventObj = args[0];
|
|
168
|
+
const handler = wrapExtMethods(lifecycleEventObj.method, lifecycleEventObj.type, pluginName);
|
|
169
|
+
lifecycleEventObj.method = handler;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
exports.getExtMetadata = getExtMetadata;
|
|
174
|
+
exports.getRouteMetadata = getRouteMetadata;
|
|
175
|
+
exports.wrapExtArguments = wrapExtArguments;
|
|
176
|
+
exports.wrapRouteArguments = wrapRouteArguments;
|
|
177
|
+
//# sourceMappingURL=hapi-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hapi-utils.js","sources":["../../../../src/integrations/tracing-channel/hapi-utils.ts"],"sourcesContent":["/*\n * OTel-free, `@hapi/*`-free port of the span-building helpers and handler/ext\n * wrap logic from the vendored `@opentelemetry/instrumentation-hapi`\n * (upstream @opentelemetry/instrumentation-hapi@0.64.0). Span output (names,\n * ops, origins, attributes) is kept byte-identical to that instrumentation;\n * span creation goes through the `@sentry/core` API and the OTel active-span\n * guard is replaced with `getActiveSpan()`.\n */\n\nimport {\n getActiveSpan,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n startSpan,\n} from '@sentry/core';\nimport type {\n LifecycleMethod,\n PatchableExtMethod,\n PatchableServerRoute,\n ServerExtDirectInput,\n ServerExtEventsObject,\n ServerExtEventsRequestObject,\n ServerRequestExtType,\n ServerRoute,\n ServerRouteOptions,\n} from './hapi-types';\n// eslint-disable-next-line typescript/no-deprecated -- TODO(v11): Replace deprecated attributes\nimport { HTTP_METHOD, HTTP_ROUTE } from '@sentry/conventions/attributes';\nimport { AttributeNames, handlerPatched, HapiLayerType, HapiLifecycleMethodNames } from './hapi-types';\n\ntype SpanAttributes = Record<string, string | undefined>;\n\ninterface SpanMetadata {\n attributes: SpanAttributes;\n name: string;\n}\n\n/**\n * Set the `http.route` attribute on the root HTTP server span for the current trace.\n *\n * No-op when there is no active span, no root span, or the root span is not an\n * `http.server` span — so framework instrumentations can call this unconditionally\n * without risking attribute pollution on non-HTTP root spans.\n */\nfunction setHttpServerSpanRouteAttribute(route: string): void {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n return;\n }\n const rootSpan = getRootSpan(activeSpan);\n if (!rootSpan) {\n return;\n }\n if (spanToJSON(rootSpan).data[SEMANTIC_ATTRIBUTE_SENTRY_OP] !== 'http.server') {\n return;\n }\n rootSpan.setAttribute(HTTP_ROUTE, route);\n}\n\nconst isLifecycleExtType = (variableToCheck: unknown): variableToCheck is ServerRequestExtType => {\n return typeof variableToCheck === 'string' && HapiLifecycleMethodNames.has(variableToCheck);\n};\n\nconst isLifecycleExtEventObj = (variableToCheck: unknown): variableToCheck is ServerExtEventsRequestObject => {\n const event = (variableToCheck as ServerExtEventsRequestObject)?.type;\n return event !== undefined && isLifecycleExtType(event);\n};\n\nconst isDirectExtInput = (variableToCheck: unknown): variableToCheck is ServerExtDirectInput => {\n return (\n Array.isArray(variableToCheck) &&\n variableToCheck.length <= 3 &&\n isLifecycleExtType(variableToCheck[0]) &&\n typeof variableToCheck[1] === 'function'\n );\n};\n\nconst isPatchableExtMethod = (\n variableToCheck: PatchableExtMethod | PatchableExtMethod[],\n): variableToCheck is PatchableExtMethod => {\n return !Array.isArray(variableToCheck);\n};\n\n/** Build the span name and attributes for a Hapi route. */\nexport const getRouteMetadata = (route: ServerRoute, pluginName?: string): SpanMetadata => {\n const attributes: SpanAttributes = {\n [HTTP_ROUTE]: route.path,\n // eslint-disable-next-line typescript/no-deprecated -- TODO(v11): Replace deprecated attributes\n [HTTP_METHOD]: route.method,\n };\n\n let name;\n if (pluginName) {\n attributes[AttributeNames.HAPI_TYPE] = HapiLayerType.PLUGIN;\n attributes[AttributeNames.PLUGIN_NAME] = pluginName;\n name = `${pluginName}: route - ${route.path}`;\n } else {\n attributes[AttributeNames.HAPI_TYPE] = HapiLayerType.ROUTER;\n name = `route - ${route.path}`;\n }\n\n return { attributes, name };\n};\n\n/** Build the span name and attributes for a Hapi server extension. */\nexport const getExtMetadata = (\n extPoint: ServerRequestExtType,\n pluginName?: string,\n methodName?: string,\n): SpanMetadata => {\n let baseName = `ext - ${extPoint}`;\n if (methodName && methodName !== 'method') {\n // `method` is the default name for the extension in the ServerExtEventsObject format.\n baseName = `ext - ${extPoint} - ${methodName}`;\n }\n if (pluginName) {\n return {\n attributes: {\n [AttributeNames.EXT_TYPE]: extPoint,\n [AttributeNames.HAPI_TYPE]: HapiLayerType.EXT,\n [AttributeNames.PLUGIN_NAME]: pluginName,\n },\n name: `${pluginName}: ${baseName}`,\n };\n }\n return {\n attributes: {\n [AttributeNames.EXT_TYPE]: extPoint,\n [AttributeNames.HAPI_TYPE]: HapiLayerType.EXT,\n },\n name: baseName,\n };\n};\n\nfunction startMetadataSpan(metadata: SpanMetadata, original: () => unknown): unknown {\n return startSpan(\n {\n name: metadata.name,\n op: `${metadata.attributes[AttributeNames.HAPI_TYPE]}.hapi`,\n attributes: {\n ...metadata.attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.orchestrion.hapi',\n },\n },\n original,\n );\n}\n\n/**\n * Patches each individual route handler method in order to create the span. It\n * does not create spans when there is no parent span.\n */\nfunction wrapRouteHandler(route: PatchableServerRoute, pluginName?: string): PatchableServerRoute {\n if (route[handlerPatched] === true) return route;\n route[handlerPatched] = true;\n\n const wrapHandler: (oldHandler: LifecycleMethod) => LifecycleMethod = oldHandler => {\n return function (this: unknown, ...params: Parameters<LifecycleMethod>) {\n if (!getActiveSpan()) {\n return oldHandler.call(this, ...params);\n }\n setHttpServerSpanRouteAttribute(route.path);\n const metadata = getRouteMetadata(route, pluginName);\n return startMetadataSpan(metadata, () => oldHandler.call(this, ...params));\n };\n };\n\n if (typeof route.handler === 'function') {\n route.handler = wrapHandler(route.handler as LifecycleMethod);\n } else if (typeof route.options === 'function') {\n const oldOptions = route.options;\n route.options = function (server: unknown): ServerRouteOptions {\n const options = oldOptions(server);\n if (typeof options.handler === 'function') {\n options.handler = wrapHandler(options.handler as LifecycleMethod);\n }\n return options;\n };\n } else if (typeof route.options?.handler === 'function') {\n route.options.handler = wrapHandler(route.options.handler as LifecycleMethod);\n }\n return route;\n}\n\n/**\n * Wraps request extension methods to add instrumentation to each new extension\n * handler. It does not create spans when there is no parent span.\n */\nfunction wrapExtMethods<T extends PatchableExtMethod | PatchableExtMethod[]>(\n method: T,\n extPoint: ServerRequestExtType,\n pluginName?: string,\n): T {\n if (Array.isArray(method)) {\n for (let i = 0; i < method.length; i++) {\n method[i] = wrapExtMethods(method[i]!, extPoint);\n }\n return method;\n } else if (isPatchableExtMethod(method)) {\n if (method[handlerPatched] === true) return method;\n method[handlerPatched] = true;\n\n const newHandler: PatchableExtMethod = function (this: unknown, ...params: Parameters<LifecycleMethod>) {\n if (!getActiveSpan()) {\n return method.apply(this, params);\n }\n const metadata = getExtMetadata(extPoint, pluginName, method.name);\n return startMetadataSpan(metadata, () => method.apply(undefined, params));\n };\n // Mark the wrapper too (not just the original)\n newHandler[handlerPatched] = true;\n return newHandler as T;\n }\n return method;\n}\n\n/**\n * Wrap the route handler(s) in the live `server.route` arguments array, mutating\n * `args[0]` in place. `args[0]` is either a single route options object or an\n * array of them. Idempotent via the `handlerPatched` marker.\n */\nexport function wrapRouteArguments(args: unknown[], pluginName?: string): void {\n const route = args[0] as PatchableServerRoute | PatchableServerRoute[];\n if (Array.isArray(route)) {\n for (let i = 0; i < route.length; i++) {\n route[i] = wrapRouteHandler(route[i]!, pluginName);\n }\n } else {\n args[0] = wrapRouteHandler(route, pluginName);\n }\n}\n\n/**\n * Wrap the extension method(s) in the live `server.ext` arguments array,\n * mutating `args` in place. Handles the three accepted input shapes:\n * `(eventsArray)`, `(lifecycleEventObject)`, and `(extTypeString, method, options)`.\n * Idempotent via the `handlerPatched` marker.\n */\nexport function wrapExtArguments(args: unknown[], pluginName?: string): void {\n if (Array.isArray(args[0])) {\n const eventsList = args[0] as ServerExtEventsObject[] | ServerExtEventsRequestObject[];\n for (let i = 0; i < eventsList.length; i++) {\n const eventObj = eventsList[i]!;\n if (isLifecycleExtType(eventObj.type)) {\n const lifecycleEventObj = eventObj as ServerExtEventsRequestObject;\n const handler = wrapExtMethods(lifecycleEventObj.method, eventObj.type, pluginName);\n lifecycleEventObj.method = handler;\n eventsList[i] = lifecycleEventObj;\n }\n }\n return;\n } else if (isDirectExtInput(args)) {\n const extInput: ServerExtDirectInput = args;\n const method: PatchableExtMethod = extInput[1];\n const handler = wrapExtMethods(method, extInput[0], pluginName);\n args[1] = handler;\n return;\n } else if (isLifecycleExtEventObj(args[0])) {\n const lifecycleEventObj = args[0];\n const handler = wrapExtMethods(lifecycleEventObj.method, lifecycleEventObj.type, pluginName);\n lifecycleEventObj.method = handler;\n }\n}\n"],"names":["getActiveSpan","getRootSpan","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","HTTP_ROUTE","HapiLifecycleMethodNames","attributes","HTTP_METHOD","AttributeNames","HapiLayerType","startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","handlerPatched"],"mappings":";;;;;;AA8CA,SAAS,gCAAgC,KAAA,EAAqB;AAC5D,EAAA,MAAM,aAAaA,kBAAA,EAAc;AACjC,EAAA,IAAI,CAAC,UAAA,EAAY;AACf,IAAA;AAAA,EACF;AACA,EAAA,MAAM,QAAA,GAAWC,iBAAY,UAAU,CAAA;AACvC,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA;AAAA,EACF;AACA,EAAA,IAAIC,gBAAW,QAAQ,CAAA,CAAE,IAAA,CAAKC,iCAA4B,MAAM,aAAA,EAAe;AAC7E,IAAA;AAAA,EACF;AACA,EAAA,QAAA,CAAS,YAAA,CAAaC,uBAAY,KAAK,CAAA;AACzC;AAEA,MAAM,kBAAA,GAAqB,CAAC,eAAA,KAAsE;AAChG,EAAA,OAAO,OAAO,eAAA,KAAoB,QAAA,IAAYC,kCAAA,CAAyB,IAAI,eAAe,CAAA;AAC5F,CAAA;AAEA,MAAM,sBAAA,GAAyB,CAAC,eAAA,KAA8E;AAC5G,EAAA,MAAM,QAAS,eAAA,EAAkD,IAAA;AACjE,EAAA,OAAO,KAAA,KAAU,MAAA,IAAa,kBAAA,CAAmB,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;AAC1C,IAAA,MAAM,iBAAA,GAAoB,KAAK,CAAC,CAAA;AAChC,IAAA,MAAM,UAAU,cAAA,CAAe,iBAAA,CAAkB,MAAA,EAAQ,iBAAA,CAAkB,MAAM,UAAU,CAAA;AAC3F,IAAA,iBAAA,CAAkB,MAAA,GAAS,OAAA;AAAA,EAC7B;AACF;;;;;;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 hapiUtils = require('./hapi-utils.js');
|
|
8
|
+
|
|
9
|
+
const INTEGRATION_NAME = "Hapi";
|
|
10
|
+
const _hapiChannelIntegration = (() => {
|
|
11
|
+
return {
|
|
12
|
+
name: INTEGRATION_NAME,
|
|
13
|
+
setupOnce() {
|
|
14
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion:hapi] subscribing to channels "${channels.CHANNELS.HAPI_ROUTE}" / "${channels.CHANNELS.HAPI_EXT}"`);
|
|
18
|
+
diagnosticsChannel.tracingChannel(channels.CHANNELS.HAPI_ROUTE).subscribe({
|
|
19
|
+
start(rawCtx) {
|
|
20
|
+
const ctx = rawCtx;
|
|
21
|
+
hapiUtils.wrapRouteArguments(ctx.arguments, ctx.self?.realm?.plugin);
|
|
22
|
+
},
|
|
23
|
+
end() {
|
|
24
|
+
},
|
|
25
|
+
asyncStart() {
|
|
26
|
+
},
|
|
27
|
+
asyncEnd() {
|
|
28
|
+
},
|
|
29
|
+
error() {
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
diagnosticsChannel.tracingChannel(channels.CHANNELS.HAPI_EXT).subscribe({
|
|
33
|
+
start(rawCtx) {
|
|
34
|
+
const ctx = rawCtx;
|
|
35
|
+
hapiUtils.wrapExtArguments(ctx.arguments, ctx.self?.realm?.plugin);
|
|
36
|
+
},
|
|
37
|
+
end() {
|
|
38
|
+
},
|
|
39
|
+
asyncStart() {
|
|
40
|
+
},
|
|
41
|
+
asyncEnd() {
|
|
42
|
+
},
|
|
43
|
+
error() {
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
const hapiChannelIntegration = core.defineIntegration(_hapiChannelIntegration);
|
|
50
|
+
|
|
51
|
+
exports.hapiChannelIntegration = hapiChannelIntegration;
|
|
52
|
+
//# sourceMappingURL=hapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hapi.js","sources":["../../../../src/integrations/tracing-channel/hapi.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { wrapExtArguments, wrapRouteArguments } from './hapi-utils';\n\n// NOTE: same name as the OTel integration by design — when enabled, the OTel\n// 'Hapi' integration is omitted from the default set.\nconst INTEGRATION_NAME = 'Hapi' as const;\n\n/**\n * The shape orchestrion's transform attaches to the `@hapi/hapi` route/ext\n * tracing-channel `context` objects.\n *\n * `arguments` is the *live* args array passed to `server.route` / `server.ext`;\n * we mutate it in place to swap handlers for span-creating proxies. `self` is\n * the hapi server instance: the root server has `self.realm.plugin === undefined`,\n * while a plugin's clone server exposes the registering plugin's name there.\n */\ninterface HapiChannelContext {\n arguments: unknown[];\n self?: { realm?: { plugin?: string } };\n}\n\nconst _hapiChannelIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(`[orchestrion:hapi] subscribing to channels \"${CHANNELS.HAPI_ROUTE}\" / \"${CHANNELS.HAPI_EXT}\"`);\n\n // `subscribe` requires all five lifecycle hooks. We only act on `start`,\n // which orchestrion fires synchronously with the live args array — that's\n // the moment we mutate the handlers in place.\n diagnosticsChannel.tracingChannel(CHANNELS.HAPI_ROUTE).subscribe({\n start(rawCtx) {\n const ctx = rawCtx as HapiChannelContext;\n wrapRouteArguments(ctx.arguments, ctx.self?.realm?.plugin);\n },\n end() {},\n asyncStart() {},\n asyncEnd() {},\n error() {},\n });\n\n diagnosticsChannel.tracingChannel(CHANNELS.HAPI_EXT).subscribe({\n start(rawCtx) {\n const ctx = rawCtx as HapiChannelContext;\n wrapExtArguments(ctx.arguments, ctx.self?.realm?.plugin);\n },\n end() {},\n asyncStart() {},\n asyncEnd() {},\n error() {},\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * EXPERIMENTAL — orchestrion-driven hapi integration. Subscribes to the\n * `orchestrion:@hapi/hapi:route` / `:ext` channels injected into `@hapi/hapi`'s\n * `lib/server.js`. Requires the orchestrion runtime hook or bundler plugin.\n */\nexport const hapiChannelIntegration = defineIntegration(_hapiChannelIntegration);\n"],"names":["DEBUG_BUILD","debug","CHANNELS","wrapRouteArguments","wrapExtArguments","defineIntegration"],"mappings":";;;;;;;;AASA,MAAM,gBAAA,GAAmB,MAAA;AAgBzB,MAAM,2BAA2B,MAAM;AACrC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,IAAI,CAAC,mBAAmB,cAAA,EAAgB;AACtC,QAAA;AAAA,MACF;AAEA,MAAAA,sBAAA,IACEC,UAAA,CAAM,IAAI,CAAA,4CAAA,EAA+CC,iBAAA,CAAS,UAAU,CAAA,KAAA,EAAQA,iBAAA,CAAS,QAAQ,CAAA,CAAA,CAAG,CAAA;AAK1G,MAAA,kBAAA,CAAmB,cAAA,CAAeA,iBAAA,CAAS,UAAU,CAAA,CAAE,SAAA,CAAU;AAAA,QAC/D,MAAM,MAAA,EAAQ;AACZ,UAAA,MAAM,GAAA,GAAM,MAAA;AACZ,UAAAC,4BAAA,CAAmB,GAAA,CAAI,SAAA,EAAW,GAAA,CAAI,IAAA,EAAM,OAAO,MAAM,CAAA;AAAA,QAC3D,CAAA;AAAA,QACA,GAAA,GAAM;AAAA,QAAC,CAAA;AAAA,QACP,UAAA,GAAa;AAAA,QAAC,CAAA;AAAA,QACd,QAAA,GAAW;AAAA,QAAC,CAAA;AAAA,QACZ,KAAA,GAAQ;AAAA,QAAC;AAAA,OACV,CAAA;AAED,MAAA,kBAAA,CAAmB,cAAA,CAAeD,iBAAA,CAAS,QAAQ,CAAA,CAAE,SAAA,CAAU;AAAA,QAC7D,MAAM,MAAA,EAAQ;AACZ,UAAA,MAAM,GAAA,GAAM,MAAA;AACZ,UAAAE,0BAAA,CAAiB,GAAA,CAAI,SAAA,EAAW,GAAA,CAAI,IAAA,EAAM,OAAO,MAAM,CAAA;AAAA,QACzD,CAAA;AAAA,QACA,GAAA,GAAM;AAAA,QAAC,CAAA;AAAA,QACP,UAAA,GAAa;AAAA,QAAC,CAAA;AAAA,QACd,QAAA,GAAW;AAAA,QAAC,CAAA;AAAA,QACZ,KAAA,GAAQ;AAAA,QAAC;AAAA,OACV,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAOO,MAAM,sBAAA,GAAyBC,uBAAkB,uBAAuB;;;;"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const diagnosticsChannel = require('node:diagnostics_channel');
|
|
4
|
+
const attributes = require('@sentry/conventions/attributes');
|
|
5
|
+
const core = require('@sentry/core');
|
|
6
|
+
const debugBuild = require('../../debug-build.js');
|
|
7
|
+
const channels = require('../../orchestrion/channels.js');
|
|
8
|
+
const redisStatementSerializer = require('../../redis/redis-statement-serializer.js');
|
|
9
|
+
const tracingChannel = require('../../tracing-channel.js');
|
|
10
|
+
|
|
11
|
+
const INTEGRATION_NAME = "IORedis";
|
|
12
|
+
const ORIGIN = "auto.db.orchestrion.redis";
|
|
13
|
+
const ATTR_DB_CONNECTION_STRING = "db.connection_string";
|
|
14
|
+
function getConnectionOptions(self) {
|
|
15
|
+
return { host: self?.options?.host, port: self?.options?.port };
|
|
16
|
+
}
|
|
17
|
+
function connectionAttributes(host, port) {
|
|
18
|
+
return {
|
|
19
|
+
[attributes.DB_SYSTEM]: "redis",
|
|
20
|
+
[ATTR_DB_CONNECTION_STRING]: `redis://${host}:${port}`,
|
|
21
|
+
[attributes.NET_PEER_NAME]: host,
|
|
22
|
+
[attributes.NET_PEER_PORT]: port,
|
|
23
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const _ioredisChannelIntegration = ((options = {}) => {
|
|
27
|
+
const responseHook = options.responseHook;
|
|
28
|
+
return {
|
|
29
|
+
name: INTEGRATION_NAME,
|
|
30
|
+
setupOnce() {
|
|
31
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion:ioredis] subscribing to "${channels.CHANNELS.IOREDIS_COMMAND}"/"${channels.CHANNELS.IOREDIS_CONNECT}"`);
|
|
35
|
+
const commandChannel = diagnosticsChannel.tracingChannel(
|
|
36
|
+
channels.CHANNELS.IOREDIS_COMMAND
|
|
37
|
+
);
|
|
38
|
+
const connectChannel = diagnosticsChannel.tracingChannel(
|
|
39
|
+
channels.CHANNELS.IOREDIS_CONNECT
|
|
40
|
+
);
|
|
41
|
+
core.waitForTracingChannelBinding(() => {
|
|
42
|
+
tracingChannel.bindTracingChannelToSpan(
|
|
43
|
+
commandChannel,
|
|
44
|
+
(data) => {
|
|
45
|
+
if (!core.getActiveSpan()) {
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
const command = data.arguments?.[0];
|
|
49
|
+
if (!command || typeof command !== "object") {
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
const { host, port } = getConnectionOptions(data.self);
|
|
53
|
+
const statement = redisStatementSerializer.defaultDbStatementSerializer(command.name, command.args ?? []);
|
|
54
|
+
return core.startInactiveSpan({
|
|
55
|
+
name: statement,
|
|
56
|
+
op: "db",
|
|
57
|
+
attributes: { ...connectionAttributes(host, port), [attributes.DB_STATEMENT]: statement }
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
beforeSpanEnd(span, data) {
|
|
62
|
+
if ("error" in data || !responseHook) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const command = data.arguments?.[0];
|
|
66
|
+
if (command) {
|
|
67
|
+
runResponseHook(responseHook, span, command, data.result);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
tracingChannel.bindTracingChannelToSpan(connectChannel, (data) => {
|
|
73
|
+
if (!core.getActiveSpan()) {
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
const { host, port } = getConnectionOptions(data.self);
|
|
77
|
+
return core.startInactiveSpan({
|
|
78
|
+
name: "connect",
|
|
79
|
+
op: "db",
|
|
80
|
+
attributes: { ...connectionAttributes(host, port), [attributes.DB_STATEMENT]: "connect" }
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
function runResponseHook(hook, span, command, result) {
|
|
88
|
+
try {
|
|
89
|
+
hook(span, command.name, command.args, result);
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const ioredisChannelIntegration = core.defineIntegration(_ioredisChannelIntegration);
|
|
94
|
+
|
|
95
|
+
exports.ioredisChannelIntegration = ioredisChannelIntegration;
|
|
96
|
+
//# sourceMappingURL=ioredis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ioredis.js","sources":["../../../../src/integrations/tracing-channel/ioredis.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated -- we intentionally emit the OLD db/net semconv\n to match `@opentelemetry/instrumentation-ioredis` (and Sentry's `inferDbSpanData`, which keys off\n `db.statement`). TODO(v11): switch to the non-deprecated `db.system.name`/`db.query.text`/\n `server.address`/`server.port` conventions and drop this disable. */\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { DB_STATEMENT, DB_SYSTEM, NET_PEER_NAME, NET_PEER_PORT } from '@sentry/conventions/attributes';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { defaultDbStatementSerializer } from '../../redis/redis-statement-serializer';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Distinct from the OTel `Redis` integration, which is composite (node-redis +\n// ioredis + the >=5.11.0 diagnostics_channel subscriber) and stays in the set;\n// only its ioredis monkey-patch is gated off in the node SDK when this is active.\nconst INTEGRATION_NAME = 'IORedis' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.redis';\n\n// todo(v11): Let's drop this as this is already covered with host and port\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\n\n/** Mirrors `@opentelemetry/instrumentation-ioredis`' response hook. Not called for failed commands. */\nexport type IORedisResponseHook = (span: Span, command: string, args: Array<string | Buffer>, result: unknown) => void;\n\nexport interface IORedisChannelIntegrationOptions {\n responseHook?: IORedisResponseHook;\n}\n\n/** Structural type for the command object ioredis passes to `sendCommand`. */\ninterface RedisCommand {\n name: string;\n args: Array<string | Buffer>;\n}\n\ninterface RedisClientLike {\n options?: { host?: string; port?: number };\n}\n\ninterface IORedisCommandContext {\n arguments?: unknown[];\n self?: RedisClientLike;\n result?: unknown;\n error?: unknown;\n}\n\ntype IORedisConnectContext = Omit<IORedisCommandContext, 'arguments'>;\n\nfunction getConnectionOptions(self: RedisClientLike | undefined): { host?: string; port?: number } {\n return { host: self?.options?.host, port: self?.options?.port };\n}\n\nfunction connectionAttributes(host: string | undefined, port: number | undefined): Record<string, unknown> {\n return {\n [DB_SYSTEM]: 'redis',\n [ATTR_DB_CONNECTION_STRING]: `redis://${host}:${port}`,\n [NET_PEER_NAME]: host,\n [NET_PEER_PORT]: port,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n}\n\nconst _ioredisChannelIntegration = ((options: IORedisChannelIntegrationOptions = {}) => {\n const responseHook = options.responseHook;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19.\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(`[orchestrion:ioredis] subscribing to \"${CHANNELS.IOREDIS_COMMAND}\"/\"${CHANNELS.IOREDIS_CONNECT}\"`);\n\n const commandChannel = diagnosticsChannel.tracingChannel<IORedisCommandContext, IORedisCommandContext>(\n CHANNELS.IOREDIS_COMMAND,\n );\n const connectChannel = diagnosticsChannel.tracingChannel<IORedisConnectContext, IORedisConnectContext>(\n CHANNELS.IOREDIS_CONNECT,\n );\n\n // `bindTracingChannelToSpan` uses `bindStore`, which needs the async-context\n // binding that `initOpenTelemetry()` registers after integration `setupOnce` —\n // defer until it's available (matches the native redis diagnostics-channel subscriber).\n waitForTracingChannelBinding(() => {\n bindTracingChannelToSpan(\n commandChannel,\n data => {\n // ioredis' `requireParentSpan` default: only create a span under an active span.\n if (!getActiveSpan()) {\n return undefined;\n }\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (!command || typeof command !== 'object') {\n return undefined;\n }\n const { host, port } = getConnectionOptions(data.self);\n const statement = defaultDbStatementSerializer(command.name, command.args ?? []);\n return startInactiveSpan({\n name: statement,\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: statement },\n });\n },\n {\n beforeSpanEnd(span, data) {\n if ('error' in data || !responseHook) {\n return;\n }\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (command) {\n runResponseHook(responseHook, span, command, data.result);\n }\n },\n },\n );\n\n bindTracingChannelToSpan(connectChannel, data => {\n if (!getActiveSpan()) {\n return undefined;\n }\n const { host, port } = getConnectionOptions(data.self);\n return startInactiveSpan({\n name: 'connect',\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: 'connect' },\n });\n });\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction runResponseHook(hook: IORedisResponseHook, span: Span, command: RedisCommand, result: unknown): void {\n try {\n hook(span, command.name, command.args, result);\n } catch {\n // never let a user-provided response hook break instrumentation\n }\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven ioredis integration. Subscribes to\n * `orchestrion:ioredis:command` / `:connect` (injected into ioredis' `<5.11.0`\n * `sendCommand`/`connect`) and creates db spans matching\n * `@opentelemetry/instrumentation-ioredis`. Requires the orchestrion runtime hook\n * or bundler plugin.\n */\nexport const ioredisChannelIntegration = defineIntegration(_ioredisChannelIntegration);\n"],"names":["DB_SYSTEM","NET_PEER_NAME","NET_PEER_PORT","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","DEBUG_BUILD","debug","CHANNELS","waitForTracingChannelBinding","bindTracingChannelToSpan","getActiveSpan","defaultDbStatementSerializer","startInactiveSpan","DB_STATEMENT","defineIntegration"],"mappings":";;;;;;;;;;AAuBA,MAAM,gBAAA,GAAmB,SAAA;AAEzB,MAAM,MAAA,GAAS,2BAAA;AAGf,MAAM,yBAAA,GAA4B,sBAAA;AA4BlC,SAAS,qBAAqB,IAAA,EAAqE;AACjG,EAAA,OAAO,EAAE,MAAM,IAAA,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;AAAU,WAC9E,CAAA;AAAA,QACH,CAAC,CAAA;AAAA,MACH,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAEA,SAAS,eAAA,CAAgB,IAAA,EAA2B,IAAA,EAAY,OAAA,EAAuB,MAAA,EAAuB;AAC5G,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAM,OAAA,CAAQ,MAAM,MAAM,CAAA;AAAA,EAC/C,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AASO,MAAM,yBAAA,GAA4BC,uBAAkB,0BAA0B;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 = "LruMemoizer";
|
|
10
|
+
const _lruMemoizerChannelIntegration = (() => {
|
|
11
|
+
return {
|
|
12
|
+
name: INTEGRATION_NAME,
|
|
13
|
+
setupOnce() {
|
|
14
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion:lru-memoizer] subscribing to channel "${channels.CHANNELS.LRU_MEMOIZER_LOAD}"`);
|
|
18
|
+
core.waitForTracingChannelBinding(() => {
|
|
19
|
+
tracingChannel.bindTracingChannelToSpan(
|
|
20
|
+
diagnosticsChannel.tracingChannel(channels.CHANNELS.LRU_MEMOIZER_LOAD),
|
|
21
|
+
// We only want the helper's caller-context restore for the callback lru-memoizer fires from a detached `setImmediate`.
|
|
22
|
+
() => void 0
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
const lruMemoizerChannelIntegration = core.defineIntegration(_lruMemoizerChannelIntegration);
|
|
29
|
+
|
|
30
|
+
exports.lruMemoizerChannelIntegration = lruMemoizerChannelIntegration;
|
|
31
|
+
//# sourceMappingURL=lru-memoizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-memoizer.js","sources":["../../../../src/integrations/tracing-channel/lru-memoizer.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration, waitForTracingChannelBinding } 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\n// 'LruMemoizer' integration is omitted from the default set.\nconst INTEGRATION_NAME = 'LruMemoizer' as const;\n\ninterface LruMemoizerLoadContext {\n arguments: unknown[];\n}\n\nconst _lruMemoizerChannelIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19 so do nothing in that case.\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD && debug.log(`[orchestrion:lru-memoizer] subscribing to channel \"${CHANNELS.LRU_MEMOIZER_LOAD}\"`);\n\n waitForTracingChannelBinding(() => {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<LruMemoizerLoadContext>(CHANNELS.LRU_MEMOIZER_LOAD),\n // We only want the helper's caller-context restore for the callback lru-memoizer fires from a detached `setImmediate`.\n () => undefined,\n );\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * EXPERIMENTAL — orchestrion-driven lru-memoizer integration. Subscribes to\n * `orchestrion:lru-memoizer:load` (injected into `lru-memoizer/lib/async.js`'s\n * `memoizedFunction`). Creates no spans; only re-runs the memoized callback with the\n * caller's scope. Requires the orchestrion runtime hook or bundler plugin.\n */\nexport const lruMemoizerChannelIntegration = defineIntegration(_lruMemoizerChannelIntegration);\n"],"names":["DEBUG_BUILD","debug","CHANNELS","waitForTracingChannelBinding","bindTracingChannelToSpan","defineIntegration"],"mappings":";;;;;;;;AASA,MAAM,gBAAA,GAAmB,aAAA;AAMzB,MAAM,kCAAkC,MAAM;AAC5C,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAAC,mBAAmB,cAAA,EAAgB;AACtC,QAAA;AAAA,MACF;AAEA,MAAAA,sBAAA,IAAeC,UAAA,CAAM,GAAA,CAAI,CAAA,mDAAA,EAAsDC,iBAAA,CAAS,iBAAiB,CAAA,CAAA,CAAG,CAAA;AAE5G,MAAAC,iCAAA,CAA6B,MAAM;AACjC,QAAAC,uCAAA;AAAA,UACE,kBAAA,CAAmB,cAAA,CAAuCF,iBAAA,CAAS,iBAAiB,CAAA;AAAA;AAAA,UAEpF,MAAM;AAAA,SACR;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAQO,MAAM,6BAAA,GAAgCG,uBAAkB,8BAA8B;;;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const diagnosticsChannel = require('node:diagnostics_channel');
|
|
4
4
|
const core = require('@sentry/core');
|
|
5
5
|
const debugBuild = require('../../debug-build.js');
|
|
6
6
|
const channels = require('../../orchestrion/channels.js');
|
|
7
|
+
const tracingChannel = require('../../tracing-channel.js');
|
|
7
8
|
|
|
8
9
|
const INTEGRATION_NAME = "Mysql";
|
|
9
10
|
const ATTR_DB_SYSTEM = "db.system";
|
|
@@ -17,92 +18,54 @@ const _mysqlChannelIntegration = (() => {
|
|
|
17
18
|
return {
|
|
18
19
|
name: INTEGRATION_NAME,
|
|
19
20
|
setupOnce() {
|
|
21
|
+
if (!diagnosticsChannel.tracingChannel) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
20
24
|
debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion:mysql] subscribing to channel "${channels.CHANNELS.MYSQL_QUERY}"`);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
spans.set(rawCtx, span);
|
|
46
|
-
const scope = core.getCurrentScope();
|
|
47
|
-
parentScopes.set(rawCtx, scope);
|
|
48
|
-
if (ctx.arguments.length > 0) {
|
|
49
|
-
const cbIdx = ctx.arguments.length - 1;
|
|
50
|
-
const orchestrionWrappedCb = ctx.arguments[cbIdx];
|
|
51
|
-
if (typeof orchestrionWrappedCb === "function") {
|
|
52
|
-
const wrapped = orchestrionWrappedCb;
|
|
53
|
-
ctx.arguments[cbIdx] = function(...args) {
|
|
54
|
-
return core.withScope(scope, () => wrapped.apply(this, args));
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
end(rawCtx) {
|
|
60
|
-
const ctx = rawCtx;
|
|
61
|
-
if (ctx.error !== void 0) {
|
|
62
|
-
finishSpan(rawCtx);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const result = ctx.result;
|
|
66
|
-
if (result && typeof result === "object" && hasOnMethod(result)) {
|
|
67
|
-
const span = spans.get(rawCtx);
|
|
68
|
-
if (!span) return;
|
|
69
|
-
const parentScope = parentScopes.get(rawCtx);
|
|
70
|
-
if (parentScope) {
|
|
71
|
-
core.bindScopeToEmitter(result, parentScope);
|
|
72
|
-
}
|
|
73
|
-
result.on("error", (err) => {
|
|
74
|
-
span.setStatus({
|
|
75
|
-
code: core.SPAN_STATUS_ERROR,
|
|
76
|
-
message: err instanceof Error ? err.message : "unknown_error"
|
|
77
|
-
});
|
|
78
|
-
finishSpan(rawCtx);
|
|
25
|
+
core.waitForTracingChannelBinding(() => {
|
|
26
|
+
tracingChannel.bindTracingChannelToSpan(
|
|
27
|
+
diagnosticsChannel.tracingChannel(channels.CHANNELS.MYSQL_QUERY),
|
|
28
|
+
(data) => {
|
|
29
|
+
const sql = extractSql(data.arguments[0]);
|
|
30
|
+
const { host, port, database, user } = getConnectionConfig(data.self);
|
|
31
|
+
const portNumber = typeof port === "string" ? parseInt(port, 10) : port;
|
|
32
|
+
const portIsNumber = typeof portNumber === "number" && !isNaN(portNumber);
|
|
33
|
+
data._sentryCallerScope = core.getCurrentScope();
|
|
34
|
+
return core.startInactiveSpan({
|
|
35
|
+
name: sql ?? "mysql.query",
|
|
36
|
+
kind: core.SPAN_KIND.CLIENT,
|
|
37
|
+
op: "db",
|
|
38
|
+
attributes: {
|
|
39
|
+
[ATTR_DB_SYSTEM]: "mysql",
|
|
40
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.db.orchestrion.mysql",
|
|
41
|
+
[ATTR_DB_CONNECTION_STRING]: getJDBCString(host, portIsNumber ? portNumber : void 0, database),
|
|
42
|
+
...database ? { [ATTR_DB_NAME]: database } : {},
|
|
43
|
+
...user ? { [ATTR_DB_USER]: user } : {},
|
|
44
|
+
...sql ? { [ATTR_DB_STATEMENT]: sql } : {},
|
|
45
|
+
...host ? { [ATTR_NET_PEER_NAME]: host } : {},
|
|
46
|
+
...portIsNumber ? { [ATTR_NET_PEER_PORT]: portNumber } : {}
|
|
47
|
+
}
|
|
79
48
|
});
|
|
80
|
-
|
|
81
|
-
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
// No-callback `query(sql)` returns a streamable `Query` emitter as `result`; it settles on the
|
|
52
|
+
// emitter's `'end'`/`'error'`, not the channel, so defer ending to those.
|
|
53
|
+
deferSpanEnd({ data, end }) {
|
|
54
|
+
const result = data.result;
|
|
55
|
+
if (!result || typeof result !== "object" || !hasOnMethod(result)) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const callerScope = data._sentryCallerScope;
|
|
59
|
+
if (callerScope) {
|
|
60
|
+
core.bindScopeToEmitter(result, callerScope);
|
|
61
|
+
}
|
|
62
|
+
result.on("error", (err) => end(err));
|
|
63
|
+
result.on("end", () => end());
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
82
66
|
}
|
|
83
|
-
|
|
84
|
-
error(rawCtx) {
|
|
85
|
-
const ctx = rawCtx;
|
|
86
|
-
const span = spans.get(rawCtx);
|
|
87
|
-
if (!span) return;
|
|
88
|
-
span.setStatus({
|
|
89
|
-
code: core.SPAN_STATUS_ERROR,
|
|
90
|
-
message: ctx.error instanceof Error ? ctx.error.message : "unknown_error"
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
asyncStart() {
|
|
94
|
-
},
|
|
95
|
-
asyncEnd(rawCtx) {
|
|
96
|
-
finishSpan(rawCtx);
|
|
97
|
-
}
|
|
67
|
+
);
|
|
98
68
|
});
|
|
99
|
-
function finishSpan(rawCtx) {
|
|
100
|
-
const span = spans.get(rawCtx);
|
|
101
|
-
if (!span) return;
|
|
102
|
-
span.end();
|
|
103
|
-
spans.delete(rawCtx);
|
|
104
|
-
parentScopes.delete(rawCtx);
|
|
105
|
-
}
|
|
106
69
|
}
|
|
107
70
|
};
|
|
108
71
|
});
|