braintrust 3.24.0 → 3.26.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 (80) hide show
  1. package/NOTICE +6 -0
  2. package/dev/dist/index.d.mts +135 -2
  3. package/dev/dist/index.d.ts +135 -2
  4. package/dev/dist/index.js +4426 -2040
  5. package/dev/dist/index.mjs +3594 -1208
  6. package/dist/apply-auto-instrumentation.js +445 -403
  7. package/dist/apply-auto-instrumentation.mjs +249 -207
  8. package/dist/auto-instrumentations/bundler/esbuild.cjs +1449 -799
  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 +5 -8
  12. package/dist/auto-instrumentations/bundler/next.cjs +1448 -818
  13. package/dist/auto-instrumentations/bundler/next.mjs +6 -29
  14. package/dist/auto-instrumentations/bundler/rollup.cjs +1449 -799
  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 +5 -8
  18. package/dist/auto-instrumentations/bundler/vite.cjs +1449 -799
  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 +5 -8
  22. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1602 -728
  23. package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
  24. package/dist/auto-instrumentations/bundler/webpack.cjs +1449 -799
  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 +5 -4
  28. package/dist/auto-instrumentations/{chunk-GSZHTAQW.mjs → chunk-6E22MYSW.mjs} +194 -93
  29. package/dist/auto-instrumentations/{chunk-VT6DDNKM.mjs → chunk-AKKPLXTP.mjs} +631 -194
  30. package/dist/auto-instrumentations/chunk-NRE4QUQR.mjs +509 -0
  31. package/dist/auto-instrumentations/{chunk-BURMPO7L.mjs → chunk-V5LEODRX.mjs} +2 -6
  32. package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
  33. package/dist/auto-instrumentations/{chunk-F43DNLPD.mjs → chunk-XZHHE4Y3.mjs} +646 -510
  34. package/dist/auto-instrumentations/hook.mjs +894 -657
  35. package/dist/auto-instrumentations/index.cjs +1125 -490
  36. package/dist/auto-instrumentations/index.d.mts +6 -2
  37. package/dist/auto-instrumentations/index.d.ts +6 -2
  38. package/dist/auto-instrumentations/index.mjs +6 -1
  39. package/dist/auto-instrumentations/loader/cjs-patch.cjs +492 -195
  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 +824 -197
  49. package/dist/browser.d.ts +824 -197
  50. package/dist/browser.js +3897 -1228
  51. package/dist/browser.mjs +3897 -1228
  52. package/dist/chunk-PN7EWK66.mjs +1784 -0
  53. package/dist/{chunk-SU6EHKJV.js → chunk-VRZZQPAA.js} +3289 -1577
  54. package/dist/chunk-VYNNEKSA.js +1784 -0
  55. package/dist/{chunk-XE5FS7QY.mjs → chunk-XIZOM2HO.mjs} +2470 -758
  56. package/dist/cli.js +3596 -1211
  57. package/dist/edge-light.d.mts +1 -1
  58. package/dist/edge-light.d.ts +1 -1
  59. package/dist/edge-light.js +3897 -1231
  60. package/dist/edge-light.mjs +3897 -1231
  61. package/dist/index.d.mts +824 -197
  62. package/dist/index.d.ts +824 -197
  63. package/dist/index.js +750 -445
  64. package/dist/index.mjs +334 -29
  65. package/dist/instrumentation/index.d.mts +135 -6
  66. package/dist/instrumentation/index.d.ts +135 -6
  67. package/dist/instrumentation/index.js +3696 -1257
  68. package/dist/instrumentation/index.mjs +3696 -1257
  69. package/dist/vitest-evals-reporter.js +16 -16
  70. package/dist/vitest-evals-reporter.mjs +2 -2
  71. package/dist/workerd.d.mts +1 -1
  72. package/dist/workerd.d.ts +1 -1
  73. package/dist/workerd.js +3897 -1231
  74. package/dist/workerd.mjs +3897 -1231
  75. package/licenses/node-diagnostics-channel/LICENSE +19 -0
  76. package/package.json +34 -35
  77. package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
  78. package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
  79. package/dist/chunk-7AUY2XWX.js +0 -1090
  80. package/dist/chunk-7F6GCRHH.mjs +0 -1090
@@ -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-NRE4QUQR.mjs";
7
+
1
8
  // src/auto-instrumentations/orchestrion-js/matcher.ts
2
9
  import semifies from "semifies";
3
10
 
@@ -10,52 +17,79 @@ 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
- module: { name }
32
+ module: { name },
33
+ operator
46
34
  } = state;
47
35
  const channelVariable = formatChannelVariable(channelName);
