braintrust 3.25.0 → 3.27.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 (79) hide show
  1. package/NOTICE +6 -0
  2. package/dev/dist/index.d.mts +130 -2
  3. package/dev/dist/index.d.ts +130 -2
  4. package/dev/dist/index.js +4133 -1421
  5. package/dev/dist/index.mjs +3242 -530
  6. package/dist/apply-auto-instrumentation.js +526 -426
  7. package/dist/apply-auto-instrumentation.mjs +329 -229
  8. package/dist/auto-instrumentations/bundler/esbuild.cjs +1198 -364
  9. package/dist/auto-instrumentations/bundler/esbuild.d.mts +4 -4
  10. package/dist/auto-instrumentations/bundler/esbuild.d.ts +4 -4
  11. package/dist/auto-instrumentations/bundler/esbuild.mjs +6 -8
  12. package/dist/auto-instrumentations/bundler/next.cjs +1227 -413
  13. package/dist/auto-instrumentations/bundler/next.mjs +7 -29
  14. package/dist/auto-instrumentations/bundler/rollup.cjs +1198 -364
  15. package/dist/auto-instrumentations/bundler/rollup.d.mts +4 -4
  16. package/dist/auto-instrumentations/bundler/rollup.d.ts +4 -4
  17. package/dist/auto-instrumentations/bundler/rollup.mjs +6 -8
  18. package/dist/auto-instrumentations/bundler/vite.cjs +1249 -387
  19. package/dist/auto-instrumentations/bundler/vite.d.mts +4 -4
  20. package/dist/auto-instrumentations/bundler/vite.d.ts +4 -4
  21. package/dist/auto-instrumentations/bundler/vite.mjs +34 -8
  22. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1368 -324
  23. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
  24. package/dist/auto-instrumentations/bundler/webpack.cjs +1198 -364
  25. package/dist/auto-instrumentations/bundler/webpack.d.mts +4 -4
  26. package/dist/auto-instrumentations/bundler/webpack.d.ts +4 -4
  27. package/dist/auto-instrumentations/bundler/webpack.mjs +6 -4
  28. package/dist/auto-instrumentations/chunk-2AMDGD65.mjs +1396 -0
  29. package/dist/auto-instrumentations/{chunk-7P6563SW.mjs → chunk-BW33ULMW.mjs} +2 -6
  30. package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-I55G56ZL.mjs} +114 -221
  31. package/dist/auto-instrumentations/chunk-JPUFNW7X.mjs +649 -0
  32. package/dist/auto-instrumentations/{chunk-JPVCUKTY.mjs → chunk-XEYKUBLY.mjs} +191 -73
  33. package/dist/auto-instrumentations/{chunk-CZ24KNHT.mjs → chunk-ZNHTSSGI.mjs} +231 -69
  34. package/dist/auto-instrumentations/hook.mjs +406 -183
  35. package/dist/auto-instrumentations/index.cjs +853 -49
  36. package/dist/auto-instrumentations/index.d.mts +10 -2
  37. package/dist/auto-instrumentations/index.d.ts +10 -2
  38. package/dist/auto-instrumentations/index.mjs +10 -1
  39. package/dist/auto-instrumentations/loader/cjs-patch.cjs +566 -221
  40. package/dist/auto-instrumentations/loader/cjs-patch.d.mts +2 -2
  41. package/dist/auto-instrumentations/loader/cjs-patch.d.ts +2 -2
  42. package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -2
  43. package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
  44. package/dist/auto-instrumentations/plugin-B-aZh7EP.d.ts +30 -0
  45. package/dist/auto-instrumentations/plugin-Bnj4E_6B.d.mts +30 -0
  46. package/dist/auto-instrumentations/{types-RNPaKi9o.d.mts → types-C1fVeiCp.d.mts} +1 -1
  47. package/dist/auto-instrumentations/{types-RNPaKi9o.d.ts → types-C1fVeiCp.d.ts} +1 -1
  48. package/dist/browser.d.mts +871 -199
  49. package/dist/browser.d.ts +871 -199
  50. package/dist/browser.js +3737 -549
  51. package/dist/browser.mjs +3737 -549
  52. package/dist/{chunk-ABR2QWDP.mjs → chunk-CZM5JIQL.mjs} +788 -132
  53. package/dist/{chunk-P25IOOU4.js → chunk-MF7NU6BT.js} +795 -139
  54. package/dist/{chunk-GSIDVFE6.js → chunk-QRHGVBKU.js} +3580 -1463
  55. package/dist/{chunk-2SANLSWX.mjs → chunk-YKD22IMR.mjs} +2505 -388
  56. package/dist/cli.js +3244 -533
  57. package/dist/edge-light.d.mts +1 -1
  58. package/dist/edge-light.d.ts +1 -1
  59. package/dist/edge-light.js +3737 -552
  60. package/dist/edge-light.mjs +3737 -552
  61. package/dist/index.d.mts +871 -199
  62. package/dist/index.d.ts +871 -199
  63. package/dist/index.js +893 -446
  64. package/dist/index.mjs +463 -16
  65. package/dist/instrumentation/index.d.mts +138 -6
  66. package/dist/instrumentation/index.d.ts +138 -6
  67. package/dist/instrumentation/index.js +3362 -559
  68. package/dist/instrumentation/index.mjs +3362 -559
  69. package/dist/vitest-evals-reporter.js +45 -43
  70. package/dist/vitest-evals-reporter.mjs +5 -3
  71. package/dist/workerd.d.mts +1 -1
  72. package/dist/workerd.d.ts +1 -1
  73. package/dist/workerd.js +3737 -552
  74. package/dist/workerd.mjs +3737 -552
  75. package/licenses/node-diagnostics-channel/LICENSE +19 -0
  76. package/package.json +34 -35
  77. package/dist/auto-instrumentations/chunk-VT6DDNKM.mjs +0 -856
  78. package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
  79. package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
