@sentry/server-utils 10.63.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.
Files changed (206) hide show
  1. package/build/cjs/index.js +6 -2
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/tracing-channel/anthropic.js +101 -0
  4. package/build/cjs/integrations/tracing-channel/anthropic.js.map +1 -0
  5. package/build/cjs/integrations/tracing-channel/hapi-types.js +30 -0
  6. package/build/cjs/integrations/tracing-channel/hapi-types.js.map +1 -0
  7. package/build/cjs/integrations/tracing-channel/hapi-utils.js +177 -0
  8. package/build/cjs/integrations/tracing-channel/hapi-utils.js.map +1 -0
  9. package/build/cjs/integrations/tracing-channel/hapi.js +52 -0
  10. package/build/cjs/integrations/tracing-channel/hapi.js.map +1 -0
  11. package/build/cjs/integrations/tracing-channel/ioredis.js +96 -0
  12. package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -0
  13. package/build/cjs/integrations/tracing-channel/mysql.js +1 -0
  14. package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -1
  15. package/build/cjs/integrations/tracing-channel/openai.js +83 -0
  16. package/build/cjs/integrations/tracing-channel/openai.js.map +1 -0
  17. package/build/cjs/integrations/tracing-channel/postgres.js +170 -0
  18. package/build/cjs/integrations/tracing-channel/postgres.js.map +1 -0
  19. package/build/cjs/integrations/tracing-channel/vercel-ai.js +25 -0
  20. package/build/cjs/integrations/tracing-channel/vercel-ai.js.map +1 -0
  21. package/build/cjs/mongoose/index.js +23 -0
  22. package/build/cjs/mongoose/index.js.map +1 -0
  23. package/build/cjs/mongoose/mongoose-dc-subscriber.js +97 -0
  24. package/build/cjs/mongoose/mongoose-dc-subscriber.js.map +1 -0
  25. package/build/cjs/orchestrion/bundler/vite.js +3 -3
  26. package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
  27. package/build/cjs/orchestrion/channels.js +17 -2
  28. package/build/cjs/orchestrion/channels.js.map +1 -1
  29. package/build/cjs/orchestrion/config/anthropic-ai.js +43 -0
  30. package/build/cjs/orchestrion/config/anthropic-ai.js.map +1 -0
  31. package/build/cjs/orchestrion/config/hapi.js +26 -0
  32. package/build/cjs/orchestrion/config/hapi.js.map +1 -0
  33. package/build/cjs/orchestrion/config/index.js +35 -0
  34. package/build/cjs/orchestrion/config/index.js.map +1 -0
  35. package/build/cjs/orchestrion/config/ioredis.js +35 -0
  36. package/build/cjs/orchestrion/config/ioredis.js.map +1 -0
  37. package/build/cjs/orchestrion/config/lru-memoizer.js +17 -0
  38. package/build/cjs/orchestrion/config/lru-memoizer.js.map +1 -0
  39. package/build/cjs/orchestrion/config/mysql.js +16 -0
  40. package/build/cjs/orchestrion/config/mysql.js.map +1 -0
  41. package/build/cjs/orchestrion/config/openai.js +40 -0
  42. package/build/cjs/orchestrion/config/openai.js.map +1 -0
  43. package/build/cjs/orchestrion/config/pg.js +51 -0
  44. package/build/cjs/orchestrion/config/pg.js.map +1 -0
  45. package/build/cjs/orchestrion/config/vercel-ai.js +44 -0
  46. package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -0
  47. package/build/cjs/orchestrion/detect.js +6 -1
  48. package/build/cjs/orchestrion/detect.js.map +1 -1
  49. package/build/cjs/orchestrion/index.js +27 -5
  50. package/build/cjs/orchestrion/index.js.map +1 -1
  51. package/build/cjs/orchestrion/runtime/register.js +10 -7
  52. package/build/cjs/orchestrion/runtime/register.js.map +1 -1
  53. package/build/cjs/redis/redis-statement-serializer.js +34 -0
  54. package/build/cjs/redis/redis-statement-serializer.js.map +1 -0
  55. package/build/cjs/tracing-channel.js +1 -1
  56. package/build/cjs/tracing-channel.js.map +1 -1
  57. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +11 -4
  58. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  59. package/build/cjs/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js +256 -0
  60. package/build/cjs/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js.map +1 -0
  61. package/build/esm/index.js +2 -0
  62. package/build/esm/index.js.map +1 -1
  63. package/build/esm/integrations/tracing-channel/anthropic.js +99 -0
  64. package/build/esm/integrations/tracing-channel/anthropic.js.map +1 -0
  65. package/build/esm/integrations/tracing-channel/hapi-types.js +25 -0
  66. package/build/esm/integrations/tracing-channel/hapi-types.js.map +1 -0
  67. package/build/esm/integrations/tracing-channel/hapi-utils.js +172 -0
  68. package/build/esm/integrations/tracing-channel/hapi-utils.js.map +1 -0
  69. package/build/esm/integrations/tracing-channel/hapi.js +50 -0
  70. package/build/esm/integrations/tracing-channel/hapi.js.map +1 -0
  71. package/build/esm/integrations/tracing-channel/ioredis.js +94 -0
  72. package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -0
  73. package/build/esm/integrations/tracing-channel/mysql.js +2 -1
  74. package/build/esm/integrations/tracing-channel/mysql.js.map +1 -1
  75. package/build/esm/integrations/tracing-channel/openai.js +81 -0
  76. package/build/esm/integrations/tracing-channel/openai.js.map +1 -0
  77. package/build/esm/integrations/tracing-channel/postgres.js +168 -0
  78. package/build/esm/integrations/tracing-channel/postgres.js.map +1 -0
  79. package/build/esm/integrations/tracing-channel/vercel-ai.js +23 -0
  80. package/build/esm/integrations/tracing-channel/vercel-ai.js.map +1 -0
  81. package/build/esm/mongoose/index.js +21 -0
  82. package/build/esm/mongoose/index.js.map +1 -0
  83. package/build/esm/mongoose/mongoose-dc-subscriber.js +89 -0
  84. package/build/esm/mongoose/mongoose-dc-subscriber.js.map +1 -0
  85. package/build/esm/orchestrion/bundler/vite.js +1 -1
  86. package/build/esm/orchestrion/channels.js +17 -2
  87. package/build/esm/orchestrion/channels.js.map +1 -1
  88. package/build/esm/orchestrion/config/anthropic-ai.js +40 -0
  89. package/build/esm/orchestrion/config/anthropic-ai.js.map +1 -0
  90. package/build/esm/orchestrion/config/hapi.js +23 -0
  91. package/build/esm/orchestrion/config/hapi.js.map +1 -0
  92. package/build/esm/orchestrion/config/index.js +31 -0
  93. package/build/esm/orchestrion/config/index.js.map +1 -0
  94. package/build/esm/orchestrion/config/ioredis.js +32 -0
  95. package/build/esm/orchestrion/config/ioredis.js.map +1 -0
  96. package/build/esm/orchestrion/config/lru-memoizer.js +14 -0
  97. package/build/esm/orchestrion/config/lru-memoizer.js.map +1 -0
  98. package/build/esm/orchestrion/config/mysql.js +13 -0
  99. package/build/esm/orchestrion/config/mysql.js.map +1 -0
  100. package/build/esm/orchestrion/config/openai.js +37 -0
  101. package/build/esm/orchestrion/config/openai.js.map +1 -0
  102. package/build/esm/orchestrion/config/pg.js +48 -0
  103. package/build/esm/orchestrion/config/pg.js.map +1 -0
  104. package/build/esm/orchestrion/config/vercel-ai.js +41 -0
  105. package/build/esm/orchestrion/config/vercel-ai.js.map +1 -0
  106. package/build/esm/orchestrion/detect.js +6 -2
  107. package/build/esm/orchestrion/detect.js.map +1 -1
  108. package/build/esm/orchestrion/index.js +21 -3
  109. package/build/esm/orchestrion/index.js.map +1 -1
  110. package/build/esm/orchestrion/runtime/register.js +8 -4
  111. package/build/esm/orchestrion/runtime/register.js.map +1 -1
  112. package/build/esm/package.json +1 -1
  113. package/build/esm/redis/redis-statement-serializer.js +32 -0
  114. package/build/esm/redis/redis-statement-serializer.js.map +1 -0
  115. package/build/esm/tracing-channel.js +2 -2
  116. package/build/esm/tracing-channel.js.map +1 -1
  117. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +14 -8
  118. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  119. package/build/esm/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js +254 -0
  120. package/build/esm/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js.map +1 -0
  121. package/build/types/index.d.ts +2 -0
  122. package/build/types/index.d.ts.map +1 -1
  123. package/build/types/integrations/tracing-channel/anthropic.d.ts +10 -0
  124. package/build/types/integrations/tracing-channel/anthropic.d.ts.map +1 -0
  125. package/build/types/integrations/tracing-channel/hapi-types.d.ts +53 -0
  126. package/build/types/integrations/tracing-channel/hapi-types.d.ts.map +1 -0
  127. package/build/types/integrations/tracing-channel/hapi-utils.d.ts +25 -0
  128. package/build/types/integrations/tracing-channel/hapi-utils.d.ts.map +1 -0
  129. package/build/types/integrations/tracing-channel/hapi.d.ts +9 -0
  130. package/build/types/integrations/tracing-channel/hapi.d.ts.map +1 -0
  131. package/build/types/integrations/tracing-channel/ioredis.d.ts +17 -0
  132. package/build/types/integrations/tracing-channel/ioredis.d.ts.map +1 -0
  133. package/build/types/integrations/tracing-channel/mysql.d.ts.map +1 -1
  134. package/build/types/integrations/tracing-channel/openai.d.ts +10 -0
  135. package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -0
  136. package/build/types/integrations/tracing-channel/postgres.d.ts +15 -0
  137. package/build/types/integrations/tracing-channel/postgres.d.ts.map +1 -0
  138. package/build/types/integrations/tracing-channel/vercel-ai.d.ts +13 -0
  139. package/build/types/integrations/tracing-channel/vercel-ai.d.ts.map +1 -0
  140. package/build/types/mongoose/index.d.ts +11 -0
  141. package/build/types/mongoose/index.d.ts.map +1 -0
  142. package/build/types/mongoose/mongoose-dc-subscriber.d.ts +63 -0
  143. package/build/types/mongoose/mongoose-dc-subscriber.d.ts.map +1 -0
  144. package/build/types/orchestrion/channels.d.ts +21 -1
  145. package/build/types/orchestrion/channels.d.ts.map +1 -1
  146. package/build/types/orchestrion/config/anthropic-ai.d.ts +31 -0
  147. package/build/types/orchestrion/config/anthropic-ai.d.ts.map +1 -0
  148. package/build/types/orchestrion/config/hapi.d.ts +17 -0
  149. package/build/types/orchestrion/config/hapi.d.ts.map +1 -0
  150. package/build/types/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
  151. package/build/types/orchestrion/config/index.d.ts.map +1 -0
  152. package/build/types/orchestrion/config/ioredis.d.ts +7 -0
  153. package/build/types/orchestrion/config/ioredis.d.ts.map +1 -0
  154. package/build/types/orchestrion/config/lru-memoizer.d.ts +16 -0
  155. package/build/types/orchestrion/config/lru-memoizer.d.ts.map +1 -0
  156. package/build/types/orchestrion/config/mysql.d.ts +16 -0
  157. package/build/types/orchestrion/config/mysql.d.ts.map +1 -0
  158. package/build/types/orchestrion/config/openai.d.ts +20 -0
  159. package/build/types/orchestrion/config/openai.d.ts.map +1 -0
  160. package/build/types/orchestrion/config/pg.d.ts +33 -0
  161. package/build/types/orchestrion/config/pg.d.ts.map +1 -0
  162. package/build/types/orchestrion/config/vercel-ai.d.ts +11 -0
  163. package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -0
  164. package/build/types/orchestrion/detect.d.ts +10 -0
  165. package/build/types/orchestrion/detect.d.ts.map +1 -1
  166. package/build/types/orchestrion/index.d.ts +53 -3
  167. package/build/types/orchestrion/index.d.ts.map +1 -1
  168. package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
  169. package/build/types/redis/redis-statement-serializer.d.ts +6 -0
  170. package/build/types/redis/redis-statement-serializer.d.ts.map +1 -0
  171. package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts +10 -4
  172. package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
  173. package/build/types/vercel-ai/vercel-ai-orchestrion-v6-subscriber.d.ts +12 -0
  174. package/build/types/vercel-ai/vercel-ai-orchestrion-v6-subscriber.d.ts.map +1 -0
  175. package/build/types-ts3.8/index.d.ts +2 -0
  176. package/build/types-ts3.8/integrations/tracing-channel/anthropic.d.ts +10 -0
  177. package/build/types-ts3.8/integrations/tracing-channel/hapi-types.d.ts +65 -0
  178. package/build/types-ts3.8/integrations/tracing-channel/hapi-utils.d.ts +25 -0
  179. package/build/types-ts3.8/integrations/tracing-channel/hapi.d.ts +9 -0
  180. package/build/types-ts3.8/integrations/tracing-channel/ioredis.d.ts +17 -0
  181. package/build/types-ts3.8/integrations/tracing-channel/openai.d.ts +10 -0
  182. package/build/types-ts3.8/integrations/tracing-channel/postgres.d.ts +15 -0
  183. package/build/types-ts3.8/integrations/tracing-channel/vercel-ai.d.ts +13 -0
  184. package/build/types-ts3.8/mongoose/index.d.ts +11 -0
  185. package/build/types-ts3.8/mongoose/mongoose-dc-subscriber.d.ts +63 -0
  186. package/build/types-ts3.8/orchestrion/channels.d.ts +21 -1
  187. package/build/types-ts3.8/orchestrion/config/anthropic-ai.d.ts +31 -0
  188. package/build/types-ts3.8/orchestrion/config/hapi.d.ts +17 -0
  189. package/build/types-ts3.8/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
  190. package/build/types-ts3.8/orchestrion/config/ioredis.d.ts +7 -0
  191. package/build/types-ts3.8/orchestrion/config/lru-memoizer.d.ts +16 -0
  192. package/build/types-ts3.8/orchestrion/config/mysql.d.ts +16 -0
  193. package/build/types-ts3.8/orchestrion/config/openai.d.ts +20 -0
  194. package/build/types-ts3.8/orchestrion/config/pg.d.ts +33 -0
  195. package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +11 -0
  196. package/build/types-ts3.8/orchestrion/detect.d.ts +10 -0
  197. package/build/types-ts3.8/orchestrion/index.d.ts +53 -3
  198. package/build/types-ts3.8/redis/redis-statement-serializer.d.ts +6 -0
  199. package/build/types-ts3.8/vercel-ai/vercel-ai-dc-subscriber.d.ts +10 -4
  200. package/build/types-ts3.8/vercel-ai/vercel-ai-orchestrion-v6-subscriber.d.ts +12 -0
  201. package/package.json +9 -9
  202. package/build/cjs/orchestrion/config.js +0 -44
  203. package/build/cjs/orchestrion/config.js.map +0 -1
  204. package/build/esm/orchestrion/config.js +0 -40
  205. package/build/esm/orchestrion/config.js.map +0 -1
  206. package/build/types/orchestrion/config.d.ts.map +0 -1