36
+ const channelGetter = formatChannelGetter(channelName);
37
+ const hasSharedHookLookup = node.body.some(
38
+ (child) => child.declarations?.[0]?.id?.name === SHARED_HOOK_LOOKUP
39
+ );
48
40
  if (node.body.some(
49
- (child) => child.declarations?.[0]?.id?.name === channelVariable
41
+ (child) => child.declarations?.[0]?.id?.name === channelGetter
50
42
  )) {
51
43
  return;
52
44
  }
53
- transforms.tracingChannelImport(state, node, null, []);
54
- const index = node.body.findIndex(tracingChannelPredicate);
45
+ const sharedHookLookup = hasSharedHookLookup ? "" : `
46
+ const ${SHARED_HOOK_LOOKUP} = (__bt$hookName, __bt$operator) => {
47
+ try {
48
+ const __bt$hooks = globalThis[${JSON.stringify(
49
+ GLOBAL_INSTRUMENTATION_HOOKS_KEY
50
+ )}];
51
+ if (
52
+ !(__bt$hooks instanceof Map) ||
53
+ __bt$hooks[Symbol.for(${JSON.stringify(
54
+ GLOBAL_INSTRUMENTATION_HOOKS_REGISTRY_BRAND
55
+ )})] !== ${GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION}
56
+ ) return undefined;
57
+ const __bt$hook = Map.prototype.get.call(
58
+ __bt$hooks,
59
+ __bt$hookName
60
+ );
61
+ if (
62
+ (__bt$hook === null ||
63
+ (typeof __bt$hook !== "object" &&
64
+ typeof __bt$hook !== "function")) ||
65
+ __bt$hook[Symbol.for(${JSON.stringify(
66
+ GLOBAL_INSTRUMENTATION_HOOK_BRAND
67
+ )})] !== ${GLOBAL_INSTRUMENTATION_HOOKS_PROTOCOL_VERSION} ||
68
+ typeof __bt$hook.hasSubscribers !== "boolean" ||
69
+ typeof __bt$hook[__bt$operator] !== "function"
70
+ ) return undefined;
71
+ return __bt$hook;
72
+ } catch {
73
+ return undefined;
74
+ }
75
+ };
76
+ `;
55
77
  const code = `
56
- const ${channelVariable} = tr_ch_apm_tracingChannel("orchestrion:${name}:${channelName}")
78
+ ${sharedHookLookup}
79
+ let ${channelVariable};
80
+ const ${channelGetter} = () =>
81
+ ${channelVariable} ??= ${SHARED_HOOK_LOOKUP}(
82
+ ${JSON.stringify(`orchestrion:${name}:${channelName}`)},
83
+ ${JSON.stringify(operator)}
84
+ );
57
85
  `;
58
- node.body.splice(index + 1, 0, parse(code).body[0]);
86
+ const sharedHookLookupIndex = node.body.findIndex(
87
+ (child) => child.declarations?.[0]?.id?.name === SHARED_HOOK_LOOKUP
88
+ );
89
+ const index = sharedHookLookupIndex === -1 ? node.body.findIndex(
90
+ (child) => child.directive === "use strict"
91
+ ) : sharedHookLookupIndex;
92
+ node.body.splice(index + 1, 0, ...parse(code).body);
59
93
  },
60
94
  traceCallback: traceAny,
61
95
  tracePromise: traceAny,
@@ -70,25 +104,21 @@ function traceAny(state, node, _parent, ancestry) {
70
104
  }
71
105
  }
72
106
  function traceFunction(state, node, program) {
73
- transforms.tracingChannelDeclaration(state, program, null, []);
107
+ transforms.tracingHookDeclaration(state, program, null, []);
74
108
  const { functionQuery } = state;
75
109
  const methodName = "methodName" in functionQuery ? functionQuery.methodName : void 0;
76
110
  const privateMethodName = "privateMethodName" in functionQuery ? functionQuery.privateMethodName : void 0;
77
111
  const functionName = "functionName" in functionQuery ? functionQuery.functionName : void 0;
78
112
  const isConstructor = methodName === "constructor" || !methodName && !privateMethodName && !functionName;
79
113
  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
- );
114
+ node.body = wrap(state, {
115
+ type,
116
+ params: node.params,
117
+ body: node.body,
118
+ async: node.async,
119
+ expression: false,
120
+ generator: node.generator
121
+ });
92
122
  node.generator = false;
93
123
  node.async = false;
94
124
  wrapSuper(node);
@@ -100,11 +130,11 @@ function traceInstanceMethod(state, node, program) {
100
130
  return;
101
131
  }
102
132
  const classBody = node.body;