@@ -1,14 +1,10 @@
1
1
  import {
2
2
  unplugin
3
- } from "./chunk-JPVCUKTY.mjs";
3
+ } from "./chunk-XEYKUBLY.mjs";
4
4
 
5
5
  // src/auto-instrumentations/bundler/webpack.ts
6
6
  function braintrustWebpackPlugin(options = {}) {
7
- const { useDiagnosticChannelCompatShim = false, ...pluginOptions } = options;
8
- return unplugin.webpack({
9
- ...pluginOptions,
10
- browser: useDiagnosticChannelCompatShim
11
- });
7
+ return unplugin.webpack(options);
12
8
  }
13
9
  var webpackPlugin = unplugin.webpack;
14
10
 
@@ -1,3 +1,10 @@
1
+ import {
2
+ GLOBAL_INSTRUMENTATION_HOOKS_KEY,
3
+ GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION,
4
+ GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND,
5
+ GLOBAL_INSTRUMENTATION_HOOK_BRAND
6
+ } from "./chunk-JPUFNW7X.mjs";
7
+
1
8
  // src/auto-instrumentations/orchestrion-js/matcher.ts
2
9
  import semifies from "semifies";
3
10
 
@@ -10,52 +17,76 @@ import { SourceMapGenerator } from "source-map";
10
17
  // src/auto-instrumentations/orchestrion-js/transforms.ts
11
18
  import esquery from "esquery";
12
19
  import { parse } from "meriyah";
13
- var tracingChannelPredicate = (node) => node.declarations?.[0]?.id?.properties?.[0]?.value?.name === "tr_ch_apm_tracingChannel";
14
20
  var CHANNEL_REGEX = /[^\w]/g;