@@ -1,20 +1,24 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
+ const index$1 = require('./mongoose/index.js');
3
4
  const redisDcSubscriber = require('./redis/redis-dc-subscriber.js');
5
+ const redisStatementSerializer = require('./redis/redis-statement-serializer.js');
4
6
  const tracingChannel = require('./tracing-channel.js');
5
- const index$1 = require('./vercel-ai/index.js');
7
+ const index$2 = require('./vercel-ai/index.js');
6
8
  const index = require('./integrations/tracing-channel/fastify/index.js');
7
9
 
8
10
 
9
11
 
12
+ exports.mongooseIntegration = index$1.mongooseIntegration;
10
13
  exports.IOREDIS_DC_CHANNEL_COMMAND = redisDcSubscriber.IOREDIS_DC_CHANNEL_COMMAND;
11
14
  exports.IOREDIS_DC_CHANNEL_CONNECT = redisDcSubscriber.IOREDIS_DC_CHANNEL_CONNECT;
12
15
  exports.REDIS_DC_CHANNEL_BATCH = redisDcSubscriber.REDIS_DC_CHANNEL_BATCH;
13
16
  exports.REDIS_DC_CHANNEL_COMMAND = redisDcSubscriber.REDIS_DC_CHANNEL_COMMAND;
14
17
  exports.REDIS_DC_CHANNEL_CONNECT = redisDcSubscriber.REDIS_DC_CHANNEL_CONNECT;