103
- if (classBody.body.some(({ key }) => key.name === methodName)) {
133
+ if (classBody.body.some(({ key }) => key?.name === methodName)) {
104
134
  return;
105
135
  }
106
136
  let ctor = classBody.body.find(({ kind }) => kind === "constructor");
107
- transforms.tracingChannelDeclaration(state, program, null, []);
137
+ transforms.tracingHookDeclaration(state, program, null, []);
108
138
  if (!ctor) {
109
139
  ctor = parse(
110
140
  node.superClass ? "class A extends Object { constructor (...args) { super(...args) } }" : "class A { constructor () {} }"
@@ -112,47 +142,46 @@ function traceInstanceMethod(state, node, program) {
112
142
  classBody.body.unshift(ctor);
113
143
  }
114
144
  const ctorBody = parse(`
115
- const __apm$${methodName} = this["${methodName}"]
145
+ const __bt$${methodName} = this["${methodName}"]
116
146
  this["${methodName}"] = function () {}
117
147
  `).body;
118
148
  const fn = ctorBody[1].expression.right;
119
149
  fn.async = operator === "tracePromise";
120
- fn.body = wrap(
121
- state,
122
- { type: "Identifier", name: `__apm$${methodName}` },
123
- program
124
- );
150
+ fn.body = wrap(state, {
151
+ type: "Identifier",
152
+ name: `__bt$${methodName}`
153
+ });
125
154
  wrapSuper(fn);
126
155
  ctor.value.body.body.push(...ctorBody);
127
156
  }
128
- function wrap(state, node, program) {
157
+ function wrap(state, node) {
129
158
  const { operator, moduleVersion } = state;
130
159
  const wrapper = operator === "traceCallback" ? wrapCallback(state) : operator === "tracePromise" ? wrapPromise(state) : wrapSync(state);
131
160
  const block = wrapper.body[0].body;
132
161
  const common = parse(
133
162
  node.type === "ArrowFunctionExpression" ? `
134
- const __apm$ctx = {
163
+ const __bt$ctx = {
135
164
  arguments,
136
165
  moduleVersion: ${JSON.stringify(moduleVersion)}
137
166
  };
138
- const __apm$traced = () => {
139
- const __apm$wrapped = () => {};
140
- return __apm$wrapped(...arguments);
167
+ const __bt$traced = () => {
168
+ const __bt$wrapped = () => {};
169
+ return __bt$wrapped(...arguments);
141
170
  };
142
171
  ` : `
143
- const __apm$ctx = {
172
+ const __bt$ctx = {
144
173
  arguments,
145
174
  self: this,
146
175
  moduleVersion: ${JSON.stringify(moduleVersion)}
147
176
  };
148
- const __apm$traced = () => {
149
- const __apm$wrapped = () => {};
150
- return __apm$wrapped.apply(this, arguments);
177
+ const __bt$traced = () => {
178
+ const __bt$wrapped = () => {};
179
+ return __bt$wrapped.apply(this, arguments);
151
180
  };
152
181
  `
153
182
  ).body;
154
183
  block.body.unshift(...common);
155
- esquery.query(block, "[id.name=__apm$wrapped]")[0].init = node;
184
+ esquery.query(block, "[id.name=__bt$wrapped]")[0].init = node;
156
185
  return block;
157
186
  }
158
187
  function wrapSuper(node) {
@@ -164,11 +193,11 @@ function wrapSuper(node) {
164
193
  const { name } = node2.property;
165
194
  let child;
166
195
  if (parent.callee) {
167
- const { expression } = parse(`__apm$super['${name}'].call(this)`).body[0];
196
+ const { expression } = parse(`__bt$super['${name}'].call(this)`).body[0];
168
197
  parent.callee = child = expression.callee;
169
198
  parent.arguments.unshift(...expression.arguments);
170
199
  } else {
171
- parent.expression = child = parse(`__apm$super['${name}']`).body[0];
200
+ parent.expression = child = parse(`__bt$super['${name}']`).body[0];
172
201
  }
173
202
  child.computed = parent.callee.computed;
174
203
  child.optional = parent.callee.optional;
@@ -179,14 +208,14 @@ function wrapSuper(node) {
179
208
  const member = parse(`
180
209
  class Wrapper {
181
210
  wrapper () {
182
- __apm$super['${name}'] = super['${name}']
211
+ __bt$super['${name}'] = super['${name}']
183
212
  }
184
213
  }
185
214
  `).body[0].body.body[0].value.body.body[0];
186
215
  node.body.body.unshift(member);
187
216
  }
188
217
  if (members.size > 0) {
189
- node.body.body.unshift(parse("const __apm$super = {}").body[0]);
218
+ node.body.body.unshift(parse("const __bt$super = {}").body[0]);
190
219
  }
191
220
  }
192
221
  function wrapCallback(state) {
@@ -194,136 +223,41 @@ function wrapCallback(state) {
194
223
  channelName,
195
224
  functionQuery: { callbackIndex = -1 }
196
225
  } = state;
197
- const channelVariable = formatChannelVariable(channelName);
226
+ const channelGetter = formatChannelGetter(channelName);
198
227
  return parse(`
199
228
  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
- });
229
+ const __bt$hook = ${channelGetter}();
230
+ if (!__bt$hook?.hasSubscribers) return __bt$traced();
231
+ __bt$ctx.self ??= this;
232
+ return __bt$hook.traceCallback(
233
+ __bt$traced,
234
+ ${callbackIndex},
235
+ __bt$ctx
236
+ );
240
237
  }
241
238
  `);
242
239
  }
243
240
  function wrapPromise(state) {
244
241
  const { channelName } = state;
245
- const channelVariable = formatChannelVariable(channelName);
242
+ const channelGetter = formatChannelGetter(channelName);
246
243
  return parse(`
247
244
  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
- });
245
+ const __bt$hook = ${channelGetter}();
246
+ if (!__bt$hook?.hasSubscribers) return __bt$traced();
247
+ __bt$ctx.self ??= this;
248
+ return __bt$hook.tracePromise(__bt$traced, __bt$ctx);
303
249
  }
304
250
  `);
305
251
  }
306
252
  function wrapSync(state) {
307
253
  const { channelName } = state;
308
- const channelVariable = formatChannelVariable(channelName);
254
+ const channelGetter = formatChannelGetter(channelName);
309
255
  return parse(`
310
256
  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
- });
257
+ const __bt$hook = ${channelGetter}();
258
+ if (!__bt$hook?.hasSubscribers) return __bt$traced();
259
+ __bt$ctx.self ??= this;
260
+ return __bt$hook.traceSync(__bt$traced, __bt$ctx);
327
261
  }
328
262
  `);
329
263
  }
@@ -334,16 +268,14 @@ var Transformer = class {
334
268
  version;
335
269
  filePath;
336
270
  configs = [];
337
- dcModule;
338
- constructor(moduleName, version, filePath, configs, dcModule) {
271
+ constructor(moduleName, version, filePath, configs) {
339
272
  this.moduleName = moduleName;
340
273
  this.version = version;
341
274
  this.filePath = filePath;
342
275
  this.configs = configs;
343
- this.dcModule = dcModule;
344
276
  }
345
277
  /**
346
- * Instruments `code` by injecting diagnostics_channel tracing around the
278
+ * Instruments `code` by injecting global tracing hooks around the
347
279
  * target functions defined by this transformer's configs.
348
280
  */
349
281
  transform(code, moduleType) {
@@ -381,8 +313,6 @@ var Transformer = class {
381
313
  const query = astQuery || this.fromFunctionQuery(resolvedFunctionQuery);
382
314
  const state = {
383
315
  ...config,
384
- dcModule: this.dcModule,
385
- moduleType,
386
316
  moduleVersion: this.version,
387
317
  functionQuery: resolvedFunctionQuery,
388
318
  operator: this.getOperator(resolvedFunctionQuery.kind)
@@ -532,11 +462,9 @@ var Transformer = class {
532
462
  // src/auto-instrumentations/orchestrion-js/matcher.ts
533
463
  var InstrumentationMatcher = class {
534
464
  configs = [];
535
- dcModule;
536
465
  transformers = {};
537
- constructor(configs, dcModule) {
466
+ constructor(configs) {
538
467
  this.configs = configs;
539
- this.dcModule = dcModule || "diagnostics_channel";
540
468
  }
541
469
  /**
542
470
  * Returns a Transformer for the given module/file/version, or undefined if no
@@ -558,8 +486,7 @@ var InstrumentationMatcher = class {
558
486
  moduleName,
559
487
  version,
560
488
  filePath,
561
- configs,
562
- this.dcModule
489
+ configs
563
490
  );
564
491
  return this.transformers[id];
565
492
  }
@@ -569,8 +496,8 @@ var InstrumentationMatcher = class {
569
496
  };
570
497
 
571
498
  // src/auto-instrumentations/orchestrion-js/index.ts
572
- function create(configs, dcModule) {
573
- return new InstrumentationMatcher(configs, dcModule);
499
+ function create(configs) {
500
+ return new InstrumentationMatcher(configs);
574
501
  }
575
502
 
576
503
  // src/auto-instrumentations/loader/mastra-observability-patch.ts
@@ -768,6 +695,9 @@ function applySpecialCasePatch(input) {
768
695
  if (input.packageName === "openai" && input.modulePath.includes("api-promise")) {
769
696
  return input.source + OPENAI_API_PROMISE_PATCH;
770
697
  }
698
+ if (input.browser) {
699
+ return null;
700
+ }
771
701
  const mastraTarget = classifyMastraTarget(
772
702
  input.packageName,
773
703
  input.modulePath