21
+ var SHARED_HOOK_LOOKUP = "tr_ch_bt$get_hook";
15
22
  function formatChannelVariable(channelName) {
16
- return `tr_ch_apm$${channelName.replace(CHANNEL_REGEX, "_")}`;
23
+ return `tr_ch_bt$${channelName.replace(CHANNEL_REGEX, "_")}`;
24
+ }
25
+ function formatChannelGetter(channelName) {
26
+ return `tr_ch_bt$get_${channelName.replace(CHANNEL_REGEX, "_")}`;
17
27
  }
18
28
  var transforms = {
19
- tracingChannelImport({ dcModule, moduleType }, node) {
20
- if (node.body.some(tracingChannelPredicate)) {
21
- return;
22
- }
23
- const options = { module: moduleType === "esm" };
24
- const index = node.body.findIndex(
25
- (child) => child.directive === "use strict"
26
- );
27
- const dc = moduleType === "esm" ? `import tr_ch_apm_dc from "${dcModule}"` : `const tr_ch_apm_dc = ${"require"}("${dcModule}")`;
28
- const tracingChannel = "const { tracingChannel: tr_ch_apm_tracingChannel } = tr_ch_apm_dc";
29
- const hasSubscribers = `const tr_ch_apm_hasSubscribers = ch => ch.start.hasSubscribers
30
- || ch.end.hasSubscribers
31
- || ch.asyncStart.hasSubscribers
32
- || ch.asyncEnd.hasSubscribers
33
- || ch.error.hasSubscribers`;
34
- node.body.splice(
35
- index + 1,
36
- 0,
37
- parse(dc, options).body[0],
38
- parse(tracingChannel, options).body[0],
39
- parse(hasSubscribers, options).body[0]
40
- );
41
- },
42
- tracingChannelDeclaration(state, node) {
29
+ tracingHookDeclaration(state, node) {
43
30
  const {
44
31
  channelName,
45
32
  module: { name }
46
33
  } = state;
47
34
  const channelVariable = formatChannelVariable(channelName);
35
+ const channelGetter = formatChannelGetter(channelName);
36
+ const hasSharedHookLookup = node.body.some(
37
+ (child) => child.declarations?.[0]?.id?.name === SHARED_HOOK_LOOKUP
38
+ );
48
39
  if (node.body.some(
49
- (child) => child.declarations?.[0]?.id?.name === channelVariable
40
+ (child) => child.declarations?.[0]?.id?.name === channelGetter
50
41
  )) {
51
42
  return;
52
43
  }
53
- transforms.tracingChannelImport(state, node, null, []);
54
- const index = node.body.findIndex(tracingChannelPredicate);
44
+ const sharedHookLookup = hasSharedHookLookup ? "" : `
45
+ const ${SHARED_HOOK_LOOKUP} = (__bt$hookName) => {
46
+ try {
47
+ const __bt$hooks = globalThis[${JSON.stringify(
48
+ GLOBAL_INSTRUMENTATION_HOOKS_KEY
49
+ )}];
50
+ if (
51
+ !(__bt$hooks instanceof Map) ||
52
+ __bt$hooks[Symbol.for(${JSON.stringify(
53
+ GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND
54
+ )})] !== ${GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION}
55
+ ) return undefined;
56
+ const __bt$hook = Map.prototype.get.call(
57
+ __bt$hooks,
58
+ __bt$hookName
59
+ );
60
+ if (
61
+ (__bt$hook === null ||
62
+ (typeof __bt$hook !== "object" &&
63
+ typeof __bt$hook !== "function")) ||
64
+ __bt$hook[Symbol.for(${JSON.stringify(
65
+ GLOBAL_INSTRUMENTATION_HOOK_BRAND
66
+ )})] !== ${GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION} ||
67
+ typeof __bt$hook.traceInvocation !== "function"
68
+ ) return undefined;
69
+ return __bt$hook;
70
+ } catch {
71
+ return undefined;
72
+ }
73
+ };
74
+ `;
55
75
  const code = `
56
- const ${channelVariable} = tr_ch_apm_tracingChannel("orchestrion:${name}:${channelName}")
76
+ ${sharedHookLookup}
77
+ let ${channelVariable};
78
+ const ${channelGetter} = () =>
79
+ ${channelVariable} ??= ${SHARED_HOOK_LOOKUP}(
80
+ ${JSON.stringify(`orchestrion:${name}:${channelName}`)}
81
+ );
57
82
  `;
58
- node.body.splice(index + 1, 0, parse(code).body[0]);
83
+ const sharedHookLookupIndex = node.body.findIndex(
84
+ (child) => child.declarations?.[0]?.id?.name === SHARED_HOOK_LOOKUP
85
+ );
86
+ const index = sharedHookLookupIndex === -1 ? node.body.findIndex(
87
+ (child) => child.directive === "use strict"
88
+ ) : sharedHookLookupIndex;
89
+ node.body.splice(index + 1, 0, ...parse(code).body);
59
90
  },
60
91
  traceCallback: traceAny,
61
92
  tracePromise: traceAny,
@@ -70,25 +101,21 @@ function traceAny(state, node, _parent, ancestry) {
70
101
  }
71
102
  }
72
103
  function traceFunction(state, node, program) {
73
- transforms.tracingChannelDeclaration(state, program, null, []);
104
+ transforms.tracingHookDeclaration(state, program, null, []);
74
105
  const { functionQuery } = state;
75
106
  const methodName = "methodName" in functionQuery ? functionQuery.methodName : void 0;
76
107
  const privateMethodName = "privateMethodName" in functionQuery ? functionQuery.privateMethodName : void 0;
77
108
  const functionName = "functionName" in functionQuery ? functionQuery.functionName : void 0;
78
109
  const isConstructor = methodName === "constructor" || !methodName && !privateMethodName && !functionName;
79
110
  const type = isConstructor ? "ArrowFunctionExpression" : "FunctionExpression";
80
- node.body = wrap(
81
- state,
82
- {
83
- type,
84
- params: node.params,
85
- body: node.body,
86
- async: node.async,
87
- expression: false,
88
- generator: node.generator
89
- },
90
- program
91
- );
111
+ node.body = wrap(state, {
112
+ type,
113
+ params: node.params,
114
+ body: node.body,
115
+ async: node.async,
116
+ expression: false,
117
+ generator: node.generator
118
+ });
92
119
  node.generator = false;
93
120
  node.async = false;
94
121
  wrapSuper(node);
@@ -100,11 +127,11 @@ function traceInstanceMethod(state, node, program) {
100
127
  return;
101
128
  }
102
129
  const classBody = node.body;
103
- if (classBody.body.some(({ key }) => key.name === methodName)) {
130
+ if (classBody.body.some(({ key }) => key?.name === methodName)) {
104
131
  return;
105
132
  }
106
133
  let ctor = classBody.body.find(({ kind }) => kind === "constructor");
107
- transforms.tracingChannelDeclaration(state, program, null, []);
134
+ transforms.tracingHookDeclaration(state, program, null, []);
108
135
  if (!ctor) {
109
136
  ctor = parse(
110
137
  node.superClass ? "class A extends Object { constructor (...args) { super(...args) } }" : "class A { constructor () {} }"
@@ -112,47 +139,36 @@ function traceInstanceMethod(state, node, program) {
112
139
  classBody.body.unshift(ctor);
113
140
  }
114
141
  const ctorBody = parse(`
115
- const __apm$${methodName} = this["${methodName}"]
142
+ const __bt$${methodName} = this["${methodName}"]
116
143
  this["${methodName}"] = function () {}
117
144
  `).body;
118
145
  const fn = ctorBody[1].expression.right;
119
146
  fn.async = operator === "tracePromise";
120
- fn.body = wrap(
121
- state,
122
- { type: "Identifier", name: `__apm$${methodName}` },
123
- program
124
- );
147
+ fn.body = wrap(state, {
148
+ type: "Identifier",
149
+ name: `__bt$${methodName}`
150
+ });
125
151
  wrapSuper(fn);
126
152
  ctor.value.body.body.push(...ctorBody);
127
153
  }
128
- function wrap(state, node, program) {
129
- const { operator, moduleVersion } = state;
130
- const wrapper = operator === "traceCallback" ? wrapCallback(state) : operator === "tracePromise" ? wrapPromise(state) : wrapSync(state);
154
+ function wrap(state, node) {
155
+ const wrapper = wrapInvocation(state);
131
156
  const block = wrapper.body[0].body;
132
157
  const common = parse(
133
158
  node.type === "ArrowFunctionExpression" ? `
134
- const __apm$ctx = {
135
- arguments,
136
- moduleVersion: ${JSON.stringify(moduleVersion)}
137
- };
138
- const __apm$traced = () => {
139
- const __apm$wrapped = () => {};
140
- return __apm$wrapped(...arguments);
159
+ const __bt$target = (...__bt$args) => {
160
+ const __bt$wrapped = () => {};
161
+ return __bt$wrapped(...__bt$args);
141
162
  };
142
163
  ` : `
143
- const __apm$ctx = {
144
- arguments,
145
- self: this,
146
- moduleVersion: ${JSON.stringify(moduleVersion)}
147
- };
148
- const __apm$traced = () => {
149
- const __apm$wrapped = () => {};
150
- return __apm$wrapped.apply(this, arguments);
164
+ const __bt$target = function (...__bt$args) {
165
+ const __bt$wrapped = () => {};
166
+ return __bt$wrapped.apply(this, __bt$args);
151
167
  };
152
168
  `
153
169
  ).body;
154
170
  block.body.unshift(...common);
155
- esquery.query(block, "[id.name=__apm$wrapped]")[0].init = node;
171
+ esquery.query(block, "[id.name=__bt$wrapped]")[0].init = node;
156
172
  return block;
157
173
  }
158
174
  function wrapSuper(node) {
@@ -164,11 +180,11 @@ function wrapSuper(node) {
164
180
  const { name } = node2.property;
165
181
  let child;
166
182
  if (parent.callee) {
167
- const { expression } = parse(`__apm$super['${name}'].call(this)`).body[0];
183
+ const { expression } = parse(`__bt$super['${name}'].call(this)`).body[0];
168
184
  parent.callee = child = expression.callee;
169
185
  parent.arguments.unshift(...expression.arguments);
170
186
  } else {
171
- parent.expression = child = parse(`__apm$super['${name}']`).body[0];
187
+ parent.expression = child = parse(`__bt$super['${name}']`).body[0];
172
188
  }
173
189
  child.computed = parent.callee.computed;
174
190
  child.optional = parent.callee.optional;
@@ -179,151 +195,32 @@ function wrapSuper(node) {
179
195
  const member = parse(`
180
196
  class Wrapper {
181
197
  wrapper () {
182
- __apm$super['${name}'] = super['${name}']
198
+ __bt$super['${name}'] = super['${name}']
183
199
  }
184
200
  }
185
201
  `).body[0].body.body[0].value.body.body[0];
186
202
  node.body.body.unshift(member);
187
203
  }
188
204
  if (members.size > 0) {
189
- node.body.body.unshift(parse("const __apm$super = {}").body[0]);
205
+ node.body.body.unshift(parse("const __bt$super = {}").body[0]);
190
206
  }
191
207
  }
192
- function wrapCallback(state) {
193
- const {
194
- channelName,
195
- functionQuery: { callbackIndex = -1 }
196
- } = state;
197
- const channelVariable = formatChannelVariable(channelName);
198
- return parse(`
199
- function wrapper () {
200
- const __apm$cb = Array.prototype.at.call(arguments, ${callbackIndex});
201
-
202
- if (!${channelVariable}.start.hasSubscribers) return __apm$traced();
203
-
204
- function __apm$wrappedCb(err, res) {
205
- if (err) {
206
- __apm$ctx.error = err;
207
- ${channelVariable}.error.publish(__apm$ctx);
208
- } else {
209
- __apm$ctx.result = res;
210
- }
211
-
212
- ${channelVariable}.asyncStart.runStores(__apm$ctx, () => {
213
- try {
214
- if (__apm$cb) {
215
- return __apm$cb.apply(this, arguments);
216
- }
217
- } finally {
218
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
219
- }
220
- });
221
- }
222
-
223
- if (typeof __apm$cb !== 'function') {
224
- return __apm$traced();
225
- }
226
- Array.prototype.splice.call(arguments, ${callbackIndex}, 1, __apm$wrappedCb);
227
-
228
- return ${channelVariable}.start.runStores(__apm$ctx, () => {
229
- try {
230
- return __apm$traced();
231
- } catch (err) {
232
- __apm$ctx.error = err;
233
- ${channelVariable}.error.publish(__apm$ctx);
234
- throw err;
235
- } finally {
236
- __apm$ctx.self ??= this;
237
- ${channelVariable}.end.publish(__apm$ctx);
238
- }
239
- });
240
- }
241
- `);
242
- }
243
- function wrapPromise(state) {
244
- const { channelName } = state;
245
- const channelVariable = formatChannelVariable(channelName);
208
+ function wrapInvocation(state) {
209
+ const { channelName, moduleVersion, operator, functionQuery } = state;
210
+ const channelGetter = formatChannelGetter(channelName);
211
+ const callbackIndex = functionQuery.callbackIndex ?? -1;
246
212
  return parse(`
247
213
  function wrapper () {
248
- if (!tr_ch_apm_hasSubscribers(${channelVariable})) return __apm$traced();
249
-
250
- return ${channelVariable}.start.runStores(__apm$ctx, () => {
251
- try {
252
- let promise = __apm$traced();
253
- if (typeof promise?.then !== 'function') {
254
- __apm$ctx.result = promise;
255
- return promise;
256
- }
257
- // Mirror Node.js core diagnostics_channel behaviour: for native Promise
258
- // instances, chain normally (safe since there is no subclass API to
259
- // preserve). For Promise subclasses and other thenables, side-chain the
260
- // callbacks for event publishing and return the original so that any
261
- // subclass-specific methods (e.g. APIPromise.withResponse()) remain
262
- // accessible to the caller.
263
- if (promise instanceof Promise && promise.constructor === Promise) {
264
- return promise.then(
265
- result => {
266
- __apm$ctx.result = result;
267
- ${channelVariable}.asyncStart.publish(__apm$ctx);
268
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
269
- return result;
270
- },
271
- err => {
272
- __apm$ctx.error = err;
273
- ${channelVariable}.error.publish(__apm$ctx);
274
- ${channelVariable}.asyncStart.publish(__apm$ctx);
275
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
276
- throw err;
277
- }
278
- );
279
- }
280
- promise.then(
281
- result => {
282
- __apm$ctx.result = result;
283
- ${channelVariable}.asyncStart.publish(__apm$ctx);
284
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
285
- },
286
- err => {
287
- __apm$ctx.error = err;
288
- ${channelVariable}.error.publish(__apm$ctx);
289
- ${channelVariable}.asyncStart.publish(__apm$ctx);
290
- ${channelVariable}.asyncEnd.publish(__apm$ctx);
291
- }
292
- );
293
- return promise;
294
- } catch (err) {
295
- __apm$ctx.error = err;
296
- ${channelVariable}.error.publish(__apm$ctx);
297
- throw err;
298
- } finally {
299
- __apm$ctx.self ??= this;
300
- ${channelVariable}.end.publish(__apm$ctx);
301
- }
302
- });
303
- }
304
- `);
305
- }
306
- function wrapSync(state) {
307
- const { channelName } = state;
308
- const channelVariable = formatChannelVariable(channelName);
309
- return parse(`
310
- function wrapper () {
311
- if (!tr_ch_apm_hasSubscribers(${channelVariable})) return __apm$traced();
312
-
313
- return ${channelVariable}.start.runStores(__apm$ctx, () => {
314
- try {
315
- const result = __apm$traced();
316
- __apm$ctx.result = result;
317
- return result;
318
- } catch (err) {
319
- __apm$ctx.error = err;
320
- ${channelVariable}.error.publish(__apm$ctx);
321
- throw err;
322
- } finally {
323
- __apm$ctx.self ??= this;
324
- ${channelVariable}.end.publish(__apm$ctx);
325
- }
326
- });
214
+ const __bt$hook = ${channelGetter}();
215
+ if (!__bt$hook) return __bt$target.apply(this, arguments);
216
+ return __bt$hook.traceInvocation(
217
+ ${JSON.stringify(operator)},
218
+ __bt$target,
219
+ this,
220
+ arguments,
221
+ { moduleVersion: ${JSON.stringify(moduleVersion)} },
222
+ ${callbackIndex}
223
+ );
327
224
  }
328
225
  `);
329
226
  }
@@ -334,16 +231,14 @@ var Transformer = class {
334
231
  version;
335
232
  filePath;
336
233
  configs = [];
337
- dcModule;
338
- constructor(moduleName, version, filePath, configs, dcModule) {
234
+ constructor(moduleName, version, filePath, configs) {
339
235
  this.moduleName = moduleName;
340
236
  this.version = version;
341
237
  this.filePath = filePath;
342
238
  this.configs = configs;
343
- this.dcModule = dcModule;
344
239
  }
345
240
  /**
346
- * Instruments `code` by injecting diagnostics_channel tracing around the
241
+ * Instruments `code` by injecting global tracing hooks around the
347
242
  * target functions defined by this transformer's configs.
348
243
  */
349
244
  transform(code, moduleType) {
@@ -381,8 +276,6 @@ var Transformer = class {
381
276
  const query = astQuery || this.fromFunctionQuery(resolvedFunctionQuery);
382
277
  const state = {
383
278
  ...config,
384
- dcModule: this.dcModule,
385
- moduleType,
386
279
  moduleVersion: this.version,
387
280
  functionQuery: resolvedFunctionQuery,
388
281
  operator: this.getOperator(resolvedFunctionQuery.kind)
@@ -532,11 +425,9 @@ var Transformer = class {
532
425
  // src/auto-instrumentations/orchestrion-js/matcher.ts
533
426
  var InstrumentationMatcher = class {
534
427
  configs = [];
535
- dcModule;
536
428
  transformers = {};
537
- constructor(configs, dcModule) {
429
+ constructor(configs) {
538
430
  this.configs = configs;
539
- this.dcModule = dcModule || "diagnostics_channel";
540
431
  }
541
432
  /**
542
433
  * Returns a Transformer for the given module/file/version, or undefined if no
@@ -558,8 +449,7 @@ var InstrumentationMatcher = class {
558
449
  moduleName,
559
450
  version,
560
451
  filePath,
561
- configs,
562
- this.dcModule
452
+ configs
563
453
  );
564
454
  return this.transformers[id];
565
455
  }
@@ -569,8 +459,8 @@ var InstrumentationMatcher = class {
569
459
  };
570
460
 
571
461
  // src/auto-instrumentations/orchestrion-js/index.ts
572
- function create(configs, dcModule) {
573
- return new InstrumentationMatcher(configs, dcModule);
462
+ function create(configs) {
463
+ return new InstrumentationMatcher(configs);
574
464
  }
575
465
 
576
466
  // src/auto-instrumentations/loader/mastra-observability-patch.ts
@@ -768,6 +658,9 @@ function applySpecialCasePatch(input) {
768
658
  if (input.packageName === "openai" && input.modulePath.includes("api-promise")) {
769
659
  return input.source + OPENAI_API_PROMISE_PATCH;
770
660
  }
661
+ if (input.browser) {
662
+ return null;
663
+ }
771
664
  const mastraTarget = classifyMastraTarget(
772
665
  input.packageName,
773
666
  input.modulePath