15
18
  exports.subscribeRedisDiagnosticChannels = redisDcSubscriber.subscribeRedisDiagnosticChannels;
19
+ exports.defaultDbStatementSerializer = redisStatementSerializer.defaultDbStatementSerializer;
16
20
  exports.bindTracingChannelToSpan = tracingChannel.bindTracingChannelToSpan;
17
- exports.vercelAiIntegration = index$1.vercelAiIntegration;
21
+ exports.vercelAiIntegration = index$2.vercelAiIntegration;
18
22
  exports.fastifyIntegration = index.fastifyIntegration;
19
23
  exports.handleFastifyError = index.handleFastifyError;
20
24
  exports.instrumentFastify = index.instrumentFastify;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,101 @@
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 = "Anthropic_AI";
10
+ const ORIGIN = "auto.ai.orchestrion.anthropic";
11
+ const INSTRUMENTED_CHANNELS = [
12
+ { channel: channels.CHANNELS.ANTHROPIC_CHAT, operation: "chat", methodPath: "messages.create", stream: "async-iterable" },
13
+ { channel: channels.CHANNELS.ANTHROPIC_MODELS, operation: "models", methodPath: "models.retrieve", stream: "none" },
14
+ {
15
+ channel: channels.CHANNELS.ANTHROPIC_MESSAGES_STREAM,
16
+ operation: "chat",
17
+ methodPath: "messages.stream",
18
+ stream: "message-stream"
19
+ }
20
+ ];
21
+ let subscribed = false;
22
+ const _anthropicChannelIntegration = ((options = {}) => {
23
+ return {
24
+ name: INTEGRATION_NAME,
25
+ setupOnce() {
26
+ if (!diagnosticsChannel.tracingChannel || subscribed) {
27
+ return;
28
+ }
29
+ subscribed = true;
30
+ core.waitForTracingChannelBinding(() => {
31
+ for (const { channel, operation, methodPath, stream } of INSTRUMENTED_CHANNELS) {
32
+ debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion:anthropic] subscribing to channel "${channel}"`);
33
+ tracingChannel.bindTracingChannelToSpan(
34
+ diagnosticsChannel.tracingChannel(channel),
35
+ (data) => createGenAiSpan(data, operation, methodPath, options),
36
+ {
37
+ beforeSpanEnd: (span, data) => {
38
+ core.addAnthropicResponseAttributes(
39
+ span,
40
+ data.result,
41
+ core.resolveAIRecordingOptions(options).recordOutputs
42
+ );
43
+ },
44
+ deferSpanEnd: ({ span, data }) => wrapStreamResult(span, data, stream, options)
45
+ }
46
+ );
47
+ }
48
+ });
49
+ }
50
+ };
51
+ });
52
+ function createGenAiSpan(data, operation, methodPath, options) {
53
+ const args = data.arguments ?? [];
54
+ if (core._INTERNAL_shouldSkipAiProviderWrapping(INTEGRATION_NAME)) {
55
+ return void 0;
56
+ }
57
+ const requestOptions = args[1];
58
+ if (requestOptions?.headers?.["X-Stainless-Helper-Method"] === "stream") {
59
+ return void 0;
60
+ }
61
+ const params = typeof args[0] === "object" && args[0] !== null ? args[0] : void 0;
62
+ const { recordInputs } = core.resolveAIRecordingOptions(options);
63
+ const enableTruncation = core.shouldEnableTruncation(options.enableTruncation);
64
+ const attributes = core.extractAnthropicRequestAttributes(args, methodPath, operation);
65
+ const model = attributes[core.GEN_AI_REQUEST_MODEL_ATTRIBUTE] || "unknown";
66
+ attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = ORIGIN;
67
+ const span = core.startInactiveSpan({
68
+ name: `${operation} ${model}`,
69
+ op: `gen_ai.${operation}`,
70
+ attributes
71
+ });
72
+ if (recordInputs && params) {
73
+ core.addAnthropicRequestAttributes(span, params, enableTruncation);
74
+ }
75
+ return span;
76
+ }
77
+ function isAsyncIterable(value) {
78
+ return !!value && typeof value[Symbol.asyncIterator] === "function";
79
+ }
80
+ function isMessageStream(value) {
81
+ return !!value && typeof value.on === "function";
82
+ }
83
+ function wrapStreamResult(span, data, stream, options) {
84
+ const { recordOutputs } = core.resolveAIRecordingOptions(options);
85
+ const result = data.result;
86
+ if (stream === "async-iterable" && isAsyncIterable(result)) {
87
+ const iterate = result[Symbol.asyncIterator].bind(result);
88
+ const instrumented = core.instrumentAsyncIterableStream({ [Symbol.asyncIterator]: iterate }, span, recordOutputs);
89
+ result[Symbol.asyncIterator] = () => instrumented;
90
+ return true;
91
+ }
92
+ if (stream === "message-stream" && isMessageStream(result)) {
93
+ core.instrumentMessageStream(result, span, recordOutputs);
94
+ return true;
95
+ }
96
+ return false;
97
+ }
98
+ const anthropicChannelIntegration = core.defineIntegration(_anthropicChannelIntegration);
99
+
100
+ exports.anthropicChannelIntegration = anthropicChannelIntegration;
101
+ //# sourceMappingURL=anthropic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic.js","sources":["../../../../src/integrations/tracing-channel/anthropic.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { AnthropicAiOptions, AnthropicAiResponse, IntegrationFn, Span, SpanAttributeValue } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n addAnthropicRequestAttributes,\n addAnthropicResponseAttributes,\n debug,\n defineIntegration,\n extractAnthropicRequestAttributes,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n instrumentAsyncIterableStream,\n instrumentMessageStream,\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 'Anthropic_AI'\n// integration is dropped from the default set (see the Node opt-in loader).\nconst INTEGRATION_NAME = 'Anthropic_AI' as const;\n\n// Distinct from the proxy's `auto.ai.anthropic` so spans from the orchestrion path\n// are attributable separately from the OTel/proxy one.\nconst ORIGIN = 'auto.ai.orchestrion.anthropic';\n\n// `stream` determines how the span is ended\nconst INSTRUMENTED_CHANNELS = [\n { channel: CHANNELS.ANTHROPIC_CHAT, operation: 'chat', methodPath: 'messages.create', stream: 'async-iterable' },\n { channel: CHANNELS.ANTHROPIC_MODELS, operation: 'models', methodPath: 'models.retrieve', stream: 'none' },\n {\n channel: CHANNELS.ANTHROPIC_MESSAGES_STREAM,\n operation: 'chat',\n methodPath: 'messages.stream',\n stream: 'message-stream',\n },\n] as const;\n\ntype StreamMode = (typeof INSTRUMENTED_CHANNELS)[number]['stream'];\n\ninterface AnthropicChannelContext {\n arguments: unknown[];\n result?: unknown;\n}\n\nlet subscribed = false;\n\nconst _anthropicChannelIntegration = ((options: AnthropicAiOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // tracingChannel is unavailable before Node 18.19 and prevent 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, methodPath, stream } of INSTRUMENTED_CHANNELS) {\n DEBUG_BUILD && debug.log(`[orchestrion:anthropic] subscribing to channel \"${channel}\"`);\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<AnthropicChannelContext>(channel),\n data => createGenAiSpan(data, operation, methodPath, options),\n {\n beforeSpanEnd: (span, data) => {\n addAnthropicResponseAttributes(\n span,\n data.result as AnthropicAiResponse,\n resolveAIRecordingOptions(options).recordOutputs,\n );\n },\n deferSpanEnd: ({ span, data }) => wrapStreamResult(span, data, stream, options),\n },\n );\n }\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Build the span for an instrumented call.\n * Returning `undefined` opts the payload out so no span is opened.\n */\nfunction createGenAiSpan(\n data: AnthropicChannelContext,\n operation: string,\n methodPath: string,\n options: AnthropicAiOptions,\n): Span | undefined {\n const args = data.arguments ?? [];\n\n // When LangChain (or another provider) is driving the SDK, it records the spans itself and marks this\n // provider as skipped — mirror the OTel integration and don't double-instrument.\n if (_INTERNAL_shouldSkipAiProviderWrapping(INTEGRATION_NAME)) {\n return undefined;\n }\n\n // `messages.stream()` internally calls the instrumented `messages.create({ stream: true })` tagged with\n // an `X-Stainless-Helper-Method: 'stream'` header. The messages-stream channel already covers it, so skip\n // the nested create to avoid a duplicate span.\n const requestOptions = args[1] as { headers?: Record<string, unknown> } | undefined;\n if (requestOptions?.headers?.['X-Stainless-Helper-Method'] === 'stream') {\n return undefined;\n }\n\n const params = typeof args[0] === 'object' && args[0] !== null ? (args[0] as Record<string, unknown>) : undefined;\n\n const { recordInputs } = resolveAIRecordingOptions(options);\n const enableTruncation = shouldEnableTruncation(options.enableTruncation);\n\n const attributes = extractAnthropicRequestAttributes(args, methodPath, operation);\n const model = (attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] as string) || 'unknown';\n attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = ORIGIN;\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 addAnthropicRequestAttributes(span, params, enableTruncation);\n }\n\n return span;\n}\n\ntype AsyncIterableStream = { [Symbol.asyncIterator]: () => AsyncIterator<unknown> };\ntype MessageStreamEmitter = { on: (...args: unknown[]) => void };\n\nfunction isAsyncIterable(value: unknown): value is AsyncIterableStream {\n return !!value && typeof (value as AsyncIterableStream)[Symbol.asyncIterator] === 'function';\n}\n\nfunction isMessageStream(value: unknown): value is MessageStreamEmitter {\n return !!value && typeof (value as MessageStreamEmitter).on === 'function';\n}\n\n/**\n * Hand span-ending ownership to a streamed result: returns `true` to skip the normal `beforeSpanEnd`,\n * `false` for non-streaming results (which end via `beforeSpanEnd`).\n *\n * - `async-iterable`: patch the `Stream`'s async iterator in place so `instrumentAsyncIterableStream` ends\n * the span when iteration finishes.\n * - `message-stream`: `instrumentMessageStream` attaches `'message'`/`'error'` listeners that end the span.\n */\nfunction wrapStreamResult(\n span: Span,\n data: AnthropicChannelContext,\n stream: StreamMode,\n options: AnthropicAiOptions,\n): boolean {\n const { recordOutputs } = resolveAIRecordingOptions(options);\n const result = data.result;\n\n if (stream === 'async-iterable' && isAsyncIterable(result)) {\n const iterate = result[Symbol.asyncIterator].bind(result);\n const instrumented = instrumentAsyncIterableStream({ [Symbol.asyncIterator]: iterate }, span, recordOutputs);\n result[Symbol.asyncIterator] = () => instrumented;\n return true;\n }\n\n if (stream === 'message-stream' && isMessageStream(result)) {\n instrumentMessageStream(result, span, recordOutputs);\n return true;\n }\n\n return false;\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven Anthropic integration. Subscribes to the `orchestrion:@anthropic-ai/sdk:*`\n * diagnostics_channels injected into the SDK's chat (`messages`/`completions`/beta `messages`), `models`, and\n * `messages.stream()` methods, so it requires the orchestrion runtime hook or bundler plugin.\n */\nexport const anthropicChannelIntegration = defineIntegration(_anthropicChannelIntegration);\n"],"names":["CHANNELS","waitForTracingChannelBinding","DEBUG_BUILD","debug","bindTracingChannelToSpan","addAnthropicResponseAttributes","resolveAIRecordingOptions","_INTERNAL_shouldSkipAiProviderWrapping","shouldEnableTruncation","extractAnthropicRequestAttributes","GEN_AI_REQUEST_MODEL_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","startInactiveSpan","addAnthropicRequestAttributes","instrumentAsyncIterableStream","instrumentMessageStream","defineIntegration"],"mappings":";;;;;;;;AAwBA,MAAM,gBAAA,GAAmB,cAAA;AAIzB,MAAM,MAAA,GAAS,+BAAA;AAGf,MAAM,qBAAA,GAAwB;AAAA,EAC5B,EAAE,SAASA,iBAAA,CAAS,cAAA,EAAgB,WAAW,MAAA,EAAQ,UAAA,EAAY,iBAAA,EAAmB,MAAA,EAAQ,gBAAA,EAAiB;AAAA,EAC/G,EAAE,SAASA,iBAAA,CAAS,gBAAA,EAAkB,WAAW,QAAA,EAAU,UAAA,EAAY,iBAAA,EAAmB,MAAA,EAAQ,MAAA,EAAO;AAAA,EACzG;AAAA,IACE,SAASA,iBAAA,CAAS,yBAAA;AAAA,IAClB,SAAA,EAAW,MAAA;AAAA,IACX,UAAA,EAAY,iBAAA;AAAA,IACZ,MAAA,EAAQ;AAAA;AAEZ,CAAA;AASA,IAAI,UAAA,GAAa,KAAA;AAEjB,MAAM,4BAAA,IAAgC,CAAC,OAAA,GAA8B,EAAC,KAAM;AAC1E,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAAC,kBAAA,CAAmB,cAAA,IAAkB,UAAA,EAAY;AACpD,QAAA;AAAA,MACF;AACA,MAAA,UAAA,GAAa,IAAA;AAIb,MAAAC,iCAAA,CAA6B,MAAM;AACjC,QAAA,KAAA,MAAW,EAAE,OAAA,EAAS,SAAA,EAAW,UAAA,EAAY,MAAA,MAAY,qBAAA,EAAuB;A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Aa,CAAA,CAAE,KAAK,MAAM,CAAA;AACxD,IAAA,MAAM,YAAA,GAAeQ,kCAAA,CAA8B,EAAE,CAAC,MAAA,CAAO,aAAa,GAAG,OAAA,EAAQ,EAAG,IAAA,EAAM,aAAa,CAAA;AAC3G,IAAA,MAAA,CAAO,MAAA,CAAO,aAAa,CAAA,GAAI,MAAM,YAAA;AACrC,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,MAAA,KAAW,gBAAA,IAAoB,eAAA,CAAgB,MAAM,CAAA,EAAG;AAC1D,IAAAC,4BAAA,CAAwB,MAAA,EAAQ,MAAM,aAAa,CAAA;AACnD,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,KAAA;AACT;AAOO,MAAM,2BAAA,GAA8BC,uBAAkB,4BAA4B;;;;"}
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const LIFECYCLE_EXT_POINTS = [
4
+ "onPreAuth",
5
+ "onCredentials",
6
+ "onPostAuth",
7
+ "onPreHandler",
8
+ "onPostHandler",
9
+ "onPreResponse",
10
+ "onRequest"
11
+ ];
12
+ const handlerPatched = /* @__PURE__ */ Symbol("hapi-handler-patched");
13
+ const HapiLayerType = {
14
+ ROUTER: "router",
15
+ PLUGIN: "plugin",
16
+ EXT: "server.ext"
17
+ };
18
+ const HapiLifecycleMethodNames = new Set(LIFECYCLE_EXT_POINTS);
19
+ var AttributeNames = /* @__PURE__ */ ((AttributeNames2) => {
20
+ AttributeNames2["HAPI_TYPE"] = "hapi.type";
21
+ AttributeNames2["PLUGIN_NAME"] = "hapi.plugin.name";
22
+ AttributeNames2["EXT_TYPE"] = "server.ext.type";
23
+ return AttributeNames2;
24
+ })(AttributeNames || {});
25
+
26
+ exports.AttributeNames = AttributeNames;
27
+ exports.HapiLayerType = HapiLayerType;
28
+ exports.HapiLifecycleMethodNames = HapiLifecycleMethodNames;
29
+ exports.handlerPatched = handlerPatched;
30
+ //# sourceMappingURL=hapi-types.js.map
@@ -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,KAAK,CAAA;AACxD,CAAA;AAEA,MAAM,gBAAA,GAAmB,CAAC,eAAA,KAAsE;AAC9F,EAAA,OACE,KAAA,CAAM,OAAA,CAAQ,eAAe,CAAA,IAC7B,gBAAgB,MAAA,IAAU,CAAA,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AA,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,EAAM,OAAA,EAAS,MAAM,IAAA,EAAM,IA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AAA;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;;;;"}
@@ -33,6 +33,7 @@ const _mysqlChannelIntegration = (() => {
33
33
  data._sentryCallerScope = core.getCurrentScope();
34
34
  return core.startInactiveSpan({
35
35
  name: sql ?? "mysql.query",
36
+ kind: core.SPAN_KIND.CLIENT,
36
37
  op: "db",
37
38
  attributes: {
38
39
  [ATTR_DB_SYSTEM]: "mysql",