braintrust 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,3197 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20;var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24; var _class25; var _class26; var _class27; var _class28; var _class29; var _class30; var _class31;
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ var _chunkCDBUTZMHjs = require('./chunk-CDBUTZMH.js');
20
+
21
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js
22
+ function suppressTracing(context2) {
23
+ return context2.setValue(SUPPRESS_TRACING_KEY, true);
24
+ }
25
+ function isTracingSuppressed(context2) {
26
+ return context2.getValue(SUPPRESS_TRACING_KEY) === true;
27
+ }
28
+ var SUPPRESS_TRACING_KEY;
29
+ var init_suppress_tracing = _chunkCDBUTZMHjs.__esm.call(void 0, {
30
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js"() {
31
+ "use strict";
32
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
33
+ SUPPRESS_TRACING_KEY = _chunkCDBUTZMHjs.createContextKey.call(void 0, "OpenTelemetry SDK Context Key SUPPRESS_TRACING");
34
+ }
35
+ });
36
+
37
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/attributes.js
38
+ function sanitizeAttributes(attributes) {
39
+ const out = {};
40
+ if (typeof attributes !== "object" || attributes == null) {
41
+ return out;
42
+ }
43
+ for (const [key, val] of Object.entries(attributes)) {
44
+ if (!isAttributeKey(key)) {
45
+ _chunkCDBUTZMHjs.diag.warn(`Invalid attribute key: ${key}`);
46
+ continue;
47
+ }
48
+ if (!isAttributeValue(val)) {
49
+ _chunkCDBUTZMHjs.diag.warn(`Invalid attribute value set for key: ${key}`);
50
+ continue;
51
+ }
52
+ if (Array.isArray(val)) {
53
+ out[key] = val.slice();
54
+ } else {
55
+ out[key] = val;
56
+ }
57
+ }
58
+ return out;
59
+ }
60
+ function isAttributeKey(key) {
61
+ return typeof key === "string" && key.length > 0;
62
+ }
63
+ function isAttributeValue(val) {
64
+ if (val == null) {
65
+ return true;
66
+ }
67
+ if (Array.isArray(val)) {
68
+ return isHomogeneousAttributeValueArray(val);
69
+ }
70
+ return isValidPrimitiveAttributeValue(val);
71
+ }
72
+ function isHomogeneousAttributeValueArray(arr) {
73
+ let type;
74
+ for (const element of arr) {
75
+ if (element == null)
76
+ continue;
77
+ if (!type) {
78
+ if (isValidPrimitiveAttributeValue(element)) {
79
+ type = typeof element;
80
+ continue;
81
+ }
82
+ return false;
83
+ }
84
+ if (typeof element === type) {
85
+ continue;
86
+ }
87
+ return false;
88
+ }
89
+ return true;
90
+ }
91
+ function isValidPrimitiveAttributeValue(val) {
92
+ switch (typeof val) {
93
+ case "number":
94
+ case "boolean":
95
+ case "string":
96
+ return true;
97
+ }
98
+ return false;
99
+ }
100
+ var init_attributes = _chunkCDBUTZMHjs.__esm.call(void 0, {
101
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/attributes.js"() {
102
+ "use strict";
103
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
104
+ }
105
+ });
106
+
107
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js
108
+ function loggingErrorHandler() {
109
+ return (ex) => {
110
+ _chunkCDBUTZMHjs.diag.error(stringifyException(ex));
111
+ };
112
+ }
113
+ function stringifyException(ex) {
114
+ if (typeof ex === "string") {
115
+ return ex;
116
+ } else {
117
+ return JSON.stringify(flattenException(ex));
118
+ }
119
+ }
120
+ function flattenException(ex) {
121
+ const result = {};
122
+ let current = ex;
123
+ while (current !== null) {
124
+ Object.getOwnPropertyNames(current).forEach((propertyName) => {
125
+ if (result[propertyName])
126
+ return;
127
+ const value = current[propertyName];
128
+ if (value) {
129
+ result[propertyName] = String(value);
130
+ }
131
+ });
132
+ current = Object.getPrototypeOf(current);
133
+ }
134
+ return result;
135
+ }
136
+ var init_logging_error_handler = _chunkCDBUTZMHjs.__esm.call(void 0, {
137
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js"() {
138
+ "use strict";
139
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
140
+ }
141
+ });
142
+
143
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js
144
+ function globalErrorHandler(ex) {
145
+ try {
146
+ delegateHandler(ex);
147
+ } catch (e2) {
148
+ }
149
+ }
150
+ var delegateHandler;
151
+ var init_global_error_handler = _chunkCDBUTZMHjs.__esm.call(void 0, {
152
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js"() {
153
+ "use strict";
154
+ init_logging_error_handler();
155
+ delegateHandler = loggingErrorHandler();
156
+ }
157
+ });
158
+
159
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js
160
+ var _util = require('util');
161
+ function getNumberFromEnv(key) {
162
+ const raw = process.env[key];
163
+ if (raw == null || raw.trim() === "") {
164
+ return void 0;
165
+ }
166
+ const value = Number(raw);
167
+ if (isNaN(value)) {
168
+ _chunkCDBUTZMHjs.diag.warn(`Unknown value ${_util.inspect.call(void 0, raw)} for ${key}, expected a number, using defaults`);
169
+ return void 0;
170
+ }
171
+ return value;
172
+ }
173
+ function getStringFromEnv(key) {
174
+ const raw = process.env[key];
175
+ if (raw == null || raw.trim() === "") {
176
+ return void 0;
177
+ }
178
+ return raw;
179
+ }
180
+ var init_environment = _chunkCDBUTZMHjs.__esm.call(void 0, {
181
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js"() {
182
+ "use strict";
183
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
184
+ }
185
+ });
186
+
187
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js
188
+ var _perf_hooks = require('perf_hooks');
189
+ var otperformance;
190
+ var init_performance = _chunkCDBUTZMHjs.__esm.call(void 0, {
191
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js"() {
192
+ "use strict";
193
+ otperformance = _perf_hooks.performance;
194
+ }
195
+ });
196
+
197
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/version.js
198
+ var VERSION;
199
+ var init_version = _chunkCDBUTZMHjs.__esm.call(void 0, {
200
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/version.js"() {
201
+ "use strict";
202
+ VERSION = "2.0.1";
203
+ }
204
+ });
205
+
206
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js
207
+ var init_SemanticAttributes = _chunkCDBUTZMHjs.__esm.call(void 0, {
208
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js"() {
209
+ "use strict";
210
+ }
211
+ });
212
+
213
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js
214
+ var init_trace = _chunkCDBUTZMHjs.__esm.call(void 0, {
215
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js"() {
216
+ "use strict";
217
+ init_SemanticAttributes();
218
+ }
219
+ });
220
+
221
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
222
+ var init_SemanticResourceAttributes = _chunkCDBUTZMHjs.__esm.call(void 0, {
223
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js"() {
224
+ "use strict";
225
+ }
226
+ });
227
+
228
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js
229
+ var init_resource = _chunkCDBUTZMHjs.__esm.call(void 0, {
230
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js"() {
231
+ "use strict";
232
+ init_SemanticResourceAttributes();
233
+ }
234
+ });
235
+
236
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
237
+ var ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, ATTR_EXCEPTION_TYPE, ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_LANGUAGE, TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_VERSION;
238
+ var init_stable_attributes = _chunkCDBUTZMHjs.__esm.call(void 0, {
239
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js"() {
240
+ "use strict";
241
+ ATTR_EXCEPTION_MESSAGE = "exception.message";
242
+ ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
243
+ ATTR_EXCEPTION_TYPE = "exception.type";
244
+ ATTR_SERVICE_NAME = "service.name";
245
+ ATTR_TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language";
246
+ TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS = "nodejs";
247
+ ATTR_TELEMETRY_SDK_NAME = "telemetry.sdk.name";
248
+ ATTR_TELEMETRY_SDK_VERSION = "telemetry.sdk.version";
249
+ }
250
+ });
251
+
252
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js
253
+ var init_stable_metrics = _chunkCDBUTZMHjs.__esm.call(void 0, {
254
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js"() {
255
+ "use strict";
256
+ }
257
+ });
258
+
259
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js
260
+ var init_esm2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
261
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js"() {
262
+ "use strict";
263
+ init_trace();
264
+ init_resource();
265
+ init_stable_attributes();
266
+ init_stable_metrics();
267
+ }
268
+ });
269
+
270
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/semconv.js
271
+ var ATTR_PROCESS_RUNTIME_NAME;
272
+ var init_semconv = _chunkCDBUTZMHjs.__esm.call(void 0, {
273
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/semconv.js"() {
274
+ "use strict";
275
+ ATTR_PROCESS_RUNTIME_NAME = "process.runtime.name";
276
+ }
277
+ });
278
+
279
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
280
+ var SDK_INFO;
281
+ var init_sdk_info = _chunkCDBUTZMHjs.__esm.call(void 0, {
282
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js"() {
283
+ "use strict";
284
+ init_version();
285
+ init_esm2();
286
+ init_semconv();
287
+ SDK_INFO = {
288
+ [ATTR_TELEMETRY_SDK_NAME]: "opentelemetry",
289
+ [ATTR_PROCESS_RUNTIME_NAME]: "node",
290
+ [ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,
291
+ [ATTR_TELEMETRY_SDK_VERSION]: VERSION
292
+ };
293
+ }
294
+ });
295
+
296
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/timer-util.js
297
+ function unrefTimer(timer) {
298
+ timer.unref();
299
+ }
300
+ var init_timer_util = _chunkCDBUTZMHjs.__esm.call(void 0, {
301
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/timer-util.js"() {
302
+ "use strict";
303
+ }
304
+ });
305
+
306
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/index.js
307
+ var init_node = _chunkCDBUTZMHjs.__esm.call(void 0, {
308
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/index.js"() {
309
+ "use strict";
310
+ init_environment();
311
+ init_performance();
312
+ init_sdk_info();
313
+ init_timer_util();
314
+ }
315
+ });
316
+
317
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/index.js
318
+ var init_platform = _chunkCDBUTZMHjs.__esm.call(void 0, {
319
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/index.js"() {
320
+ "use strict";
321
+ init_node();
322
+ }
323
+ });
324
+
325
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/time.js
326
+ function millisToHrTime(epochMillis) {
327
+ const epochSeconds = epochMillis / 1e3;
328
+ const seconds = Math.trunc(epochSeconds);
329
+ const nanos = Math.round(epochMillis % 1e3 * MILLISECONDS_TO_NANOSECONDS);
330
+ return [seconds, nanos];
331
+ }
332
+ function getTimeOrigin() {
333
+ let timeOrigin = otperformance.timeOrigin;
334
+ if (typeof timeOrigin !== "number") {
335
+ const perf = otperformance;
336
+ timeOrigin = perf.timing && perf.timing.fetchStart;
337
+ }
338
+ return timeOrigin;
339
+ }
340
+ function hrTime(performanceNow) {
341
+ const timeOrigin = millisToHrTime(getTimeOrigin());
342
+ const now2 = millisToHrTime(typeof performanceNow === "number" ? performanceNow : otperformance.now());
343
+ return addHrTimes(timeOrigin, now2);
344
+ }
345
+ function hrTimeDuration(startTime, endTime) {
346
+ let seconds = endTime[0] - startTime[0];
347
+ let nanos = endTime[1] - startTime[1];
348
+ if (nanos < 0) {
349
+ seconds -= 1;
350
+ nanos += SECOND_TO_NANOSECONDS;
351
+ }
352
+ return [seconds, nanos];
353
+ }
354
+ function hrTimeToMicroseconds(time) {
355
+ return time[0] * 1e6 + time[1] / 1e3;
356
+ }
357
+ function isTimeInputHrTime(value) {
358
+ return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" && typeof value[1] === "number";
359
+ }
360
+ function isTimeInput(value) {
361
+ return isTimeInputHrTime(value) || typeof value === "number" || value instanceof Date;
362
+ }
363
+ function addHrTimes(time1, time2) {
364
+ const out = [time1[0] + time2[0], time1[1] + time2[1]];
365
+ if (out[1] >= SECOND_TO_NANOSECONDS) {
366
+ out[1] -= SECOND_TO_NANOSECONDS;
367
+ out[0] += 1;
368
+ }
369
+ return out;
370
+ }
371
+ var NANOSECOND_DIGITS, NANOSECOND_DIGITS_IN_MILLIS, MILLISECONDS_TO_NANOSECONDS, SECOND_TO_NANOSECONDS;
372
+ var init_time = _chunkCDBUTZMHjs.__esm.call(void 0, {
373
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/time.js"() {
374
+ "use strict";
375
+ init_platform();
376
+ NANOSECOND_DIGITS = 9;
377
+ NANOSECOND_DIGITS_IN_MILLIS = 6;
378
+ MILLISECONDS_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS);
379
+ SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
380
+ }
381
+ });
382
+
383
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/ExportResult.js
384
+ var ExportResultCode;
385
+ var init_ExportResult = _chunkCDBUTZMHjs.__esm.call(void 0, {
386
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/ExportResult.js"() {
387
+ "use strict";
388
+ (function(ExportResultCode3) {
389
+ ExportResultCode3[ExportResultCode3["SUCCESS"] = 0] = "SUCCESS";
390
+ ExportResultCode3[ExportResultCode3["FAILED"] = 1] = "FAILED";
391
+ })(ExportResultCode || (ExportResultCode = {}));
392
+ }
393
+ });
394
+
395
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js
396
+ function isPlainObject(value) {
397
+ if (!isObjectLike(value) || baseGetTag(value) !== objectTag) {
398
+ return false;
399
+ }
400
+ const proto = getPrototypeOf(value);
401
+ if (proto === null) {
402
+ return true;
403
+ }
404
+ const Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
405
+ return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) === objectCtorString;
406
+ }
407
+ function isObjectLike(value) {
408
+ return value != null && typeof value == "object";
409
+ }
410
+ function baseGetTag(value) {
411
+ if (value == null) {
412
+ return value === void 0 ? undefinedTag : nullTag;
413
+ }
414
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
415
+ }
416
+ function getRawTag(value) {
417
+ const isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
418
+ let unmasked = false;
419
+ try {
420
+ value[symToStringTag] = void 0;
421
+ unmasked = true;
422
+ } catch (e) {
423
+ }
424
+ const result = nativeObjectToString.call(value);
425
+ if (unmasked) {
426
+ if (isOwn) {
427
+ value[symToStringTag] = tag;
428
+ } else {
429
+ delete value[symToStringTag];
430
+ }
431
+ }
432
+ return result;
433
+ }
434
+ function objectToString(value) {
435
+ return nativeObjectToString.call(value);
436
+ }
437
+ var objectTag, nullTag, undefinedTag, funcProto, funcToString, objectCtorString, getPrototypeOf, objectProto, hasOwnProperty, symToStringTag, nativeObjectToString;
438
+ var init_lodash_merge = _chunkCDBUTZMHjs.__esm.call(void 0, {
439
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js"() {
440
+ "use strict";
441
+ objectTag = "[object Object]";
442
+ nullTag = "[object Null]";
443
+ undefinedTag = "[object Undefined]";
444
+ funcProto = Function.prototype;
445
+ funcToString = funcProto.toString;
446
+ objectCtorString = funcToString.call(Object);
447
+ getPrototypeOf = Object.getPrototypeOf;
448
+ objectProto = Object.prototype;
449
+ hasOwnProperty = objectProto.hasOwnProperty;
450
+ symToStringTag = Symbol ? Symbol.toStringTag : void 0;
451
+ nativeObjectToString = objectProto.toString;
452
+ }
453
+ });
454
+
455
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/merge.js
456
+ function merge(...args) {
457
+ let result = args.shift();
458
+ const objects = /* @__PURE__ */ new WeakMap();
459
+ while (args.length > 0) {
460
+ result = mergeTwoObjects(result, args.shift(), 0, objects);
461
+ }
462
+ return result;
463
+ }
464
+ function takeValue(value) {
465
+ if (isArray2(value)) {
466
+ return value.slice();
467
+ }
468
+ return value;
469
+ }
470
+ function mergeTwoObjects(one, two, level = 0, objects) {
471
+ let result;
472
+ if (level > MAX_LEVEL) {
473
+ return void 0;
474
+ }
475
+ level++;
476
+ if (isPrimitive(one) || isPrimitive(two) || isFunction(two)) {
477
+ result = takeValue(two);
478
+ } else if (isArray2(one)) {
479
+ result = one.slice();
480
+ if (isArray2(two)) {
481
+ for (let i = 0, j = two.length; i < j; i++) {
482
+ result.push(takeValue(two[i]));
483
+ }
484
+ } else if (isObject2(two)) {
485
+ const keys = Object.keys(two);
486
+ for (let i = 0, j = keys.length; i < j; i++) {
487
+ const key = keys[i];
488
+ result[key] = takeValue(two[key]);
489
+ }
490
+ }
491
+ } else if (isObject2(one)) {
492
+ if (isObject2(two)) {
493
+ if (!shouldMerge(one, two)) {
494
+ return two;
495
+ }
496
+ result = Object.assign({}, one);
497
+ const keys = Object.keys(two);
498
+ for (let i = 0, j = keys.length; i < j; i++) {
499
+ const key = keys[i];
500
+ const twoValue = two[key];
501
+ if (isPrimitive(twoValue)) {
502
+ if (typeof twoValue === "undefined") {
503
+ delete result[key];
504
+ } else {
505
+ result[key] = twoValue;
506
+ }
507
+ } else {
508
+ const obj1 = result[key];
509
+ const obj2 = twoValue;
510
+ if (wasObjectReferenced(one, key, objects) || wasObjectReferenced(two, key, objects)) {
511
+ delete result[key];
512
+ } else {
513
+ if (isObject2(obj1) && isObject2(obj2)) {
514
+ const arr1 = objects.get(obj1) || [];
515
+ const arr2 = objects.get(obj2) || [];
516
+ arr1.push({ obj: one, key });
517
+ arr2.push({ obj: two, key });
518
+ objects.set(obj1, arr1);
519
+ objects.set(obj2, arr2);
520
+ }
521
+ result[key] = mergeTwoObjects(result[key], twoValue, level, objects);
522
+ }
523
+ }
524
+ }
525
+ } else {
526
+ result = two;
527
+ }
528
+ }
529
+ return result;
530
+ }
531
+ function wasObjectReferenced(obj, key, objects) {
532
+ const arr = objects.get(obj[key]) || [];
533
+ for (let i = 0, j = arr.length; i < j; i++) {
534
+ const info = arr[i];
535
+ if (info.key === key && info.obj === obj) {
536
+ return true;
537
+ }
538
+ }
539
+ return false;
540
+ }
541
+ function isArray2(value) {
542
+ return Array.isArray(value);
543
+ }
544
+ function isFunction(value) {
545
+ return typeof value === "function";
546
+ }
547
+ function isObject2(value) {
548
+ return !isPrimitive(value) && !isArray2(value) && !isFunction(value) && typeof value === "object";
549
+ }
550
+ function isPrimitive(value) {
551
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "undefined" || value instanceof Date || value instanceof RegExp || value === null;
552
+ }
553
+ function shouldMerge(one, two) {
554
+ if (!isPlainObject(one) || !isPlainObject(two)) {
555
+ return false;
556
+ }
557
+ return true;
558
+ }
559
+ var MAX_LEVEL;
560
+ var init_merge = _chunkCDBUTZMHjs.__esm.call(void 0, {
561
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/merge.js"() {
562
+ "use strict";
563
+ init_lodash_merge();
564
+ MAX_LEVEL = 20;
565
+ }
566
+ });
567
+
568
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/promise.js
569
+ var Deferred;
570
+ var init_promise = _chunkCDBUTZMHjs.__esm.call(void 0, {
571
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/promise.js"() {
572
+ "use strict";
573
+ Deferred = class {
574
+
575
+
576
+
577
+ constructor() {
578
+ this._promise = new Promise((resolve, reject2) => {
579
+ this._resolve = resolve;
580
+ this._reject = reject2;
581
+ });
582
+ }
583
+ get promise() {
584
+ return this._promise;
585
+ }
586
+ resolve(val) {
587
+ this._resolve(val);
588
+ }
589
+ reject(err) {
590
+ this._reject(err);
591
+ }
592
+ };
593
+ }
594
+ });
595
+
596
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/callback.js
597
+ var BindOnceFuture;
598
+ var init_callback = _chunkCDBUTZMHjs.__esm.call(void 0, {
599
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/callback.js"() {
600
+ "use strict";
601
+ init_promise();
602
+ BindOnceFuture = (_class = class {
603
+
604
+
605
+ __init() {this._isCalled = false}
606
+ __init2() {this._deferred = new Deferred()}
607
+ constructor(_callback, _that) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
608
+ this._callback = _callback;
609
+ this._that = _that;
610
+ }
611
+ get isCalled() {
612
+ return this._isCalled;
613
+ }
614
+ get promise() {
615
+ return this._deferred.promise;
616
+ }
617
+ call(...args) {
618
+ if (!this._isCalled) {
619
+ this._isCalled = true;
620
+ try {
621
+ Promise.resolve(this._callback.call(this._that, ...args)).then((val) => this._deferred.resolve(val), (err) => this._deferred.reject(err));
622
+ } catch (err) {
623
+ this._deferred.reject(err);
624
+ }
625
+ }
626
+ return this._deferred.promise;
627
+ }
628
+ }, _class);
629
+ }
630
+ });
631
+
632
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/internal/exporter.js
633
+ function _export(exporter, arg) {
634
+ return new Promise((resolve) => {
635
+ _chunkCDBUTZMHjs.context.with(suppressTracing(_chunkCDBUTZMHjs.context.active()), () => {
636
+ exporter.export(arg, (result) => {
637
+ resolve(result);
638
+ });
639
+ });
640
+ });
641
+ }
642
+ var init_exporter = _chunkCDBUTZMHjs.__esm.call(void 0, {
643
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/internal/exporter.js"() {
644
+ "use strict";
645
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
646
+ init_suppress_tracing();
647
+ }
648
+ });
649
+
650
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js
651
+ var internal;
652
+ var init_esm3 = _chunkCDBUTZMHjs.__esm.call(void 0, {
653
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js"() {
654
+ "use strict";
655
+ init_attributes();
656
+ init_global_error_handler();
657
+ init_time();
658
+ init_ExportResult();
659
+ init_platform();
660
+ init_suppress_tracing();
661
+ init_merge();
662
+ init_callback();
663
+ init_exporter();
664
+ internal = {
665
+ _export
666
+ };
667
+ }
668
+ });
669
+
670
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/node/default-service-name.js
671
+ function defaultServiceName() {
672
+ return `unknown_service:${process.argv0}`;
673
+ }
674
+ var init_default_service_name = _chunkCDBUTZMHjs.__esm.call(void 0, {
675
+ "../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/node/default-service-name.js"() {
676
+ "use strict";
677
+ }
678
+ });
679
+
680
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/node/index.js
681
+ var init_node2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
682
+ "../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/node/index.js"() {
683
+ "use strict";
684
+ init_default_service_name();
685
+ }
686
+ });
687
+
688
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/index.js
689
+ var init_platform2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
690
+ "../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/index.js"() {
691
+ "use strict";
692
+ init_node2();
693
+ }
694
+ });
695
+
696
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/utils.js
697
+ var isPromiseLike;
698
+ var init_utils = _chunkCDBUTZMHjs.__esm.call(void 0, {
699
+ "../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/utils.js"() {
700
+ "use strict";
701
+ isPromiseLike = (val) => {
702
+ return val !== null && typeof val === "object" && typeof val.then === "function";
703
+ };
704
+ }
705
+ });
706
+
707
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js
708
+ function resourceFromAttributes(attributes) {
709
+ return ResourceImpl.FromAttributeList(Object.entries(attributes));
710
+ }
711
+ function defaultResource() {
712
+ return resourceFromAttributes({
713
+ [ATTR_SERVICE_NAME]: defaultServiceName(),
714
+ [ATTR_TELEMETRY_SDK_LANGUAGE]: SDK_INFO[ATTR_TELEMETRY_SDK_LANGUAGE],
715
+ [ATTR_TELEMETRY_SDK_NAME]: SDK_INFO[ATTR_TELEMETRY_SDK_NAME],
716
+ [ATTR_TELEMETRY_SDK_VERSION]: SDK_INFO[ATTR_TELEMETRY_SDK_VERSION]
717
+ });
718
+ }
719
+ function guardedRawAttributes(attributes) {
720
+ return attributes.map(([k, v]) => {
721
+ if (isPromiseLike(v)) {
722
+ return [
723
+ k,
724
+ v.catch((err) => {
725
+ _chunkCDBUTZMHjs.diag.debug("promise rejection for resource attribute: %s - %s", k, err);
726
+ return void 0;
727
+ })
728
+ ];
729
+ }
730
+ return [k, v];
731
+ });
732
+ }
733
+ var ResourceImpl;
734
+ var init_ResourceImpl = _chunkCDBUTZMHjs.__esm.call(void 0, {
735
+ "../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js"() {
736
+ "use strict";
737
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
738
+ init_esm3();
739
+ init_esm2();
740
+ init_platform2();
741
+ init_utils();
742
+ ResourceImpl = (_class2 = class _ResourceImpl {
743
+
744
+ __init3() {this._asyncAttributesPending = false}
745
+
746
+ static FromAttributeList(attributes) {
747
+ const res = new _ResourceImpl({});
748
+ res._rawAttributes = guardedRawAttributes(attributes);
749
+ res._asyncAttributesPending = attributes.filter(([_, val]) => isPromiseLike(val)).length > 0;
750
+ return res;
751
+ }
752
+ constructor(resource) {;_class2.prototype.__init3.call(this);
753
+ const attributes = _nullishCoalesce(resource.attributes, () => ( {}));
754
+ this._rawAttributes = Object.entries(attributes).map(([k, v]) => {
755
+ if (isPromiseLike(v)) {
756
+ this._asyncAttributesPending = true;
757
+ }
758
+ return [k, v];
759
+ });
760
+ this._rawAttributes = guardedRawAttributes(this._rawAttributes);
761
+ }
762
+ get asyncAttributesPending() {
763
+ return this._asyncAttributesPending;
764
+ }
765
+ async waitForAsyncAttributes() {
766
+ if (!this.asyncAttributesPending) {
767
+ return;
768
+ }
769
+ for (let i = 0; i < this._rawAttributes.length; i++) {
770
+ const [k, v] = this._rawAttributes[i];
771
+ this._rawAttributes[i] = [k, isPromiseLike(v) ? await v : v];
772
+ }
773
+ this._asyncAttributesPending = false;
774
+ }
775
+ get attributes() {
776
+ if (this.asyncAttributesPending) {
777
+ _chunkCDBUTZMHjs.diag.error("Accessing resource attributes before async attributes settled");
778
+ }
779
+ if (this._memoizedAttributes) {
780
+ return this._memoizedAttributes;
781
+ }
782
+ const attrs = {};
783
+ for (const [k, v] of this._rawAttributes) {
784
+ if (isPromiseLike(v)) {
785
+ _chunkCDBUTZMHjs.diag.debug(`Unsettled resource attribute ${k} skipped`);
786
+ continue;
787
+ }
788
+ if (v != null) {
789
+ attrs[k] ??= v;
790
+ }
791
+ }
792
+ if (!this._asyncAttributesPending) {
793
+ this._memoizedAttributes = attrs;
794
+ }
795
+ return attrs;
796
+ }
797
+ getRawAttributes() {
798
+ return this._rawAttributes;
799
+ }
800
+ merge(resource) {
801
+ if (resource == null)
802
+ return this;
803
+ return _ResourceImpl.FromAttributeList([
804
+ ...resource.getRawAttributes(),
805
+ ...this.getRawAttributes()
806
+ ]);
807
+ }
808
+ }, _class2);
809
+ }
810
+ });
811
+
812
+ // ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/index.js
813
+ var init_esm4 = _chunkCDBUTZMHjs.__esm.call(void 0, {
814
+ "../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/index.js"() {
815
+ "use strict";
816
+ init_ResourceImpl();
817
+ }
818
+ });
819
+
820
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js
821
+ var ExceptionEventName;
822
+ var init_enums = _chunkCDBUTZMHjs.__esm.call(void 0, {
823
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js"() {
824
+ "use strict";
825
+ ExceptionEventName = "exception";
826
+ }
827
+ });
828
+
829
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js
830
+ var SpanImpl2;
831
+ var init_Span = _chunkCDBUTZMHjs.__esm.call(void 0, {
832
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js"() {
833
+ "use strict";
834
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
835
+ init_esm3();
836
+ init_esm2();
837
+ init_enums();
838
+ SpanImpl2 = (_class3 = class {
839
+ // Below properties are included to implement ReadableSpan for export
840
+ // purposes but are not intended to be written-to directly.
841
+
842
+
843
+
844
+ __init4() {this.attributes = {}}
845
+ __init5() {this.links = []}
846
+ __init6() {this.events = []}
847
+
848
+
849
+
850
+ __init7() {this._droppedAttributesCount = 0}
851
+ __init8() {this._droppedEventsCount = 0}
852
+ __init9() {this._droppedLinksCount = 0}
853
+
854
+ __init10() {this.status = {
855
+ code: _chunkCDBUTZMHjs.SpanStatusCode.UNSET
856
+ }}
857
+ __init11() {this.endTime = [0, 0]}
858
+ __init12() {this._ended = false}
859
+ __init13() {this._duration = [-1, -1]}
860
+
861
+
862
+
863
+
864
+
865
+
866
+ /**
867
+ * Constructs a new SpanImpl instance.
868
+ */
869
+ constructor(opts) {;_class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);_class3.prototype.__init10.call(this);_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);
870
+ const now2 = Date.now();
871
+ this._spanContext = opts.spanContext;
872
+ this._performanceStartTime = otperformance.now();
873
+ this._performanceOffset = now2 - (this._performanceStartTime + getTimeOrigin());
874
+ this._startTimeProvided = opts.startTime != null;
875
+ this._spanLimits = opts.spanLimits;
876
+ this._attributeValueLengthLimit = this._spanLimits.attributeValueLengthLimit || 0;
877
+ this._spanProcessor = opts.spanProcessor;
878
+ this.name = opts.name;
879
+ this.parentSpanContext = opts.parentSpanContext;
880
+ this.kind = opts.kind;
881
+ this.links = opts.links || [];
882
+ this.startTime = this._getTime(_nullishCoalesce(opts.startTime, () => ( now2)));
883
+ this.resource = opts.resource;
884
+ this.instrumentationScope = opts.scope;
885
+ if (opts.attributes != null) {
886
+ this.setAttributes(opts.attributes);
887
+ }
888
+ this._spanProcessor.onStart(this, opts.context);
889
+ }
890
+ spanContext() {
891
+ return this._spanContext;
892
+ }
893
+ setAttribute(key, value) {
894
+ if (value == null || this._isSpanEnded())
895
+ return this;
896
+ if (key.length === 0) {
897
+ _chunkCDBUTZMHjs.diag.warn(`Invalid attribute key: ${key}`);
898
+ return this;
899
+ }
900
+ if (!isAttributeValue(value)) {
901
+ _chunkCDBUTZMHjs.diag.warn(`Invalid attribute value set for key: ${key}`);
902
+ return this;
903
+ }
904
+ const { attributeCountLimit } = this._spanLimits;
905
+ if (attributeCountLimit !== void 0 && Object.keys(this.attributes).length >= attributeCountLimit && !Object.prototype.hasOwnProperty.call(this.attributes, key)) {
906
+ this._droppedAttributesCount++;
907
+ return this;
908
+ }
909
+ this.attributes[key] = this._truncateToSize(value);
910
+ return this;
911
+ }
912
+ setAttributes(attributes) {
913
+ for (const [k, v] of Object.entries(attributes)) {
914
+ this.setAttribute(k, v);
915
+ }
916
+ return this;
917
+ }
918
+ /**
919
+ *
920
+ * @param name Span Name
921
+ * @param [attributesOrStartTime] Span attributes or start time
922
+ * if type is {@type TimeInput} and 3rd param is undefined
923
+ * @param [timeStamp] Specified time stamp for the event
924
+ */
925
+ addEvent(name, attributesOrStartTime, timeStamp) {
926
+ if (this._isSpanEnded())
927
+ return this;
928
+ const { eventCountLimit } = this._spanLimits;
929
+ if (eventCountLimit === 0) {
930
+ _chunkCDBUTZMHjs.diag.warn("No events allowed.");
931
+ this._droppedEventsCount++;
932
+ return this;
933
+ }
934
+ if (eventCountLimit !== void 0 && this.events.length >= eventCountLimit) {
935
+ if (this._droppedEventsCount === 0) {
936
+ _chunkCDBUTZMHjs.diag.debug("Dropping extra events.");
937
+ }
938
+ this.events.shift();
939
+ this._droppedEventsCount++;
940
+ }
941
+ if (isTimeInput(attributesOrStartTime)) {
942
+ if (!isTimeInput(timeStamp)) {
943
+ timeStamp = attributesOrStartTime;
944
+ }
945
+ attributesOrStartTime = void 0;
946
+ }
947
+ const attributes = sanitizeAttributes(attributesOrStartTime);
948
+ this.events.push({
949
+ name,
950
+ attributes,
951
+ time: this._getTime(timeStamp),
952
+ droppedAttributesCount: 0
953
+ });
954
+ return this;
955
+ }
956
+ addLink(link) {
957
+ this.links.push(link);
958
+ return this;
959
+ }
960
+ addLinks(links) {
961
+ this.links.push(...links);
962
+ return this;
963
+ }
964
+ setStatus(status) {
965
+ if (this._isSpanEnded())
966
+ return this;
967
+ this.status = { ...status };
968
+ if (this.status.message != null && typeof status.message !== "string") {
969
+ _chunkCDBUTZMHjs.diag.warn(`Dropping invalid status.message of type '${typeof status.message}', expected 'string'`);
970
+ delete this.status.message;
971
+ }
972
+ return this;
973
+ }
974
+ updateName(name) {
975
+ if (this._isSpanEnded())
976
+ return this;
977
+ this.name = name;
978
+ return this;
979
+ }
980
+ end(endTime) {
981
+ if (this._isSpanEnded()) {
982
+ _chunkCDBUTZMHjs.diag.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);
983
+ return;
984
+ }
985
+ this._ended = true;
986
+ this.endTime = this._getTime(endTime);
987
+ this._duration = hrTimeDuration(this.startTime, this.endTime);
988
+ if (this._duration[0] < 0) {
989
+ _chunkCDBUTZMHjs.diag.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.", this.startTime, this.endTime);
990
+ this.endTime = this.startTime.slice();
991
+ this._duration = [0, 0];
992
+ }
993
+ if (this._droppedEventsCount > 0) {
994
+ _chunkCDBUTZMHjs.diag.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`);
995
+ }
996
+ this._spanProcessor.onEnd(this);
997
+ }
998
+ _getTime(inp) {
999
+ if (typeof inp === "number" && inp <= otperformance.now()) {
1000
+ return hrTime(inp + this._performanceOffset);
1001
+ }
1002
+ if (typeof inp === "number") {
1003
+ return millisToHrTime(inp);
1004
+ }
1005
+ if (inp instanceof Date) {
1006
+ return millisToHrTime(inp.getTime());
1007
+ }
1008
+ if (isTimeInputHrTime(inp)) {
1009
+ return inp;
1010
+ }
1011
+ if (this._startTimeProvided) {
1012
+ return millisToHrTime(Date.now());
1013
+ }
1014
+ const msDuration = otperformance.now() - this._performanceStartTime;
1015
+ return addHrTimes(this.startTime, millisToHrTime(msDuration));
1016
+ }
1017
+ isRecording() {
1018
+ return this._ended === false;
1019
+ }
1020
+ recordException(exception, time) {
1021
+ const attributes = {};
1022
+ if (typeof exception === "string") {
1023
+ attributes[ATTR_EXCEPTION_MESSAGE] = exception;
1024
+ } else if (exception) {
1025
+ if (exception.code) {
1026
+ attributes[ATTR_EXCEPTION_TYPE] = exception.code.toString();
1027
+ } else if (exception.name) {
1028
+ attributes[ATTR_EXCEPTION_TYPE] = exception.name;
1029
+ }
1030
+ if (exception.message) {
1031
+ attributes[ATTR_EXCEPTION_MESSAGE] = exception.message;
1032
+ }
1033
+ if (exception.stack) {
1034
+ attributes[ATTR_EXCEPTION_STACKTRACE] = exception.stack;
1035
+ }
1036
+ }
1037
+ if (attributes[ATTR_EXCEPTION_TYPE] || attributes[ATTR_EXCEPTION_MESSAGE]) {
1038
+ this.addEvent(ExceptionEventName, attributes, time);
1039
+ } else {
1040
+ _chunkCDBUTZMHjs.diag.warn(`Failed to record an exception ${exception}`);
1041
+ }
1042
+ }
1043
+ get duration() {
1044
+ return this._duration;
1045
+ }
1046
+ get ended() {
1047
+ return this._ended;
1048
+ }
1049
+ get droppedAttributesCount() {
1050
+ return this._droppedAttributesCount;
1051
+ }
1052
+ get droppedEventsCount() {
1053
+ return this._droppedEventsCount;
1054
+ }
1055
+ get droppedLinksCount() {
1056
+ return this._droppedLinksCount;
1057
+ }
1058
+ _isSpanEnded() {
1059
+ if (this._ended) {
1060
+ const error2 = new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);
1061
+ _chunkCDBUTZMHjs.diag.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`, error2);
1062
+ }
1063
+ return this._ended;
1064
+ }
1065
+ // Utility function to truncate given value within size
1066
+ // for value type of string, will truncate to given limit
1067
+ // for type of non-string, will return same value
1068
+ _truncateToLimitUtil(value, limit) {
1069
+ if (value.length <= limit) {
1070
+ return value;
1071
+ }
1072
+ return value.substring(0, limit);
1073
+ }
1074
+ /**
1075
+ * If the given attribute value is of type string and has more characters than given {@code attributeValueLengthLimit} then
1076
+ * return string with truncated to {@code attributeValueLengthLimit} characters
1077
+ *
1078
+ * If the given attribute value is array of strings then
1079
+ * return new array of strings with each element truncated to {@code attributeValueLengthLimit} characters
1080
+ *
1081
+ * Otherwise return same Attribute {@code value}
1082
+ *
1083
+ * @param value Attribute value
1084
+ * @returns truncated attribute value if required, otherwise same value
1085
+ */
1086
+ _truncateToSize(value) {
1087
+ const limit = this._attributeValueLengthLimit;
1088
+ if (limit <= 0) {
1089
+ _chunkCDBUTZMHjs.diag.warn(`Attribute value limit must be positive, got ${limit}`);
1090
+ return value;
1091
+ }
1092
+ if (typeof value === "string") {
1093
+ return this._truncateToLimitUtil(value, limit);
1094
+ }
1095
+ if (Array.isArray(value)) {
1096
+ return value.map((val) => typeof val === "string" ? this._truncateToLimitUtil(val, limit) : val);
1097
+ }
1098
+ return value;
1099
+ }
1100
+ }, _class3);
1101
+ }
1102
+ });
1103
+
1104
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js
1105
+ var SamplingDecision2;
1106
+ var init_Sampler = _chunkCDBUTZMHjs.__esm.call(void 0, {
1107
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js"() {
1108
+ "use strict";
1109
+ (function(SamplingDecision3) {
1110
+ SamplingDecision3[SamplingDecision3["NOT_RECORD"] = 0] = "NOT_RECORD";
1111
+ SamplingDecision3[SamplingDecision3["RECORD"] = 1] = "RECORD";
1112
+ SamplingDecision3[SamplingDecision3["RECORD_AND_SAMPLED"] = 2] = "RECORD_AND_SAMPLED";
1113
+ })(SamplingDecision2 || (SamplingDecision2 = {}));
1114
+ }
1115
+ });
1116
+
1117
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js
1118
+ var AlwaysOffSampler;
1119
+ var init_AlwaysOffSampler = _chunkCDBUTZMHjs.__esm.call(void 0, {
1120
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js"() {
1121
+ "use strict";
1122
+ init_Sampler();
1123
+ AlwaysOffSampler = class {
1124
+ shouldSample() {
1125
+ return {
1126
+ decision: SamplingDecision2.NOT_RECORD
1127
+ };
1128
+ }
1129
+ toString() {
1130
+ return "AlwaysOffSampler";
1131
+ }
1132
+ };
1133
+ }
1134
+ });
1135
+
1136
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js
1137
+ var AlwaysOnSampler;
1138
+ var init_AlwaysOnSampler = _chunkCDBUTZMHjs.__esm.call(void 0, {
1139
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js"() {
1140
+ "use strict";
1141
+ init_Sampler();
1142
+ AlwaysOnSampler = class {
1143
+ shouldSample() {
1144
+ return {
1145
+ decision: SamplingDecision2.RECORD_AND_SAMPLED
1146
+ };
1147
+ }
1148
+ toString() {
1149
+ return "AlwaysOnSampler";
1150
+ }
1151
+ };
1152
+ }
1153
+ });
1154
+
1155
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js
1156
+ var ParentBasedSampler;
1157
+ var init_ParentBasedSampler = _chunkCDBUTZMHjs.__esm.call(void 0, {
1158
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js"() {
1159
+ "use strict";
1160
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
1161
+ init_esm3();
1162
+ init_AlwaysOffSampler();
1163
+ init_AlwaysOnSampler();
1164
+ ParentBasedSampler = class {
1165
+
1166
+
1167
+
1168
+
1169
+
1170
+ constructor(config) {
1171
+ this._root = config.root;
1172
+ if (!this._root) {
1173
+ globalErrorHandler(new Error("ParentBasedSampler must have a root sampler configured"));
1174
+ this._root = new AlwaysOnSampler();
1175
+ }
1176
+ this._remoteParentSampled = _nullishCoalesce(config.remoteParentSampled, () => ( new AlwaysOnSampler()));
1177
+ this._remoteParentNotSampled = _nullishCoalesce(config.remoteParentNotSampled, () => ( new AlwaysOffSampler()));
1178
+ this._localParentSampled = _nullishCoalesce(config.localParentSampled, () => ( new AlwaysOnSampler()));
1179
+ this._localParentNotSampled = _nullishCoalesce(config.localParentNotSampled, () => ( new AlwaysOffSampler()));
1180
+ }
1181
+ shouldSample(context2, traceId, spanName, spanKind, attributes, links) {
1182
+ const parentContext = _chunkCDBUTZMHjs.trace.getSpanContext(context2);
1183
+ if (!parentContext || !_chunkCDBUTZMHjs.isSpanContextValid.call(void 0, parentContext)) {
1184
+ return this._root.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
1185
+ }
1186
+ if (parentContext.isRemote) {
1187
+ if (parentContext.traceFlags & _chunkCDBUTZMHjs.TraceFlags.SAMPLED) {
1188
+ return this._remoteParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
1189
+ }
1190
+ return this._remoteParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
1191
+ }
1192
+ if (parentContext.traceFlags & _chunkCDBUTZMHjs.TraceFlags.SAMPLED) {
1193
+ return this._localParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
1194
+ }
1195
+ return this._localParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
1196
+ }
1197
+ toString() {
1198
+ return `ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`;
1199
+ }
1200
+ };
1201
+ }
1202
+ });
1203
+
1204
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js
1205
+ var TraceIdRatioBasedSampler;
1206
+ var init_TraceIdRatioBasedSampler = _chunkCDBUTZMHjs.__esm.call(void 0, {
1207
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js"() {
1208
+ "use strict";
1209
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
1210
+ init_Sampler();
1211
+ TraceIdRatioBasedSampler = class {
1212
+
1213
+
1214
+ constructor(_ratio = 0) {
1215
+ this._ratio = _ratio;
1216
+ this._ratio = this._normalize(_ratio);
1217
+ this._upperBound = Math.floor(this._ratio * 4294967295);
1218
+ }
1219
+ shouldSample(context2, traceId) {
1220
+ return {
1221
+ decision: _chunkCDBUTZMHjs.isValidTraceId.call(void 0, traceId) && this._accumulate(traceId) < this._upperBound ? SamplingDecision2.RECORD_AND_SAMPLED : SamplingDecision2.NOT_RECORD
1222
+ };
1223
+ }
1224
+ toString() {
1225
+ return `TraceIdRatioBased{${this._ratio}}`;
1226
+ }
1227
+ _normalize(ratio) {
1228
+ if (typeof ratio !== "number" || isNaN(ratio))
1229
+ return 0;
1230
+ return ratio >= 1 ? 1 : ratio <= 0 ? 0 : ratio;
1231
+ }
1232
+ _accumulate(traceId) {
1233
+ let accumulation = 0;
1234
+ for (let i = 0; i < traceId.length / 8; i++) {
1235
+ const pos = i * 8;
1236
+ const part = parseInt(traceId.slice(pos, pos + 8), 16);
1237
+ accumulation = (accumulation ^ part) >>> 0;
1238
+ }
1239
+ return accumulation;
1240
+ }
1241
+ };
1242
+ }
1243
+ });
1244
+
1245
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js
1246
+ function loadDefaultConfig() {
1247
+ return {
1248
+ sampler: buildSamplerFromEnv(),
1249
+ forceFlushTimeoutMillis: 3e4,
1250
+ generalLimits: {
1251
+ attributeValueLengthLimit: _nullishCoalesce(getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT"), () => ( Infinity)),
1252
+ attributeCountLimit: _nullishCoalesce(getNumberFromEnv("OTEL_ATTRIBUTE_COUNT_LIMIT"), () => ( 128))
1253
+ },
1254
+ spanLimits: {
1255
+ attributeValueLengthLimit: _nullishCoalesce(getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT"), () => ( Infinity)),
1256
+ attributeCountLimit: _nullishCoalesce(getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT"), () => ( 128)),
1257
+ linkCountLimit: _nullishCoalesce(getNumberFromEnv("OTEL_SPAN_LINK_COUNT_LIMIT"), () => ( 128)),
1258
+ eventCountLimit: _nullishCoalesce(getNumberFromEnv("OTEL_SPAN_EVENT_COUNT_LIMIT"), () => ( 128)),
1259
+ attributePerEventCountLimit: _nullishCoalesce(getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT"), () => ( 128)),
1260
+ attributePerLinkCountLimit: _nullishCoalesce(getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT"), () => ( 128))
1261
+ }
1262
+ };
1263
+ }
1264
+ function buildSamplerFromEnv() {
1265
+ const sampler = _nullishCoalesce(getStringFromEnv("OTEL_TRACES_SAMPLER"), () => ( "parentbased_always_on"));
1266
+ switch (sampler) {
1267
+ case "always_on":
1268
+ return new AlwaysOnSampler();
1269
+ case "always_off":
1270
+ return new AlwaysOffSampler();
1271
+ case "parentbased_always_on":
1272
+ return new ParentBasedSampler({
1273
+ root: new AlwaysOnSampler()
1274
+ });
1275
+ case "parentbased_always_off":
1276
+ return new ParentBasedSampler({
1277
+ root: new AlwaysOffSampler()
1278
+ });
1279
+ case "traceidratio":
1280
+ return new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv());
1281
+ case "parentbased_traceidratio":
1282
+ return new ParentBasedSampler({
1283
+ root: new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv())
1284
+ });
1285
+ default:
1286
+ _chunkCDBUTZMHjs.diag.error(`OTEL_TRACES_SAMPLER value "${sampler}" invalid, defaulting to "${"parentbased_always_on"}".`);
1287
+ return new ParentBasedSampler({
1288
+ root: new AlwaysOnSampler()
1289
+ });
1290
+ }
1291
+ }
1292
+ function getSamplerProbabilityFromEnv() {
1293
+ const probability = getNumberFromEnv("OTEL_TRACES_SAMPLER_ARG");
1294
+ if (probability == null) {
1295
+ _chunkCDBUTZMHjs.diag.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${DEFAULT_RATIO}.`);
1296
+ return DEFAULT_RATIO;
1297
+ }
1298
+ if (probability < 0 || probability > 1) {
1299
+ _chunkCDBUTZMHjs.diag.error(`OTEL_TRACES_SAMPLER_ARG=${probability} was given, but it is out of range ([0..1]), defaulting to ${DEFAULT_RATIO}.`);
1300
+ return DEFAULT_RATIO;
1301
+ }
1302
+ return probability;
1303
+ }
1304
+ var DEFAULT_RATIO;
1305
+ var init_config = _chunkCDBUTZMHjs.__esm.call(void 0, {
1306
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js"() {
1307
+ "use strict";
1308
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
1309
+ init_esm3();
1310
+ init_AlwaysOffSampler();
1311
+ init_AlwaysOnSampler();
1312
+ init_ParentBasedSampler();
1313
+ init_TraceIdRatioBasedSampler();
1314
+ DEFAULT_RATIO = 1;
1315
+ }
1316
+ });
1317
+
1318
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js
1319
+ function mergeConfig(userConfig) {
1320
+ const perInstanceDefaults = {
1321
+ sampler: buildSamplerFromEnv()
1322
+ };
1323
+ const DEFAULT_CONFIG = loadDefaultConfig();
1324
+ const target = Object.assign({}, DEFAULT_CONFIG, perInstanceDefaults, userConfig);
1325
+ target.generalLimits = Object.assign({}, DEFAULT_CONFIG.generalLimits, userConfig.generalLimits || {});
1326
+ target.spanLimits = Object.assign({}, DEFAULT_CONFIG.spanLimits, userConfig.spanLimits || {});
1327
+ return target;
1328
+ }
1329
+ function reconfigureLimits(userConfig) {
1330
+ const spanLimits = Object.assign({}, userConfig.spanLimits);
1331
+ spanLimits.attributeCountLimit = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([userConfig, 'access', _2 => _2.spanLimits, 'optionalAccess', _3 => _3.attributeCountLimit]), () => ( _optionalChain([userConfig, 'access', _4 => _4.generalLimits, 'optionalAccess', _5 => _5.attributeCountLimit]))), () => ( getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT"))), () => ( getNumberFromEnv("OTEL_ATTRIBUTE_COUNT_LIMIT"))), () => ( DEFAULT_ATTRIBUTE_COUNT_LIMIT));
1332
+ spanLimits.attributeValueLengthLimit = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([userConfig, 'access', _6 => _6.spanLimits, 'optionalAccess', _7 => _7.attributeValueLengthLimit]), () => ( _optionalChain([userConfig, 'access', _8 => _8.generalLimits, 'optionalAccess', _9 => _9.attributeValueLengthLimit]))), () => ( getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT"))), () => ( getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT"))), () => ( DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT));
1333
+ return Object.assign({}, userConfig, { spanLimits });
1334
+ }
1335
+ var DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
1336
+ var init_utility = _chunkCDBUTZMHjs.__esm.call(void 0, {
1337
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js"() {
1338
+ "use strict";
1339
+ init_config();
1340
+ init_esm3();
1341
+ DEFAULT_ATTRIBUTE_COUNT_LIMIT = 128;
1342
+ DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT = Infinity;
1343
+ }
1344
+ });
1345
+
1346
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js
1347
+ var BatchSpanProcessorBase;
1348
+ var init_BatchSpanProcessorBase = _chunkCDBUTZMHjs.__esm.call(void 0, {
1349
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js"() {
1350
+ "use strict";
1351
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
1352
+ init_esm3();
1353
+ BatchSpanProcessorBase = (_class4 = class {
1354
+
1355
+
1356
+
1357
+
1358
+
1359
+ __init14() {this._isExporting = false}
1360
+ __init15() {this._finishedSpans = []}
1361
+
1362
+
1363
+ __init16() {this._droppedSpansCount = 0}
1364
+ constructor(_exporter, config) {;_class4.prototype.__init14.call(this);_class4.prototype.__init15.call(this);_class4.prototype.__init16.call(this);
1365
+ this._exporter = _exporter;
1366
+ this._maxExportBatchSize = typeof _optionalChain([config, 'optionalAccess', _10 => _10.maxExportBatchSize]) === "number" ? config.maxExportBatchSize : _nullishCoalesce(getNumberFromEnv("OTEL_BSP_MAX_EXPORT_BATCH_SIZE"), () => ( 512));
1367
+ this._maxQueueSize = typeof _optionalChain([config, 'optionalAccess', _11 => _11.maxQueueSize]) === "number" ? config.maxQueueSize : _nullishCoalesce(getNumberFromEnv("OTEL_BSP_MAX_QUEUE_SIZE"), () => ( 2048));
1368
+ this._scheduledDelayMillis = typeof _optionalChain([config, 'optionalAccess', _12 => _12.scheduledDelayMillis]) === "number" ? config.scheduledDelayMillis : _nullishCoalesce(getNumberFromEnv("OTEL_BSP_SCHEDULE_DELAY"), () => ( 5e3));
1369
+ this._exportTimeoutMillis = typeof _optionalChain([config, 'optionalAccess', _13 => _13.exportTimeoutMillis]) === "number" ? config.exportTimeoutMillis : _nullishCoalesce(getNumberFromEnv("OTEL_BSP_EXPORT_TIMEOUT"), () => ( 3e4));
1370
+ this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
1371
+ if (this._maxExportBatchSize > this._maxQueueSize) {
1372
+ _chunkCDBUTZMHjs.diag.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize");
1373
+ this._maxExportBatchSize = this._maxQueueSize;
1374
+ }
1375
+ }
1376
+ forceFlush() {
1377
+ if (this._shutdownOnce.isCalled) {
1378
+ return this._shutdownOnce.promise;
1379
+ }
1380
+ return this._flushAll();
1381
+ }
1382
+ // does nothing.
1383
+ onStart(_span, _parentContext) {
1384
+ }
1385
+ onEnd(span) {
1386
+ if (this._shutdownOnce.isCalled) {
1387
+ return;
1388
+ }
1389
+ if ((span.spanContext().traceFlags & _chunkCDBUTZMHjs.TraceFlags.SAMPLED) === 0) {
1390
+ return;
1391
+ }
1392
+ this._addToBuffer(span);
1393
+ }
1394
+ shutdown() {
1395
+ return this._shutdownOnce.call();
1396
+ }
1397
+ _shutdown() {
1398
+ return Promise.resolve().then(() => {
1399
+ return this.onShutdown();
1400
+ }).then(() => {
1401
+ return this._flushAll();
1402
+ }).then(() => {
1403
+ return this._exporter.shutdown();
1404
+ });
1405
+ }
1406
+ /** Add a span in the buffer. */
1407
+ _addToBuffer(span) {
1408
+ if (this._finishedSpans.length >= this._maxQueueSize) {
1409
+ if (this._droppedSpansCount === 0) {
1410
+ _chunkCDBUTZMHjs.diag.debug("maxQueueSize reached, dropping spans");
1411
+ }
1412
+ this._droppedSpansCount++;
1413
+ return;
1414
+ }
1415
+ if (this._droppedSpansCount > 0) {
1416
+ _chunkCDBUTZMHjs.diag.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`);
1417
+ this._droppedSpansCount = 0;
1418
+ }
1419
+ this._finishedSpans.push(span);
1420
+ this._maybeStartTimer();
1421
+ }
1422
+ /**
1423
+ * Send all spans to the exporter respecting the batch size limit
1424
+ * This function is used only on forceFlush or shutdown,
1425
+ * for all other cases _flush should be used
1426
+ * */
1427
+ _flushAll() {
1428
+ return new Promise((resolve, reject2) => {
1429
+ const promises = [];
1430
+ const count = Math.ceil(this._finishedSpans.length / this._maxExportBatchSize);
1431
+ for (let i = 0, j = count; i < j; i++) {
1432
+ promises.push(this._flushOneBatch());
1433
+ }
1434
+ Promise.all(promises).then(() => {
1435
+ resolve();
1436
+ }).catch(reject2);
1437
+ });
1438
+ }
1439
+ _flushOneBatch() {
1440
+ this._clearTimer();
1441
+ if (this._finishedSpans.length === 0) {
1442
+ return Promise.resolve();
1443
+ }
1444
+ return new Promise((resolve, reject2) => {
1445
+ const timer = setTimeout(() => {
1446
+ reject2(new Error("Timeout"));
1447
+ }, this._exportTimeoutMillis);
1448
+ _chunkCDBUTZMHjs.context.with(suppressTracing(_chunkCDBUTZMHjs.context.active()), () => {
1449
+ let spans;
1450
+ if (this._finishedSpans.length <= this._maxExportBatchSize) {
1451
+ spans = this._finishedSpans;
1452
+ this._finishedSpans = [];
1453
+ } else {
1454
+ spans = this._finishedSpans.splice(0, this._maxExportBatchSize);
1455
+ }
1456
+ const doExport = () => this._exporter.export(spans, (result) => {
1457
+ clearTimeout(timer);
1458
+ if (result.code === ExportResultCode.SUCCESS) {
1459
+ resolve();
1460
+ } else {
1461
+ reject2(_nullishCoalesce(result.error, () => ( new Error("BatchSpanProcessor: span export failed"))));
1462
+ }
1463
+ });
1464
+ let pendingResources = null;
1465
+ for (let i = 0, len = spans.length; i < len; i++) {
1466
+ const span = spans[i];
1467
+ if (span.resource.asyncAttributesPending && span.resource.waitForAsyncAttributes) {
1468
+ pendingResources ??= [];
1469
+ pendingResources.push(span.resource.waitForAsyncAttributes());
1470
+ }
1471
+ }
1472
+ if (pendingResources === null) {
1473
+ doExport();
1474
+ } else {
1475
+ Promise.all(pendingResources).then(doExport, (err) => {
1476
+ globalErrorHandler(err);
1477
+ reject2(err);
1478
+ });
1479
+ }
1480
+ });
1481
+ });
1482
+ }
1483
+ _maybeStartTimer() {
1484
+ if (this._isExporting)
1485
+ return;
1486
+ const flush2 = () => {
1487
+ this._isExporting = true;
1488
+ this._flushOneBatch().finally(() => {
1489
+ this._isExporting = false;
1490
+ if (this._finishedSpans.length > 0) {
1491
+ this._clearTimer();
1492
+ this._maybeStartTimer();
1493
+ }
1494
+ }).catch((e) => {
1495
+ this._isExporting = false;
1496
+ globalErrorHandler(e);
1497
+ });
1498
+ };
1499
+ if (this._finishedSpans.length >= this._maxExportBatchSize) {
1500
+ return flush2();
1501
+ }
1502
+ if (this._timer !== void 0)
1503
+ return;
1504
+ this._timer = setTimeout(() => flush2(), this._scheduledDelayMillis);
1505
+ unrefTimer(this._timer);
1506
+ }
1507
+ _clearTimer() {
1508
+ if (this._timer !== void 0) {
1509
+ clearTimeout(this._timer);
1510
+ this._timer = void 0;
1511
+ }
1512
+ }
1513
+ }, _class4);
1514
+ }
1515
+ });
1516
+
1517
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js
1518
+ var BatchSpanProcessor;
1519
+ var init_BatchSpanProcessor = _chunkCDBUTZMHjs.__esm.call(void 0, {
1520
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js"() {
1521
+ "use strict";
1522
+ init_BatchSpanProcessorBase();
1523
+ BatchSpanProcessor = class extends BatchSpanProcessorBase {
1524
+ onShutdown() {
1525
+ }
1526
+ };
1527
+ }
1528
+ });
1529
+
1530
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js
1531
+ function getIdGenerator(bytes) {
1532
+ return function generateId() {
1533
+ for (let i = 0; i < bytes / 4; i++) {
1534
+ SHARED_BUFFER.writeUInt32BE(Math.random() * 2 ** 32 >>> 0, i * 4);
1535
+ }
1536
+ for (let i = 0; i < bytes; i++) {
1537
+ if (SHARED_BUFFER[i] > 0) {
1538
+ break;
1539
+ } else if (i === bytes - 1) {
1540
+ SHARED_BUFFER[bytes - 1] = 1;
1541
+ }
1542
+ }
1543
+ return SHARED_BUFFER.toString("hex", 0, bytes);
1544
+ };
1545
+ }
1546
+ var SPAN_ID_BYTES, TRACE_ID_BYTES, RandomIdGenerator, SHARED_BUFFER;
1547
+ var init_RandomIdGenerator = _chunkCDBUTZMHjs.__esm.call(void 0, {
1548
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js"() {
1549
+ "use strict";
1550
+ SPAN_ID_BYTES = 8;
1551
+ TRACE_ID_BYTES = 16;
1552
+ RandomIdGenerator = (_class5 = class {constructor() { _class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this); }
1553
+ /**
1554
+ * Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex
1555
+ * characters corresponding to 128 bits.
1556
+ */
1557
+ __init17() {this.generateTraceId = getIdGenerator(TRACE_ID_BYTES)}
1558
+ /**
1559
+ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex
1560
+ * characters corresponding to 64 bits.
1561
+ */
1562
+ __init18() {this.generateSpanId = getIdGenerator(SPAN_ID_BYTES)}
1563
+ }, _class5);
1564
+ SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES);
1565
+ }
1566
+ });
1567
+
1568
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js
1569
+ var init_node3 = _chunkCDBUTZMHjs.__esm.call(void 0, {
1570
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js"() {
1571
+ "use strict";
1572
+ init_BatchSpanProcessor();
1573
+ init_RandomIdGenerator();
1574
+ }
1575
+ });
1576
+
1577
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js
1578
+ var init_platform3 = _chunkCDBUTZMHjs.__esm.call(void 0, {
1579
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js"() {
1580
+ "use strict";
1581
+ init_node3();
1582
+ }
1583
+ });
1584
+
1585
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
1586
+ var Tracer;
1587
+ var init_Tracer = _chunkCDBUTZMHjs.__esm.call(void 0, {
1588
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js"() {
1589
+ "use strict";
1590
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
1591
+ init_esm3();
1592
+ init_Span();
1593
+ init_utility();
1594
+ init_platform3();
1595
+ Tracer = class {
1596
+
1597
+
1598
+
1599
+
1600
+
1601
+
1602
+
1603
+ /**
1604
+ * Constructs a new Tracer instance.
1605
+ */
1606
+ constructor(instrumentationScope, config, resource, spanProcessor) {
1607
+ const localConfig = mergeConfig(config);
1608
+ this._sampler = localConfig.sampler;
1609
+ this._generalLimits = localConfig.generalLimits;
1610
+ this._spanLimits = localConfig.spanLimits;
1611
+ this._idGenerator = config.idGenerator || new RandomIdGenerator();
1612
+ this._resource = resource;
1613
+ this._spanProcessor = spanProcessor;
1614
+ this.instrumentationScope = instrumentationScope;
1615
+ }
1616
+ /**
1617
+ * Starts a new Span or returns the default NoopSpan based on the sampling
1618
+ * decision.
1619
+ */
1620
+ startSpan(name, options = {}, context2 = _chunkCDBUTZMHjs.context.active()) {
1621
+ if (options.root) {
1622
+ context2 = _chunkCDBUTZMHjs.trace.deleteSpan(context2);
1623
+ }
1624
+ const parentSpan = _chunkCDBUTZMHjs.trace.getSpan(context2);
1625
+ if (isTracingSuppressed(context2)) {
1626
+ _chunkCDBUTZMHjs.diag.debug("Instrumentation suppressed, returning Noop Span");
1627
+ const nonRecordingSpan = _chunkCDBUTZMHjs.trace.wrapSpanContext(_chunkCDBUTZMHjs.INVALID_SPAN_CONTEXT);
1628
+ return nonRecordingSpan;
1629
+ }
1630
+ const parentSpanContext = _optionalChain([parentSpan, 'optionalAccess', _14 => _14.spanContext, 'call', _15 => _15()]);
1631
+ const spanId = this._idGenerator.generateSpanId();
1632
+ let validParentSpanContext;
1633
+ let traceId;
1634
+ let traceState;
1635
+ if (!parentSpanContext || !_chunkCDBUTZMHjs.trace.isSpanContextValid(parentSpanContext)) {
1636
+ traceId = this._idGenerator.generateTraceId();
1637
+ } else {
1638
+ traceId = parentSpanContext.traceId;
1639
+ traceState = parentSpanContext.traceState;
1640
+ validParentSpanContext = parentSpanContext;
1641
+ }
1642
+ const spanKind = _nullishCoalesce(options.kind, () => ( _chunkCDBUTZMHjs.SpanKind.INTERNAL));
1643
+ const links = (_nullishCoalesce(options.links, () => ( []))).map((link) => {
1644
+ return {
1645
+ context: link.context,
1646
+ attributes: sanitizeAttributes(link.attributes)
1647
+ };
1648
+ });
1649
+ const attributes = sanitizeAttributes(options.attributes);
1650
+ const samplingResult = this._sampler.shouldSample(context2, traceId, name, spanKind, attributes, links);
1651
+ traceState = _nullishCoalesce(samplingResult.traceState, () => ( traceState));
1652
+ const traceFlags = samplingResult.decision === _chunkCDBUTZMHjs.SamplingDecision.RECORD_AND_SAMPLED ? _chunkCDBUTZMHjs.TraceFlags.SAMPLED : _chunkCDBUTZMHjs.TraceFlags.NONE;
1653
+ const spanContext = { traceId, spanId, traceFlags, traceState };
1654
+ if (samplingResult.decision === _chunkCDBUTZMHjs.SamplingDecision.NOT_RECORD) {
1655
+ _chunkCDBUTZMHjs.diag.debug("Recording is off, propagating context in a non-recording span");
1656
+ const nonRecordingSpan = _chunkCDBUTZMHjs.trace.wrapSpanContext(spanContext);
1657
+ return nonRecordingSpan;
1658
+ }
1659
+ const initAttributes = sanitizeAttributes(Object.assign(attributes, samplingResult.attributes));
1660
+ const span = new SpanImpl2({
1661
+ resource: this._resource,
1662
+ scope: this.instrumentationScope,
1663
+ context: context2,
1664
+ spanContext,
1665
+ name,
1666
+ kind: spanKind,
1667
+ links,
1668
+ parentSpanContext: validParentSpanContext,
1669
+ attributes: initAttributes,
1670
+ startTime: options.startTime,
1671
+ spanProcessor: this._spanProcessor,
1672
+ spanLimits: this._spanLimits
1673
+ });
1674
+ return span;
1675
+ }
1676
+ startActiveSpan(name, arg2, arg3, arg4) {
1677
+ let opts;
1678
+ let ctx;
1679
+ let fn;
1680
+ if (arguments.length < 2) {
1681
+ return;
1682
+ } else if (arguments.length === 2) {
1683
+ fn = arg2;
1684
+ } else if (arguments.length === 3) {
1685
+ opts = arg2;
1686
+ fn = arg3;
1687
+ } else {
1688
+ opts = arg2;
1689
+ ctx = arg3;
1690
+ fn = arg4;
1691
+ }
1692
+ const parentContext = _nullishCoalesce(ctx, () => ( _chunkCDBUTZMHjs.context.active()));
1693
+ const span = this.startSpan(name, opts, parentContext);
1694
+ const contextWithSpanSet = _chunkCDBUTZMHjs.trace.setSpan(parentContext, span);
1695
+ return _chunkCDBUTZMHjs.context.with(contextWithSpanSet, fn, void 0, span);
1696
+ }
1697
+ /** Returns the active {@link GeneralLimits}. */
1698
+ getGeneralLimits() {
1699
+ return this._generalLimits;
1700
+ }
1701
+ /** Returns the active {@link SpanLimits}. */
1702
+ getSpanLimits() {
1703
+ return this._spanLimits;
1704
+ }
1705
+ };
1706
+ }
1707
+ });
1708
+
1709
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js
1710
+ var MultiSpanProcessor;
1711
+ var init_MultiSpanProcessor = _chunkCDBUTZMHjs.__esm.call(void 0, {
1712
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js"() {
1713
+ "use strict";
1714
+ init_esm3();
1715
+ MultiSpanProcessor = class {
1716
+
1717
+ constructor(_spanProcessors) {
1718
+ this._spanProcessors = _spanProcessors;
1719
+ }
1720
+ forceFlush() {
1721
+ const promises = [];
1722
+ for (const spanProcessor of this._spanProcessors) {
1723
+ promises.push(spanProcessor.forceFlush());
1724
+ }
1725
+ return new Promise((resolve) => {
1726
+ Promise.all(promises).then(() => {
1727
+ resolve();
1728
+ }).catch((error2) => {
1729
+ globalErrorHandler(error2 || new Error("MultiSpanProcessor: forceFlush failed"));
1730
+ resolve();
1731
+ });
1732
+ });
1733
+ }
1734
+ onStart(span, context2) {
1735
+ for (const spanProcessor of this._spanProcessors) {
1736
+ spanProcessor.onStart(span, context2);
1737
+ }
1738
+ }
1739
+ onEnd(span) {
1740
+ for (const spanProcessor of this._spanProcessors) {
1741
+ spanProcessor.onEnd(span);
1742
+ }
1743
+ }
1744
+ shutdown() {
1745
+ const promises = [];
1746
+ for (const spanProcessor of this._spanProcessors) {
1747
+ promises.push(spanProcessor.shutdown());
1748
+ }
1749
+ return new Promise((resolve, reject2) => {
1750
+ Promise.all(promises).then(() => {
1751
+ resolve();
1752
+ }, reject2);
1753
+ });
1754
+ }
1755
+ };
1756
+ }
1757
+ });
1758
+
1759
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js
1760
+ var ForceFlushState, BasicTracerProvider;
1761
+ var init_BasicTracerProvider = _chunkCDBUTZMHjs.__esm.call(void 0, {
1762
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js"() {
1763
+ "use strict";
1764
+ init_esm3();
1765
+ init_esm4();
1766
+ init_Tracer();
1767
+ init_config();
1768
+ init_MultiSpanProcessor();
1769
+ init_utility();
1770
+ (function(ForceFlushState2) {
1771
+ ForceFlushState2[ForceFlushState2["resolved"] = 0] = "resolved";
1772
+ ForceFlushState2[ForceFlushState2["timeout"] = 1] = "timeout";
1773
+ ForceFlushState2[ForceFlushState2["error"] = 2] = "error";
1774
+ ForceFlushState2[ForceFlushState2["unresolved"] = 3] = "unresolved";
1775
+ })(ForceFlushState || (ForceFlushState = {}));
1776
+ BasicTracerProvider = (_class6 = class {
1777
+
1778
+ __init19() {this._tracers = /* @__PURE__ */ new Map()}
1779
+
1780
+
1781
+ constructor(config = {}) {;_class6.prototype.__init19.call(this);
1782
+ const mergedConfig = merge({}, loadDefaultConfig(), reconfigureLimits(config));
1783
+ this._resource = _nullishCoalesce(mergedConfig.resource, () => ( defaultResource()));
1784
+ this._config = Object.assign({}, mergedConfig, {
1785
+ resource: this._resource
1786
+ });
1787
+ const spanProcessors = [];
1788
+ if (_optionalChain([config, 'access', _16 => _16.spanProcessors, 'optionalAccess', _17 => _17.length])) {
1789
+ spanProcessors.push(...config.spanProcessors);
1790
+ }
1791
+ this._activeSpanProcessor = new MultiSpanProcessor(spanProcessors);
1792
+ }
1793
+ getTracer(name, version, options) {
1794
+ const key = `${name}@${version || ""}:${_optionalChain([options, 'optionalAccess', _18 => _18.schemaUrl]) || ""}`;
1795
+ if (!this._tracers.has(key)) {
1796
+ this._tracers.set(key, new Tracer({ name, version, schemaUrl: _optionalChain([options, 'optionalAccess', _19 => _19.schemaUrl]) }, this._config, this._resource, this._activeSpanProcessor));
1797
+ }
1798
+ return this._tracers.get(key);
1799
+ }
1800
+ forceFlush() {
1801
+ const timeout = this._config.forceFlushTimeoutMillis;
1802
+ const promises = this._activeSpanProcessor["_spanProcessors"].map((spanProcessor) => {
1803
+ return new Promise((resolve) => {
1804
+ let state;
1805
+ const timeoutInterval = setTimeout(() => {
1806
+ resolve(new Error(`Span processor did not completed within timeout period of ${timeout} ms`));
1807
+ state = ForceFlushState.timeout;
1808
+ }, timeout);
1809
+ spanProcessor.forceFlush().then(() => {
1810
+ clearTimeout(timeoutInterval);
1811
+ if (state !== ForceFlushState.timeout) {
1812
+ state = ForceFlushState.resolved;
1813
+ resolve(state);
1814
+ }
1815
+ }).catch((error2) => {
1816
+ clearTimeout(timeoutInterval);
1817
+ state = ForceFlushState.error;
1818
+ resolve(error2);
1819
+ });
1820
+ });
1821
+ });
1822
+ return new Promise((resolve, reject2) => {
1823
+ Promise.all(promises).then((results) => {
1824
+ const errors = results.filter((result) => result !== ForceFlushState.resolved);
1825
+ if (errors.length > 0) {
1826
+ reject2(errors);
1827
+ } else {
1828
+ resolve();
1829
+ }
1830
+ }).catch((error2) => reject2([error2]));
1831
+ });
1832
+ }
1833
+ shutdown() {
1834
+ return this._activeSpanProcessor.shutdown();
1835
+ }
1836
+ }, _class6);
1837
+ }
1838
+ });
1839
+
1840
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/ConsoleSpanExporter.js
1841
+ var ConsoleSpanExporter;
1842
+ var init_ConsoleSpanExporter = _chunkCDBUTZMHjs.__esm.call(void 0, {
1843
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/ConsoleSpanExporter.js"() {
1844
+ "use strict";
1845
+ init_esm3();
1846
+ ConsoleSpanExporter = class {
1847
+ /**
1848
+ * Export spans.
1849
+ * @param spans
1850
+ * @param resultCallback
1851
+ */
1852
+ export(spans, resultCallback) {
1853
+ return this._sendSpans(spans, resultCallback);
1854
+ }
1855
+ /**
1856
+ * Shutdown the exporter.
1857
+ */
1858
+ shutdown() {
1859
+ this._sendSpans([]);
1860
+ return this.forceFlush();
1861
+ }
1862
+ /**
1863
+ * Exports any pending spans in exporter
1864
+ */
1865
+ forceFlush() {
1866
+ return Promise.resolve();
1867
+ }
1868
+ /**
1869
+ * converts span info into more readable format
1870
+ * @param span
1871
+ */
1872
+ _exportInfo(span) {
1873
+ return {
1874
+ resource: {
1875
+ attributes: span.resource.attributes
1876
+ },
1877
+ instrumentationScope: span.instrumentationScope,
1878
+ traceId: span.spanContext().traceId,
1879
+ parentSpanContext: span.parentSpanContext,
1880
+ traceState: _optionalChain([span, 'access', _20 => _20.spanContext, 'call', _21 => _21(), 'access', _22 => _22.traceState, 'optionalAccess', _23 => _23.serialize, 'call', _24 => _24()]),
1881
+ name: span.name,
1882
+ id: span.spanContext().spanId,
1883
+ kind: span.kind,
1884
+ timestamp: hrTimeToMicroseconds(span.startTime),
1885
+ duration: hrTimeToMicroseconds(span.duration),
1886
+ attributes: span.attributes,
1887
+ status: span.status,
1888
+ events: span.events,
1889
+ links: span.links
1890
+ };
1891
+ }
1892
+ /**
1893
+ * Showing spans in console
1894
+ * @param spans
1895
+ * @param done
1896
+ */
1897
+ _sendSpans(spans, done) {
1898
+ for (const span of spans) {
1899
+ console.dir(this._exportInfo(span), { depth: 3 });
1900
+ }
1901
+ if (done) {
1902
+ return done({ code: ExportResultCode.SUCCESS });
1903
+ }
1904
+ }
1905
+ };
1906
+ }
1907
+ });
1908
+
1909
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/InMemorySpanExporter.js
1910
+ var InMemorySpanExporter;
1911
+ var init_InMemorySpanExporter = _chunkCDBUTZMHjs.__esm.call(void 0, {
1912
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/InMemorySpanExporter.js"() {
1913
+ "use strict";
1914
+ init_esm3();
1915
+ InMemorySpanExporter = (_class7 = class {constructor() { _class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this); }
1916
+ __init20() {this._finishedSpans = []}
1917
+ /**
1918
+ * Indicates if the exporter has been "shutdown."
1919
+ * When false, exported spans will not be stored in-memory.
1920
+ */
1921
+ __init21() {this._stopped = false}
1922
+ export(spans, resultCallback) {
1923
+ if (this._stopped)
1924
+ return resultCallback({
1925
+ code: ExportResultCode.FAILED,
1926
+ error: new Error("Exporter has been stopped")
1927
+ });
1928
+ this._finishedSpans.push(...spans);
1929
+ setTimeout(() => resultCallback({ code: ExportResultCode.SUCCESS }), 0);
1930
+ }
1931
+ shutdown() {
1932
+ this._stopped = true;
1933
+ this._finishedSpans = [];
1934
+ return this.forceFlush();
1935
+ }
1936
+ /**
1937
+ * Exports any pending spans in the exporter
1938
+ */
1939
+ forceFlush() {
1940
+ return Promise.resolve();
1941
+ }
1942
+ reset() {
1943
+ this._finishedSpans = [];
1944
+ }
1945
+ getFinishedSpans() {
1946
+ return this._finishedSpans;
1947
+ }
1948
+ }, _class7);
1949
+ }
1950
+ });
1951
+
1952
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/SimpleSpanProcessor.js
1953
+ var SimpleSpanProcessor;
1954
+ var init_SimpleSpanProcessor = _chunkCDBUTZMHjs.__esm.call(void 0, {
1955
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/SimpleSpanProcessor.js"() {
1956
+ "use strict";
1957
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
1958
+ init_esm3();
1959
+ SimpleSpanProcessor = class {
1960
+
1961
+
1962
+
1963
+ constructor(_exporter) {
1964
+ this._exporter = _exporter;
1965
+ this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
1966
+ this._pendingExports = /* @__PURE__ */ new Set();
1967
+ }
1968
+ async forceFlush() {
1969
+ await Promise.all(Array.from(this._pendingExports));
1970
+ if (this._exporter.forceFlush) {
1971
+ await this._exporter.forceFlush();
1972
+ }
1973
+ }
1974
+ onStart(_span, _parentContext) {
1975
+ }
1976
+ onEnd(span) {
1977
+ if (this._shutdownOnce.isCalled) {
1978
+ return;
1979
+ }
1980
+ if ((span.spanContext().traceFlags & _chunkCDBUTZMHjs.TraceFlags.SAMPLED) === 0) {
1981
+ return;
1982
+ }
1983
+ const pendingExport = this._doExport(span).catch((err) => globalErrorHandler(err));
1984
+ this._pendingExports.add(pendingExport);
1985
+ pendingExport.finally(() => this._pendingExports.delete(pendingExport));
1986
+ }
1987
+ async _doExport(span) {
1988
+ if (span.resource.asyncAttributesPending) {
1989
+ await _optionalChain([span, 'access', _25 => _25.resource, 'access', _26 => _26.waitForAsyncAttributes, 'optionalCall', _27 => _27()]);
1990
+ }
1991
+ const result = await internal._export(this._exporter, [span]);
1992
+ if (result.code !== ExportResultCode.SUCCESS) {
1993
+ throw _nullishCoalesce(result.error, () => ( new Error(`SimpleSpanProcessor: span export failed (status ${result})`)));
1994
+ }
1995
+ }
1996
+ shutdown() {
1997
+ return this._shutdownOnce.call();
1998
+ }
1999
+ _shutdown() {
2000
+ return this._exporter.shutdown();
2001
+ }
2002
+ };
2003
+ }
2004
+ });
2005
+
2006
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/NoopSpanProcessor.js
2007
+ var NoopSpanProcessor;
2008
+ var init_NoopSpanProcessor = _chunkCDBUTZMHjs.__esm.call(void 0, {
2009
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/NoopSpanProcessor.js"() {
2010
+ "use strict";
2011
+ NoopSpanProcessor = class {
2012
+ onStart(_span, _context) {
2013
+ }
2014
+ onEnd(_span) {
2015
+ }
2016
+ shutdown() {
2017
+ return Promise.resolve();
2018
+ }
2019
+ forceFlush() {
2020
+ return Promise.resolve();
2021
+ }
2022
+ };
2023
+ }
2024
+ });
2025
+
2026
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js
2027
+ var esm_exports2 = {};
2028
+ _chunkCDBUTZMHjs.__export.call(void 0, esm_exports2, {
2029
+ AlwaysOffSampler: () => AlwaysOffSampler,
2030
+ AlwaysOnSampler: () => AlwaysOnSampler,
2031
+ BasicTracerProvider: () => BasicTracerProvider,
2032
+ BatchSpanProcessor: () => BatchSpanProcessor,
2033
+ ConsoleSpanExporter: () => ConsoleSpanExporter,
2034
+ InMemorySpanExporter: () => InMemorySpanExporter,
2035
+ NoopSpanProcessor: () => NoopSpanProcessor,
2036
+ ParentBasedSampler: () => ParentBasedSampler,
2037
+ RandomIdGenerator: () => RandomIdGenerator,
2038
+ SamplingDecision: () => SamplingDecision2,
2039
+ SimpleSpanProcessor: () => SimpleSpanProcessor,
2040
+ TraceIdRatioBasedSampler: () => TraceIdRatioBasedSampler
2041
+ });
2042
+ var init_esm5 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2043
+ "../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js"() {
2044
+ "use strict";
2045
+ init_BasicTracerProvider();
2046
+ init_platform3();
2047
+ init_ConsoleSpanExporter();
2048
+ init_InMemorySpanExporter();
2049
+ init_SimpleSpanProcessor();
2050
+ init_NoopSpanProcessor();
2051
+ init_AlwaysOffSampler();
2052
+ init_AlwaysOnSampler();
2053
+ init_ParentBasedSampler();
2054
+ init_TraceIdRatioBasedSampler();
2055
+ init_Sampler();
2056
+ }
2057
+ });
2058
+
2059
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js
2060
+ var OTLPExporterBase;
2061
+ var init_OTLPExporterBase = _chunkCDBUTZMHjs.__esm.call(void 0, {
2062
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js"() {
2063
+ "use strict";
2064
+ OTLPExporterBase = class {
2065
+
2066
+ constructor(_delegate) {
2067
+ this._delegate = _delegate;
2068
+ }
2069
+ /**
2070
+ * Export items.
2071
+ * @param items
2072
+ * @param resultCallback
2073
+ */
2074
+ export(items, resultCallback) {
2075
+ this._delegate.export(items, resultCallback);
2076
+ }
2077
+ forceFlush() {
2078
+ return this._delegate.forceFlush();
2079
+ }
2080
+ shutdown() {
2081
+ return this._delegate.shutdown();
2082
+ }
2083
+ };
2084
+ }
2085
+ });
2086
+
2087
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js
2088
+ var OTLPExporterError;
2089
+ var init_types = _chunkCDBUTZMHjs.__esm.call(void 0, {
2090
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js"() {
2091
+ "use strict";
2092
+ OTLPExporterError = (_class8 = class extends Error {
2093
+
2094
+ __init22() {this.name = "OTLPExporterError"}
2095
+
2096
+ constructor(message, code, data) {
2097
+ super(message);_class8.prototype.__init22.call(this);;
2098
+ this.data = data;
2099
+ this.code = code;
2100
+ }
2101
+ }, _class8);
2102
+ }
2103
+ });
2104
+
2105
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js
2106
+ function validateTimeoutMillis(timeoutMillis) {
2107
+ if (Number.isFinite(timeoutMillis) && timeoutMillis > 0) {
2108
+ return timeoutMillis;
2109
+ }
2110
+ throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${timeoutMillis}')`);
2111
+ }
2112
+ function wrapStaticHeadersInFunction(headers) {
2113
+ if (headers == null) {
2114
+ return void 0;
2115
+ }
2116
+ return () => headers;
2117
+ }
2118
+ function mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
2119
+ return {
2120
+ timeoutMillis: validateTimeoutMillis(_nullishCoalesce(_nullishCoalesce(userProvidedConfiguration.timeoutMillis, () => ( fallbackConfiguration.timeoutMillis)), () => ( defaultConfiguration.timeoutMillis))),
2121
+ concurrencyLimit: _nullishCoalesce(_nullishCoalesce(userProvidedConfiguration.concurrencyLimit, () => ( fallbackConfiguration.concurrencyLimit)), () => ( defaultConfiguration.concurrencyLimit)),
2122
+ compression: _nullishCoalesce(_nullishCoalesce(userProvidedConfiguration.compression, () => ( fallbackConfiguration.compression)), () => ( defaultConfiguration.compression))
2123
+ };
2124
+ }
2125
+ function getSharedConfigurationDefaults() {
2126
+ return {
2127
+ timeoutMillis: 1e4,
2128
+ concurrencyLimit: 30,
2129
+ compression: "none"
2130
+ };
2131
+ }
2132
+ var init_shared_configuration = _chunkCDBUTZMHjs.__esm.call(void 0, {
2133
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js"() {
2134
+ "use strict";
2135
+ }
2136
+ });
2137
+
2138
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js
2139
+ function createBoundedQueueExportPromiseHandler(options) {
2140
+ return new BoundedQueueExportPromiseHandler(options.concurrencyLimit);
2141
+ }
2142
+ var BoundedQueueExportPromiseHandler;
2143
+ var init_bounded_queue_export_promise_handler = _chunkCDBUTZMHjs.__esm.call(void 0, {
2144
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js"() {
2145
+ "use strict";
2146
+ BoundedQueueExportPromiseHandler = (_class9 = class {
2147
+
2148
+ __init23() {this._sendingPromises = []}
2149
+ /**
2150
+ * @param concurrencyLimit maximum promises allowed in a queue at the same time.
2151
+ */
2152
+ constructor(concurrencyLimit) {;_class9.prototype.__init23.call(this);
2153
+ this._concurrencyLimit = concurrencyLimit;
2154
+ }
2155
+ pushPromise(promise) {
2156
+ if (this.hasReachedLimit()) {
2157
+ throw new Error("Concurrency Limit reached");
2158
+ }
2159
+ this._sendingPromises.push(promise);
2160
+ const popPromise = () => {
2161
+ const index = this._sendingPromises.indexOf(promise);
2162
+ this._sendingPromises.splice(index, 1);
2163
+ };
2164
+ promise.then(popPromise, popPromise);
2165
+ }
2166
+ hasReachedLimit() {
2167
+ return this._sendingPromises.length >= this._concurrencyLimit;
2168
+ }
2169
+ async awaitAll() {
2170
+ await Promise.all(this._sendingPromises);
2171
+ }
2172
+ }, _class9);
2173
+ }
2174
+ });
2175
+
2176
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/baggage/constants.js
2177
+ var BAGGAGE_KEY_PAIR_SEPARATOR, BAGGAGE_PROPERTIES_SEPARATOR, BAGGAGE_ITEMS_SEPARATOR;
2178
+ var init_constants = _chunkCDBUTZMHjs.__esm.call(void 0, {
2179
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/baggage/constants.js"() {
2180
+ "use strict";
2181
+ BAGGAGE_KEY_PAIR_SEPARATOR = "=";
2182
+ BAGGAGE_PROPERTIES_SEPARATOR = ";";
2183
+ BAGGAGE_ITEMS_SEPARATOR = ",";
2184
+ }
2185
+ });
2186
+
2187
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/baggage/utils.js
2188
+ function parsePairKeyValue(entry) {
2189
+ const valueProps = entry.split(BAGGAGE_PROPERTIES_SEPARATOR);
2190
+ if (valueProps.length <= 0)
2191
+ return;
2192
+ const keyPairPart = valueProps.shift();
2193
+ if (!keyPairPart)
2194
+ return;
2195
+ const separatorIndex = keyPairPart.indexOf(BAGGAGE_KEY_PAIR_SEPARATOR);
2196
+ if (separatorIndex <= 0)
2197
+ return;
2198
+ const key = decodeURIComponent(keyPairPart.substring(0, separatorIndex).trim());
2199
+ const value = decodeURIComponent(keyPairPart.substring(separatorIndex + 1).trim());
2200
+ let metadata;
2201
+ if (valueProps.length > 0) {
2202
+ metadata = _chunkCDBUTZMHjs.baggageEntryMetadataFromString.call(void 0, valueProps.join(BAGGAGE_PROPERTIES_SEPARATOR));
2203
+ }
2204
+ return { key, value, metadata };
2205
+ }
2206
+ function parseKeyPairsIntoRecord(value) {
2207
+ if (typeof value !== "string" || value.length === 0)
2208
+ return {};
2209
+ return value.split(BAGGAGE_ITEMS_SEPARATOR).map((entry) => {
2210
+ return parsePairKeyValue(entry);
2211
+ }).filter((keyPair) => keyPair !== void 0 && keyPair.value.length > 0).reduce((headers, keyPair) => {
2212
+ headers[keyPair.key] = keyPair.value;
2213
+ return headers;
2214
+ }, {});
2215
+ }
2216
+ var init_utils2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2217
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/baggage/utils.js"() {
2218
+ "use strict";
2219
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
2220
+ init_constants();
2221
+ }
2222
+ });
2223
+
2224
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/time.js
2225
+ function hrTimeToNanoseconds2(time) {
2226
+ return time[0] * SECOND_TO_NANOSECONDS2 + time[1];
2227
+ }
2228
+ var NANOSECOND_DIGITS2, NANOSECOND_DIGITS_IN_MILLIS2, MILLISECONDS_TO_NANOSECONDS2, SECOND_TO_NANOSECONDS2;
2229
+ var init_time2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2230
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/time.js"() {
2231
+ "use strict";
2232
+ NANOSECOND_DIGITS2 = 9;
2233
+ NANOSECOND_DIGITS_IN_MILLIS2 = 6;
2234
+ MILLISECONDS_TO_NANOSECONDS2 = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS2);
2235
+ SECOND_TO_NANOSECONDS2 = Math.pow(10, NANOSECOND_DIGITS2);
2236
+ }
2237
+ });
2238
+
2239
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/ExportResult.js
2240
+ var ExportResultCode2;
2241
+ var init_ExportResult2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2242
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/ExportResult.js"() {
2243
+ "use strict";
2244
+ (function(ExportResultCode3) {
2245
+ ExportResultCode3[ExportResultCode3["SUCCESS"] = 0] = "SUCCESS";
2246
+ ExportResultCode3[ExportResultCode3["FAILED"] = 1] = "FAILED";
2247
+ })(ExportResultCode2 || (ExportResultCode2 = {}));
2248
+ }
2249
+ });
2250
+
2251
+ // ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js
2252
+ var init_esm6 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2253
+ "../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js"() {
2254
+ "use strict";
2255
+ init_time2();
2256
+ init_ExportResult2();
2257
+ init_utils2();
2258
+ }
2259
+ });
2260
+
2261
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/logging-response-handler.js
2262
+ function isPartialSuccessResponse(response) {
2263
+ return Object.prototype.hasOwnProperty.call(response, "partialSuccess");
2264
+ }
2265
+ function createLoggingPartialSuccessResponseHandler() {
2266
+ return {
2267
+ handleResponse(response) {
2268
+ if (response == null || !isPartialSuccessResponse(response) || response.partialSuccess == null || Object.keys(response.partialSuccess).length === 0) {
2269
+ return;
2270
+ }
2271
+ _chunkCDBUTZMHjs.diag.warn("Received Partial Success response:", JSON.stringify(response.partialSuccess));
2272
+ }
2273
+ };
2274
+ }
2275
+ var init_logging_response_handler = _chunkCDBUTZMHjs.__esm.call(void 0, {
2276
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/logging-response-handler.js"() {
2277
+ "use strict";
2278
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
2279
+ }
2280
+ });
2281
+
2282
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js
2283
+ function createOtlpExportDelegate(components, settings) {
2284
+ return new OTLPExportDelegate(components.transport, components.serializer, createLoggingPartialSuccessResponseHandler(), components.promiseHandler, settings.timeout);
2285
+ }
2286
+ var OTLPExportDelegate;
2287
+ var init_otlp_export_delegate = _chunkCDBUTZMHjs.__esm.call(void 0, {
2288
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js"() {
2289
+ "use strict";
2290
+ init_esm6();
2291
+ init_types();
2292
+ init_logging_response_handler();
2293
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
2294
+ OTLPExportDelegate = class {
2295
+
2296
+
2297
+
2298
+
2299
+
2300
+
2301
+ constructor(_transport, _serializer, _responseHandler, _promiseQueue, _timeout) {
2302
+ this._transport = _transport;
2303
+ this._serializer = _serializer;
2304
+ this._responseHandler = _responseHandler;
2305
+ this._promiseQueue = _promiseQueue;
2306
+ this._timeout = _timeout;
2307
+ this._diagLogger = _chunkCDBUTZMHjs.diag.createComponentLogger({
2308
+ namespace: "OTLPExportDelegate"
2309
+ });
2310
+ }
2311
+ export(internalRepresentation, resultCallback) {
2312
+ this._diagLogger.debug("items to be sent", internalRepresentation);
2313
+ if (this._promiseQueue.hasReachedLimit()) {
2314
+ resultCallback({
2315
+ code: ExportResultCode2.FAILED,
2316
+ error: new Error("Concurrent export limit reached")
2317
+ });
2318
+ return;
2319
+ }
2320
+ const serializedRequest = this._serializer.serializeRequest(internalRepresentation);
2321
+ if (serializedRequest == null) {
2322
+ resultCallback({
2323
+ code: ExportResultCode2.FAILED,
2324
+ error: new Error("Nothing to send")
2325
+ });
2326
+ return;
2327
+ }
2328
+ this._promiseQueue.pushPromise(this._transport.send(serializedRequest, this._timeout).then((response) => {
2329
+ if (response.status === "success") {
2330
+ if (response.data != null) {
2331
+ try {
2332
+ this._responseHandler.handleResponse(this._serializer.deserializeResponse(response.data));
2333
+ } catch (e) {
2334
+ this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?", e, response.data);
2335
+ }
2336
+ }
2337
+ resultCallback({
2338
+ code: ExportResultCode2.SUCCESS
2339
+ });
2340
+ return;
2341
+ } else if (response.status === "failure" && response.error) {
2342
+ resultCallback({
2343
+ code: ExportResultCode2.FAILED,
2344
+ error: response.error
2345
+ });
2346
+ return;
2347
+ } else if (response.status === "retryable") {
2348
+ resultCallback({
2349
+ code: ExportResultCode2.FAILED,
2350
+ error: new OTLPExporterError("Export failed with retryable status")
2351
+ });
2352
+ } else {
2353
+ resultCallback({
2354
+ code: ExportResultCode2.FAILED,
2355
+ error: new OTLPExporterError("Export failed with unknown error")
2356
+ });
2357
+ }
2358
+ }, (reason) => resultCallback({
2359
+ code: ExportResultCode2.FAILED,
2360
+ error: reason
2361
+ })));
2362
+ }
2363
+ forceFlush() {
2364
+ return this._promiseQueue.awaitAll();
2365
+ }
2366
+ async shutdown() {
2367
+ this._diagLogger.debug("shutdown started");
2368
+ await this.forceFlush();
2369
+ this._transport.shutdown();
2370
+ }
2371
+ };
2372
+ }
2373
+ });
2374
+
2375
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js
2376
+ var init_esm7 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2377
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js"() {
2378
+ "use strict";
2379
+ init_OTLPExporterBase();
2380
+ }
2381
+ });
2382
+
2383
+ // ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/version.js
2384
+ var VERSION2;
2385
+ var init_version2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2386
+ "../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/version.js"() {
2387
+ "use strict";
2388
+ VERSION2 = "0.200.0";
2389
+ }
2390
+ });
2391
+
2392
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/hex-to-binary.js
2393
+ function intValue(charCode) {
2394
+ if (charCode >= 48 && charCode <= 57) {
2395
+ return charCode - 48;
2396
+ }
2397
+ if (charCode >= 97 && charCode <= 102) {
2398
+ return charCode - 87;
2399
+ }
2400
+ return charCode - 55;
2401
+ }
2402
+ function hexToBinary(hexStr) {
2403
+ const buf = new Uint8Array(hexStr.length / 2);
2404
+ let offset = 0;
2405
+ for (let i = 0; i < hexStr.length; i += 2) {
2406
+ const hi = intValue(hexStr.charCodeAt(i));
2407
+ const lo = intValue(hexStr.charCodeAt(i + 1));
2408
+ buf[offset++] = hi << 4 | lo;
2409
+ }
2410
+ return buf;
2411
+ }
2412
+ var init_hex_to_binary = _chunkCDBUTZMHjs.__esm.call(void 0, {
2413
+ "../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/hex-to-binary.js"() {
2414
+ "use strict";
2415
+ }
2416
+ });
2417
+
2418
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js
2419
+ function hrTimeToNanos(hrTime3) {
2420
+ const NANOSECONDS = BigInt(1e9);
2421
+ return BigInt(hrTime3[0]) * NANOSECONDS + BigInt(hrTime3[1]);
2422
+ }
2423
+ function toLongBits(value) {
2424
+ const low = Number(BigInt.asUintN(32, value));
2425
+ const high = Number(BigInt.asUintN(32, value >> BigInt(32)));
2426
+ return { low, high };
2427
+ }
2428
+ function encodeAsLongBits(hrTime3) {
2429
+ const nanos = hrTimeToNanos(hrTime3);
2430
+ return toLongBits(nanos);
2431
+ }
2432
+ function encodeAsString(hrTime3) {
2433
+ const nanos = hrTimeToNanos(hrTime3);
2434
+ return nanos.toString();
2435
+ }
2436
+ function identity(value) {
2437
+ return value;
2438
+ }
2439
+ function optionalHexToBinary(str) {
2440
+ if (str === void 0)
2441
+ return void 0;
2442
+ return hexToBinary(str);
2443
+ }
2444
+ function getOtlpEncoder(options) {
2445
+ if (options === void 0) {
2446
+ return DEFAULT_ENCODER;
2447
+ }
2448
+ const useLongBits = _nullishCoalesce(options.useLongBits, () => ( true));
2449
+ const useHex = _nullishCoalesce(options.useHex, () => ( false));
2450
+ return {
2451
+ encodeHrTime: useLongBits ? encodeAsLongBits : encodeTimestamp,
2452
+ encodeSpanContext: useHex ? identity : hexToBinary,
2453
+ encodeOptionalSpanContext: useHex ? identity : optionalHexToBinary
2454
+ };
2455
+ }
2456
+ var encodeTimestamp, DEFAULT_ENCODER;
2457
+ var init_utils3 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2458
+ "../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js"() {
2459
+ "use strict";
2460
+ init_esm6();
2461
+ init_hex_to_binary();
2462
+ encodeTimestamp = typeof BigInt !== "undefined" ? encodeAsString : hrTimeToNanoseconds2;
2463
+ DEFAULT_ENCODER = {
2464
+ encodeHrTime: encodeAsLongBits,
2465
+ encodeSpanContext: hexToBinary,
2466
+ encodeOptionalSpanContext: optionalHexToBinary
2467
+ };
2468
+ }
2469
+ });
2470
+
2471
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js
2472
+ function createResource(resource) {
2473
+ return {
2474
+ attributes: toAttributes(resource.attributes),
2475
+ droppedAttributesCount: 0
2476
+ };
2477
+ }
2478
+ function createInstrumentationScope(scope) {
2479
+ return {
2480
+ name: scope.name,
2481
+ version: scope.version
2482
+ };
2483
+ }
2484
+ function toAttributes(attributes) {
2485
+ return Object.keys(attributes).map((key) => toKeyValue(key, attributes[key]));
2486
+ }
2487
+ function toKeyValue(key, value) {
2488
+ return {
2489
+ key,
2490
+ value: toAnyValue(value)
2491
+ };
2492
+ }
2493
+ function toAnyValue(value) {
2494
+ const t = typeof value;
2495
+ if (t === "string")
2496
+ return { stringValue: value };
2497
+ if (t === "number") {
2498
+ if (!Number.isInteger(value))
2499
+ return { doubleValue: value };
2500
+ return { intValue: value };
2501
+ }
2502
+ if (t === "boolean")
2503
+ return { boolValue: value };
2504
+ if (value instanceof Uint8Array)
2505
+ return { bytesValue: value };
2506
+ if (Array.isArray(value))
2507
+ return { arrayValue: { values: value.map(toAnyValue) } };
2508
+ if (t === "object" && value != null)
2509
+ return {
2510
+ kvlistValue: {
2511
+ values: Object.entries(value).map(([k, v]) => toKeyValue(k, v))
2512
+ }
2513
+ };
2514
+ return {};
2515
+ }
2516
+ var init_internal = _chunkCDBUTZMHjs.__esm.call(void 0, {
2517
+ "../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js"() {
2518
+ "use strict";
2519
+ }
2520
+ });
2521
+
2522
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js
2523
+ function sdkSpanToOtlpSpan(span, encoder) {
2524
+ const ctx = span.spanContext();
2525
+ const status = span.status;
2526
+ const parentSpanId = _optionalChain([span, 'access', _28 => _28.parentSpanContext, 'optionalAccess', _29 => _29.spanId]) ? encoder.encodeSpanContext(_optionalChain([span, 'access', _30 => _30.parentSpanContext, 'optionalAccess', _31 => _31.spanId])) : void 0;
2527
+ return {
2528
+ traceId: encoder.encodeSpanContext(ctx.traceId),
2529
+ spanId: encoder.encodeSpanContext(ctx.spanId),
2530
+ parentSpanId,
2531
+ traceState: _optionalChain([ctx, 'access', _32 => _32.traceState, 'optionalAccess', _33 => _33.serialize, 'call', _34 => _34()]),
2532
+ name: span.name,
2533
+ // Span kind is offset by 1 because the API does not define a value for unset
2534
+ kind: span.kind == null ? 0 : span.kind + 1,
2535
+ startTimeUnixNano: encoder.encodeHrTime(span.startTime),
2536
+ endTimeUnixNano: encoder.encodeHrTime(span.endTime),
2537
+ attributes: toAttributes(span.attributes),
2538
+ droppedAttributesCount: span.droppedAttributesCount,
2539
+ events: span.events.map((event) => toOtlpSpanEvent(event, encoder)),
2540
+ droppedEventsCount: span.droppedEventsCount,
2541
+ status: {
2542
+ // API and proto enums share the same values
2543
+ code: status.code,
2544
+ message: status.message
2545
+ },
2546
+ links: span.links.map((link) => toOtlpLink(link, encoder)),
2547
+ droppedLinksCount: span.droppedLinksCount
2548
+ };
2549
+ }
2550
+ function toOtlpLink(link, encoder) {
2551
+ return {
2552
+ attributes: link.attributes ? toAttributes(link.attributes) : [],
2553
+ spanId: encoder.encodeSpanContext(link.context.spanId),
2554
+ traceId: encoder.encodeSpanContext(link.context.traceId),
2555
+ traceState: _optionalChain([link, 'access', _35 => _35.context, 'access', _36 => _36.traceState, 'optionalAccess', _37 => _37.serialize, 'call', _38 => _38()]),
2556
+ droppedAttributesCount: link.droppedAttributesCount || 0
2557
+ };
2558
+ }
2559
+ function toOtlpSpanEvent(timedEvent, encoder) {
2560
+ return {
2561
+ attributes: timedEvent.attributes ? toAttributes(timedEvent.attributes) : [],
2562
+ name: timedEvent.name,
2563
+ timeUnixNano: encoder.encodeHrTime(timedEvent.time),
2564
+ droppedAttributesCount: timedEvent.droppedAttributesCount || 0
2565
+ };
2566
+ }
2567
+ function createExportTraceServiceRequest(spans, options) {
2568
+ const encoder = getOtlpEncoder(options);
2569
+ return {
2570
+ resourceSpans: spanRecordsToResourceSpans(spans, encoder)
2571
+ };
2572
+ }
2573
+ function createResourceMap(readableSpans) {
2574
+ const resourceMap = /* @__PURE__ */ new Map();
2575
+ for (const record of readableSpans) {
2576
+ let ilsMap = resourceMap.get(record.resource);
2577
+ if (!ilsMap) {
2578
+ ilsMap = /* @__PURE__ */ new Map();
2579
+ resourceMap.set(record.resource, ilsMap);
2580
+ }
2581
+ const instrumentationScopeKey = `${record.instrumentationScope.name}@${record.instrumentationScope.version || ""}:${record.instrumentationScope.schemaUrl || ""}`;
2582
+ let records = ilsMap.get(instrumentationScopeKey);
2583
+ if (!records) {
2584
+ records = [];
2585
+ ilsMap.set(instrumentationScopeKey, records);
2586
+ }
2587
+ records.push(record);
2588
+ }
2589
+ return resourceMap;
2590
+ }
2591
+ function spanRecordsToResourceSpans(readableSpans, encoder) {
2592
+ const resourceMap = createResourceMap(readableSpans);
2593
+ const out = [];
2594
+ const entryIterator = resourceMap.entries();
2595
+ let entry = entryIterator.next();
2596
+ while (!entry.done) {
2597
+ const [resource, ilmMap] = entry.value;
2598
+ const scopeResourceSpans = [];
2599
+ const ilmIterator = ilmMap.values();
2600
+ let ilmEntry = ilmIterator.next();
2601
+ while (!ilmEntry.done) {
2602
+ const scopeSpans = ilmEntry.value;
2603
+ if (scopeSpans.length > 0) {
2604
+ const spans = scopeSpans.map((readableSpan) => sdkSpanToOtlpSpan(readableSpan, encoder));
2605
+ scopeResourceSpans.push({
2606
+ scope: createInstrumentationScope(scopeSpans[0].instrumentationScope),
2607
+ spans,
2608
+ schemaUrl: scopeSpans[0].instrumentationScope.schemaUrl
2609
+ });
2610
+ }
2611
+ ilmEntry = ilmIterator.next();
2612
+ }
2613
+ const transformedSpans = {
2614
+ resource: createResource(resource),
2615
+ scopeSpans: scopeResourceSpans,
2616
+ schemaUrl: void 0
2617
+ };
2618
+ out.push(transformedSpans);
2619
+ entry = entryIterator.next();
2620
+ }
2621
+ return out;
2622
+ }
2623
+ var init_internal2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2624
+ "../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js"() {
2625
+ "use strict";
2626
+ init_internal();
2627
+ init_utils3();
2628
+ }
2629
+ });
2630
+
2631
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js
2632
+ var JsonTraceSerializer;
2633
+ var init_trace2 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2634
+ "../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js"() {
2635
+ "use strict";
2636
+ init_internal2();
2637
+ JsonTraceSerializer = {
2638
+ serializeRequest: (arg) => {
2639
+ const request3 = createExportTraceServiceRequest(arg, {
2640
+ useHex: true,
2641
+ useLongBits: false
2642
+ });
2643
+ const encoder = new TextEncoder();
2644
+ return encoder.encode(JSON.stringify(request3));
2645
+ },
2646
+ deserializeResponse: (arg) => {
2647
+ const decoder = new TextDecoder();
2648
+ return JSON.parse(decoder.decode(arg));
2649
+ }
2650
+ };
2651
+ }
2652
+ });
2653
+
2654
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js
2655
+ var init_json = _chunkCDBUTZMHjs.__esm.call(void 0, {
2656
+ "../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js"() {
2657
+ "use strict";
2658
+ init_trace2();
2659
+ }
2660
+ });
2661
+
2662
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/index.js
2663
+ var init_esm8 = _chunkCDBUTZMHjs.__esm.call(void 0, {
2664
+ "../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/index.js"() {
2665
+ "use strict";
2666
+ init_json();
2667
+ }
2668
+ });
2669
+
2670
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js
2671
+ function isExportRetryable(statusCode) {
2672
+ const retryCodes = [429, 502, 503, 504];
2673
+ return retryCodes.includes(statusCode);
2674
+ }
2675
+ function parseRetryAfterToMills(retryAfter) {
2676
+ if (retryAfter == null) {
2677
+ return void 0;
2678
+ }
2679
+ const seconds = Number.parseInt(retryAfter, 10);
2680
+ if (Number.isInteger(seconds)) {
2681
+ return seconds > 0 ? seconds * 1e3 : -1;
2682
+ }
2683
+ const delay = new Date(retryAfter).getTime() - Date.now();
2684
+ if (delay >= 0) {
2685
+ return delay;
2686
+ }
2687
+ return 0;
2688
+ }
2689
+ var init_is_export_retryable = _chunkCDBUTZMHjs.__esm.call(void 0, {
2690
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js"() {
2691
+ "use strict";
2692
+ }
2693
+ });
2694
+
2695
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
2696
+ var http_transport_utils_exports = {};
2697
+ _chunkCDBUTZMHjs.__export.call(void 0, http_transport_utils_exports, {
2698
+ compressAndSend: () => compressAndSend,
2699
+ createHttpAgent: () => createHttpAgent,
2700
+ sendWithHttp: () => sendWithHttp
2701
+ });
2702
+ var _http = require('http'); var http = _interopRequireWildcard(_http);
2703
+ var _https = require('https'); var https = _interopRequireWildcard(_https);
2704
+ var _zlib = require('zlib'); var zlib2 = _interopRequireWildcard(_zlib); var zlib = _interopRequireWildcard(_zlib);
2705
+ var _stream = require('stream');
2706
+ function sendWithHttp(params, agent, data, onDone, timeoutMillis) {
2707
+ const parsedUrl = new URL(params.url);
2708
+ const nodeVersion = Number(process.versions.node.split(".")[0]);
2709
+ const options = {
2710
+ hostname: parsedUrl.hostname,
2711
+ port: parsedUrl.port,
2712
+ path: parsedUrl.pathname,
2713
+ method: "POST",
2714
+ headers: {
2715
+ ...params.headers()
2716
+ },
2717
+ agent
2718
+ };
2719
+ const request3 = parsedUrl.protocol === "http:" ? http.request : https.request;
2720
+ const req = request3(options, (res) => {
2721
+ const responseData = [];
2722
+ res.on("data", (chunk) => responseData.push(chunk));
2723
+ res.on("end", () => {
2724
+ if (res.statusCode && res.statusCode < 299) {
2725
+ onDone({
2726
+ status: "success",
2727
+ data: Buffer.concat(responseData)
2728
+ });
2729
+ } else if (res.statusCode && isExportRetryable(res.statusCode)) {
2730
+ onDone({
2731
+ status: "retryable",
2732
+ retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
2733
+ });
2734
+ } else {
2735
+ const error2 = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
2736
+ onDone({
2737
+ status: "failure",
2738
+ error: error2
2739
+ });
2740
+ }
2741
+ });
2742
+ });
2743
+ req.setTimeout(timeoutMillis, () => {
2744
+ req.destroy();
2745
+ onDone({
2746
+ status: "failure",
2747
+ error: new Error("Request Timeout")
2748
+ });
2749
+ });
2750
+ req.on("error", (error2) => {
2751
+ onDone({
2752
+ status: "failure",
2753
+ error: error2
2754
+ });
2755
+ });
2756
+ const reportTimeoutErrorEvent = nodeVersion >= 14 ? "close" : "abort";
2757
+ req.on(reportTimeoutErrorEvent, () => {
2758
+ onDone({
2759
+ status: "failure",
2760
+ error: new Error("Request timed out")
2761
+ });
2762
+ });
2763
+ compressAndSend(req, params.compression, data, (error2) => {
2764
+ onDone({
2765
+ status: "failure",
2766
+ error: error2
2767
+ });
2768
+ });
2769
+ }
2770
+ function compressAndSend(req, compression, data, onError) {
2771
+ let dataStream = readableFromUint8Array(data);
2772
+ if (compression === "gzip") {
2773
+ req.setHeader("Content-Encoding", "gzip");
2774
+ dataStream = dataStream.on("error", onError).pipe(zlib2.createGzip()).on("error", onError);
2775
+ }
2776
+ dataStream.pipe(req).on("error", onError);
2777
+ }
2778
+ function readableFromUint8Array(buff) {
2779
+ const readable = new (0, _stream.Readable)();
2780
+ readable.push(buff);
2781
+ readable.push(null);
2782
+ return readable;
2783
+ }
2784
+ function createHttpAgent(rawUrl, agentOptions) {
2785
+ const parsedUrl = new URL(rawUrl);
2786
+ const Agent3 = parsedUrl.protocol === "http:" ? http.Agent : https.Agent;
2787
+ return new Agent3(agentOptions);
2788
+ }
2789
+ var init_http_transport_utils = _chunkCDBUTZMHjs.__esm.call(void 0, {
2790
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js"() {
2791
+ "use strict";
2792
+ init_is_export_retryable();
2793
+ init_types();
2794
+ }
2795
+ });
2796
+
2797
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js
2798
+ function createHttpExporterTransport(parameters) {
2799
+ return new HttpExporterTransport(parameters);
2800
+ }
2801
+ var HttpExporterTransport;
2802
+ var init_http_exporter_transport = _chunkCDBUTZMHjs.__esm.call(void 0, {
2803
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js"() {
2804
+ "use strict";
2805
+ HttpExporterTransport = (_class10 = class {
2806
+
2807
+ __init24() {this._utils = null}
2808
+ constructor(_parameters) {;_class10.prototype.__init24.call(this);
2809
+ this._parameters = _parameters;
2810
+ }
2811
+ async send(data, timeoutMillis) {
2812
+ const { agent, send } = this._loadUtils();
2813
+ return new Promise((resolve) => {
2814
+ send(this._parameters, agent, data, (result) => {
2815
+ resolve(result);
2816
+ }, timeoutMillis);
2817
+ });
2818
+ }
2819
+ shutdown() {
2820
+ }
2821
+ _loadUtils() {
2822
+ let utils = this._utils;
2823
+ if (utils === null) {
2824
+ const {
2825
+ sendWithHttp: sendWithHttp2,
2826
+ createHttpAgent: createHttpAgent2
2827
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2828
+ } = (init_http_transport_utils(), _chunkCDBUTZMHjs.__toCommonJS.call(void 0, http_transport_utils_exports));
2829
+ utils = this._utils = {
2830
+ agent: createHttpAgent2(this._parameters.url, this._parameters.agentOptions),
2831
+ send: sendWithHttp2
2832
+ };
2833
+ }
2834
+ return utils;
2835
+ }
2836
+ }, _class10);
2837
+ }
2838
+ });
2839
+
2840
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js
2841
+ function getJitter() {
2842
+ return Math.random() * (2 * JITTER) - JITTER;
2843
+ }
2844
+ function createRetryingTransport(options) {
2845
+ return new RetryingTransport(options.transport);
2846
+ }
2847
+ var MAX_ATTEMPTS, INITIAL_BACKOFF, MAX_BACKOFF, BACKOFF_MULTIPLIER, JITTER, RetryingTransport;
2848
+ var init_retrying_transport = _chunkCDBUTZMHjs.__esm.call(void 0, {
2849
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js"() {
2850
+ "use strict";
2851
+ MAX_ATTEMPTS = 5;
2852
+ INITIAL_BACKOFF = 1e3;
2853
+ MAX_BACKOFF = 5e3;
2854
+ BACKOFF_MULTIPLIER = 1.5;
2855
+ JITTER = 0.2;
2856
+ RetryingTransport = class {
2857
+
2858
+ constructor(_transport) {
2859
+ this._transport = _transport;
2860
+ }
2861
+ retry(data, timeoutMillis, inMillis) {
2862
+ return new Promise((resolve, reject2) => {
2863
+ setTimeout(() => {
2864
+ this._transport.send(data, timeoutMillis).then(resolve, reject2);
2865
+ }, inMillis);
2866
+ });
2867
+ }
2868
+ async send(data, timeoutMillis) {
2869
+ const deadline = Date.now() + timeoutMillis;
2870
+ let result = await this._transport.send(data, timeoutMillis);
2871
+ let attempts = MAX_ATTEMPTS;
2872
+ let nextBackoff = INITIAL_BACKOFF;
2873
+ while (result.status === "retryable" && attempts > 0) {
2874
+ attempts--;
2875
+ const backoff = Math.max(Math.min(nextBackoff, MAX_BACKOFF) + getJitter(), 0);
2876
+ nextBackoff = nextBackoff * BACKOFF_MULTIPLIER;
2877
+ const retryInMillis = _nullishCoalesce(result.retryInMillis, () => ( backoff));
2878
+ const remainingTimeoutMillis = deadline - Date.now();
2879
+ if (retryInMillis > remainingTimeoutMillis) {
2880
+ return result;
2881
+ }
2882
+ result = await this.retry(data, remainingTimeoutMillis, retryInMillis);
2883
+ }
2884
+ return result;
2885
+ }
2886
+ shutdown() {
2887
+ return this._transport.shutdown();
2888
+ }
2889
+ };
2890
+ }
2891
+ });
2892
+
2893
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js
2894
+ function createOtlpHttpExportDelegate(options, serializer) {
2895
+ return createOtlpExportDelegate({
2896
+ transport: createRetryingTransport({
2897
+ transport: createHttpExporterTransport(options)
2898
+ }),
2899
+ serializer,
2900
+ promiseHandler: createBoundedQueueExportPromiseHandler(options)
2901
+ }, { timeout: options.timeoutMillis });
2902
+ }
2903
+ var init_otlp_http_export_delegate = _chunkCDBUTZMHjs.__esm.call(void 0, {
2904
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js"() {
2905
+ "use strict";
2906
+ init_otlp_export_delegate();
2907
+ init_http_exporter_transport();
2908
+ init_bounded_queue_export_promise_handler();
2909
+ init_retrying_transport();
2910
+ }
2911
+ });
2912
+
2913
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-env-configuration.js
2914
+ function parseAndValidateTimeoutFromEnv(timeoutEnvVar) {
2915
+ const envTimeout = _optionalChain([process, 'access', _39 => _39.env, 'access', _40 => _40[timeoutEnvVar], 'optionalAccess', _41 => _41.trim, 'call', _42 => _42()]);
2916
+ if (envTimeout != null && envTimeout !== "") {
2917
+ const definedTimeout = Number(envTimeout);
2918
+ if (Number.isFinite(definedTimeout) && definedTimeout > 0) {
2919
+ return definedTimeout;
2920
+ }
2921
+ _chunkCDBUTZMHjs.diag.warn(`Configuration: ${timeoutEnvVar} is invalid, expected number greater than 0 (actual: ${envTimeout})`);
2922
+ }
2923
+ return void 0;
2924
+ }
2925
+ function getTimeoutFromEnv(signalIdentifier) {
2926
+ const specificTimeout = parseAndValidateTimeoutFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_TIMEOUT`);
2927
+ const nonSpecificTimeout = parseAndValidateTimeoutFromEnv("OTEL_EXPORTER_OTLP_TIMEOUT");
2928
+ return _nullishCoalesce(specificTimeout, () => ( nonSpecificTimeout));
2929
+ }
2930
+ function parseAndValidateCompressionFromEnv(compressionEnvVar) {
2931
+ const compression = _optionalChain([process, 'access', _43 => _43.env, 'access', _44 => _44[compressionEnvVar], 'optionalAccess', _45 => _45.trim, 'call', _46 => _46()]);
2932
+ if (compression === "") {
2933
+ return void 0;
2934
+ }
2935
+ if (compression == null || compression === "none" || compression === "gzip") {
2936
+ return compression;
2937
+ }
2938
+ _chunkCDBUTZMHjs.diag.warn(`Configuration: ${compressionEnvVar} is invalid, expected 'none' or 'gzip' (actual: '${compression}')`);
2939
+ return void 0;
2940
+ }
2941
+ function getCompressionFromEnv(signalIdentifier) {
2942
+ const specificCompression = parseAndValidateCompressionFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_COMPRESSION`);
2943
+ const nonSpecificCompression = parseAndValidateCompressionFromEnv("OTEL_EXPORTER_OTLP_COMPRESSION");
2944
+ return _nullishCoalesce(specificCompression, () => ( nonSpecificCompression));
2945
+ }
2946
+ function getSharedConfigurationFromEnvironment(signalIdentifier) {
2947
+ return {
2948
+ timeoutMillis: getTimeoutFromEnv(signalIdentifier),
2949
+ compression: getCompressionFromEnv(signalIdentifier)
2950
+ };
2951
+ }
2952
+ var init_shared_env_configuration = _chunkCDBUTZMHjs.__esm.call(void 0, {
2953
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-env-configuration.js"() {
2954
+ "use strict";
2955
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
2956
+ }
2957
+ });
2958
+
2959
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js
2960
+ function validateAndNormalizeHeaders(partialHeaders) {
2961
+ return () => {
2962
+ const headers = {};
2963
+ Object.entries(_nullishCoalesce(_optionalChain([partialHeaders, 'optionalCall', _47 => _47()]), () => ( {}))).forEach(([key, value]) => {
2964
+ if (typeof value !== "undefined") {
2965
+ headers[key] = String(value);
2966
+ } else {
2967
+ _chunkCDBUTZMHjs.diag.warn(`Header "${key}" has invalid value (${value}) and will be ignored`);
2968
+ }
2969
+ });
2970
+ return headers;
2971
+ };
2972
+ }
2973
+ var init_util = _chunkCDBUTZMHjs.__esm.call(void 0, {
2974
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js"() {
2975
+ "use strict";
2976
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
2977
+ }
2978
+ });
2979
+
2980
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js
2981
+ function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
2982
+ const requiredHeaders = {
2983
+ ...defaultHeaders()
2984
+ };
2985
+ const headers = {};
2986
+ return () => {
2987
+ if (fallbackHeaders != null) {
2988
+ Object.assign(headers, fallbackHeaders());
2989
+ }
2990
+ if (userProvidedHeaders != null) {
2991
+ Object.assign(headers, userProvidedHeaders());
2992
+ }
2993
+ return Object.assign(headers, requiredHeaders);
2994
+ };
2995
+ }
2996
+ function validateUserProvidedUrl(url) {
2997
+ if (url == null) {
2998
+ return void 0;
2999
+ }
3000
+ try {
3001
+ new URL(url);
3002
+ return url;
3003
+ } catch (e) {
3004
+ throw new Error(`Configuration: Could not parse user-provided export URL: '${url}'`);
3005
+ }
3006
+ }
3007
+ function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
3008
+ return {
3009
+ ...mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
3010
+ headers: mergeHeaders(validateAndNormalizeHeaders(userProvidedConfiguration.headers), fallbackConfiguration.headers, defaultConfiguration.headers),
3011
+ url: _nullishCoalesce(_nullishCoalesce(validateUserProvidedUrl(userProvidedConfiguration.url), () => ( fallbackConfiguration.url)), () => ( defaultConfiguration.url)),
3012
+ agentOptions: _nullishCoalesce(_nullishCoalesce(userProvidedConfiguration.agentOptions, () => ( fallbackConfiguration.agentOptions)), () => ( defaultConfiguration.agentOptions))
3013
+ };
3014
+ }
3015
+ function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
3016
+ return {
3017
+ ...getSharedConfigurationDefaults(),
3018
+ headers: () => requiredHeaders,
3019
+ url: "http://localhost:4318/" + signalResourcePath,
3020
+ agentOptions: { keepAlive: true }
3021
+ };
3022
+ }
3023
+ var init_otlp_http_configuration = _chunkCDBUTZMHjs.__esm.call(void 0, {
3024
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js"() {
3025
+ "use strict";
3026
+ init_shared_configuration();
3027
+ init_util();
3028
+ }
3029
+ });
3030
+
3031
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-env-configuration.js
3032
+ function getStaticHeadersFromEnv(signalIdentifier) {
3033
+ const signalSpecificRawHeaders = _optionalChain([process, 'access', _48 => _48.env, 'access', _49 => _49[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`], 'optionalAccess', _50 => _50.trim, 'call', _51 => _51()]);
3034
+ const nonSignalSpecificRawHeaders = _optionalChain([process, 'access', _52 => _52.env, 'access', _53 => _53["OTEL_EXPORTER_OTLP_HEADERS"], 'optionalAccess', _54 => _54.trim, 'call', _55 => _55()]);
3035
+ const signalSpecificHeaders = parseKeyPairsIntoRecord(signalSpecificRawHeaders);
3036
+ const nonSignalSpecificHeaders = parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
3037
+ if (Object.keys(signalSpecificHeaders).length === 0 && Object.keys(nonSignalSpecificHeaders).length === 0) {
3038
+ return void 0;
3039
+ }
3040
+ return Object.assign({}, parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders), parseKeyPairsIntoRecord(signalSpecificRawHeaders));
3041
+ }
3042
+ function appendRootPathToUrlIfNeeded(url) {
3043
+ try {
3044
+ const parsedUrl = new URL(url);
3045
+ return parsedUrl.toString();
3046
+ } catch (e3) {
3047
+ _chunkCDBUTZMHjs.diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
3048
+ return void 0;
3049
+ }
3050
+ }
3051
+ function appendResourcePathToUrl(url, path3) {
3052
+ try {
3053
+ new URL(url);
3054
+ } catch (e4) {
3055
+ _chunkCDBUTZMHjs.diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
3056
+ return void 0;
3057
+ }
3058
+ if (!url.endsWith("/")) {
3059
+ url = url + "/";
3060
+ }
3061
+ url += path3;
3062
+ try {
3063
+ new URL(url);
3064
+ } catch (e5) {
3065
+ _chunkCDBUTZMHjs.diag.warn(`Configuration: Provided URL appended with '${path3}' is not a valid URL, using 'undefined' instead of '${url}'`);
3066
+ return void 0;
3067
+ }
3068
+ return url;
3069
+ }
3070
+ function getNonSpecificUrlFromEnv(signalResourcePath) {
3071
+ const envUrl = _optionalChain([process, 'access', _56 => _56.env, 'access', _57 => _57.OTEL_EXPORTER_OTLP_ENDPOINT, 'optionalAccess', _58 => _58.trim, 'call', _59 => _59()]);
3072
+ if (envUrl == null || envUrl === "") {
3073
+ return void 0;
3074
+ }
3075
+ return appendResourcePathToUrl(envUrl, signalResourcePath);
3076
+ }
3077
+ function getSpecificUrlFromEnv(signalIdentifier) {
3078
+ const envUrl = _optionalChain([process, 'access', _60 => _60.env, 'access', _61 => _61[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`], 'optionalAccess', _62 => _62.trim, 'call', _63 => _63()]);
3079
+ if (envUrl == null || envUrl === "") {
3080
+ return void 0;
3081
+ }
3082
+ return appendRootPathToUrlIfNeeded(envUrl);
3083
+ }
3084
+ function getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath) {
3085
+ return {
3086
+ ...getSharedConfigurationFromEnvironment(signalIdentifier),
3087
+ url: _nullishCoalesce(getSpecificUrlFromEnv(signalIdentifier), () => ( getNonSpecificUrlFromEnv(signalResourcePath))),
3088
+ headers: wrapStaticHeadersInFunction(getStaticHeadersFromEnv(signalIdentifier))
3089
+ };
3090
+ }
3091
+ var init_otlp_http_env_configuration = _chunkCDBUTZMHjs.__esm.call(void 0, {
3092
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-env-configuration.js"() {
3093
+ "use strict";
3094
+ init_esm6();
3095
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
3096
+ init_shared_env_configuration();
3097
+ init_shared_configuration();
3098
+ }
3099
+ });
3100
+
3101
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js
3102
+ function convertLegacyAgentOptions(config) {
3103
+ if (_optionalChain([config, 'optionalAccess', _64 => _64.keepAlive]) != null) {
3104
+ if (config.httpAgentOptions != null) {
3105
+ if (config.httpAgentOptions.keepAlive == null) {
3106
+ config.httpAgentOptions.keepAlive = config.keepAlive;
3107
+ }
3108
+ } else {
3109
+ config.httpAgentOptions = {
3110
+ keepAlive: config.keepAlive
3111
+ };
3112
+ }
3113
+ }
3114
+ return config.httpAgentOptions;
3115
+ }
3116
+ function convertLegacyHttpOptions(config, signalIdentifier, signalResourcePath, requiredHeaders) {
3117
+ if (config.metadata) {
3118
+ _chunkCDBUTZMHjs.diag.warn("Metadata cannot be set when using http");
3119
+ }
3120
+ return mergeOtlpHttpConfigurationWithDefaults({
3121
+ url: config.url,
3122
+ headers: wrapStaticHeadersInFunction(config.headers),
3123
+ concurrencyLimit: config.concurrencyLimit,
3124
+ timeoutMillis: config.timeoutMillis,
3125
+ compression: config.compression,
3126
+ agentOptions: convertLegacyAgentOptions(config)
3127
+ }, getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
3128
+ }
3129
+ var init_convert_legacy_node_http_options = _chunkCDBUTZMHjs.__esm.call(void 0, {
3130
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js"() {
3131
+ "use strict";
3132
+ init_otlp_http_configuration();
3133
+ init_otlp_http_env_configuration();
3134
+ _chunkCDBUTZMHjs.init_esm.call(void 0, );
3135
+ init_shared_configuration();
3136
+ }
3137
+ });
3138
+
3139
+ // ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js
3140
+ var init_index_node_http = _chunkCDBUTZMHjs.__esm.call(void 0, {
3141
+ "../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js"() {
3142
+ "use strict";
3143
+ init_otlp_http_export_delegate();
3144
+ init_convert_legacy_node_http_options();
3145
+ }
3146
+ });
3147
+
3148
+ // ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js
3149
+ var OTLPTraceExporter;
3150
+ var init_OTLPTraceExporter = _chunkCDBUTZMHjs.__esm.call(void 0, {
3151
+ "../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js"() {
3152
+ "use strict";
3153
+ init_esm7();
3154
+ init_version2();
3155
+ init_esm8();
3156
+ init_index_node_http();
3157
+ OTLPTraceExporter = class extends OTLPExporterBase {
3158
+ constructor(config = {}) {
3159
+ super(createOtlpHttpExportDelegate(convertLegacyHttpOptions(config, "TRACES", "v1/traces", {
3160
+ "User-Agent": `OTel-OTLP-Exporter-JavaScript/${VERSION2}`,
3161
+ "Content-Type": "application/json"
3162
+ }), JsonTraceSerializer));
3163
+ }
3164
+ };
3165
+ }
3166
+ });
3167
+
3168
+ // ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js
3169
+ var init_node4 = _chunkCDBUTZMHjs.__esm.call(void 0, {
3170
+ "../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js"() {
3171
+ "use strict";
3172
+ init_OTLPTraceExporter();
3173
+ }
3174
+ });
3175
+
3176
+ // ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js
3177
+ var init_platform4 = _chunkCDBUTZMHjs.__esm.call(void 0, {
3178
+ "../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js"() {
3179
+ "use strict";
3180
+ init_node4();
3181
+ }
3182
+ });
3183
+
3184
+ // ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js
3185
+ var esm_exports3 = {};
3186
+ _chunkCDBUTZMHjs.__export.call(void 0, esm_exports3, {
3187
+ OTLPTraceExporter: () => OTLPTraceExporter
3188
+ });
3189
+ var init_esm9 = _chunkCDBUTZMHjs.__esm.call(void 0, {
3190
+ "../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js"() {
3191
+ "use strict";
3192
+ init_platform4();
3193
+ }
3194
+ });
6
3195
 
7
3196
  // src/node.ts
8
3197
  var _async_hooks = require('async_hooks');
@@ -57,7 +3246,7 @@ async function getBaseBranch(remote = void 0) {
57
3246
  if (git === null) {
58
3247
  throw new Error("Not in a git repo");
59
3248
  }
60
- const remoteName = await _asyncNullishCoalesce(remote, async () => ( await _asyncOptionalChain([(await git.getRemotes()), 'access', async _2 => _2[0], 'optionalAccess', async _3 => _3.name])));
3249
+ const remoteName = await _asyncNullishCoalesce(remote, async () => ( await _asyncOptionalChain([(await git.getRemotes()), 'access', async _65 => _65[0], 'optionalAccess', async _66 => _66.name])));
61
3250
  if (!remoteName) {
62
3251
  throw new Error("No remote found");
63
3252
  }
@@ -79,7 +3268,7 @@ async function getBaseBranch(remote = void 0) {
79
3268
  throw new Error(`Could not find HEAD branch in remote ${remoteName}`);
80
3269
  }
81
3270
  branch = match[1];
82
- } catch (e2) {
3271
+ } catch (e6) {
83
3272
  branch = "main";
84
3273
  }
85
3274
  }
@@ -106,7 +3295,7 @@ async function getBaseBranchAncestor(remote = void 0) {
106
3295
  return void 0;
107
3296
  }
108
3297
  }
109
- async function getPastNAncestors(n = 10, remote = void 0) {
3298
+ async function getPastNAncestors(n = 1e3, remote = void 0) {
110
3299
  const git = await currentRepo();
111
3300
  if (git === null) {
112
3301
  return [];
@@ -123,7 +3312,7 @@ async function getPastNAncestors(n = 10, remote = void 0) {
123
3312
  if (!ancestor) {
124
3313
  return [];
125
3314
  }
126
- const commits = await git.log({ from: ancestor, to: "HEAD" });
3315
+ const commits = await git.log({ from: ancestor, to: "HEAD", maxCount: n });
127
3316
  return commits.all.map((c) => c.hash);
128
3317
  }
129
3318
  async function attempt(fn) {
@@ -150,7 +3339,7 @@ async function getRepoInfo(settings) {
150
3339
  return repo;
151
3340
  }
152
3341
  let sanitized = {};
153
- _optionalChain([settings, 'access', _4 => _4.fields, 'optionalAccess', _5 => _5.forEach, 'call', _6 => _6((field) => {
3342
+ _optionalChain([settings, 'access', _67 => _67.fields, 'optionalAccess', _68 => _68.forEach, 'call', _69 => _69((field) => {
154
3343
  sanitized = { ...sanitized, [field]: repo[field] };
155
3344
  })]);
156
3345
  return sanitized;
@@ -208,11 +3397,11 @@ async function repoInfo() {
208
3397
 
209
3398
  // src/stackutil.ts
210
3399
  function getStackTrace() {
211
- const trace = new Error().stack;
212
- if (typeof trace !== "string") {
3400
+ const trace2 = new Error().stack;
3401
+ if (typeof trace2 !== "string") {
213
3402
  return [];
214
3403
  }
215
- const traceLines = trace.split("\n");
3404
+ const traceLines = trace2.split("\n");
216
3405
  const out = [];
217
3406
  const stackFrameRegex = /at(.*)\((.*):(\d+):(\d+)\)/;
218
3407
  for (const traceLine of traceLines.slice(1)) {
@@ -236,9 +3425,9 @@ function getCallerLocation() {
236
3425
  const entries = getStackTrace();
237
3426
  for (const frame of entries) {
238
3427
  if (thisDir === void 0) {
239
- thisDir = _optionalChain([isomorph_default, 'access', _7 => _7.pathDirname, 'optionalCall', _8 => _8(frame.fileName)]);
3428
+ thisDir = _optionalChain([isomorph_default, 'access', _70 => _70.pathDirname, 'optionalCall', _71 => _71(frame.fileName)]);
240
3429
  }
241
- if (_optionalChain([isomorph_default, 'access', _9 => _9.pathDirname, 'optionalCall', _10 => _10(frame.fileName)]) !== thisDir) {
3430
+ if (_optionalChain([isomorph_default, 'access', _72 => _72.pathDirname, 'optionalCall', _73 => _73(frame.fileName)]) !== thisDir) {
242
3431
  return {
243
3432
  caller_functionname: frame.functionName,
244
3433
  caller_filename: frame.fileName,
@@ -254,11 +3443,11 @@ var _uuid = require('uuid');
254
3443
 
255
3444
  // src/queue.ts
256
3445
  var DEFAULT_QUEUE_SIZE = 15e3;
257
- var Queue = (_class = class {
258
- __init() {this.items = []}
3446
+ var Queue = (_class11 = class {
3447
+ __init25() {this.items = []}
259
3448
 
260
- __init2() {this.enforceSizeLimit = false}
261
- constructor(maxSize) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
3449
+ __init26() {this.enforceSizeLimit = false}
3450
+ constructor(maxSize) {;_class11.prototype.__init25.call(this);_class11.prototype.__init26.call(this);
262
3451
  if (maxSize < 1) {
263
3452
  console.warn(
264
3453
  `maxSize ${maxSize} is <1, using default ${DEFAULT_QUEUE_SIZE}`
@@ -306,7 +3495,7 @@ var Queue = (_class = class {
306
3495
  get capacity() {
307
3496
  return this.maxSize;
308
3497
  }
309
- }, _class);
3498
+ }, _class11);
310
3499
 
311
3500
  // src/logger.ts
312
3501
 
@@ -902,13 +4091,13 @@ function getCurrentUnixTimestamp() {
902
4091
  function isEmpty(a) {
903
4092
  return a === void 0 || a === null;
904
4093
  }
905
- var LazyValue = (_class2 = class {
4094
+ var LazyValue = (_class12 = class {
906
4095
 
907
- __init3() {this.resolvedValue = void 0}
908
- __init4() {this.value = {
4096
+ __init27() {this.resolvedValue = void 0}
4097
+ __init28() {this.value = {
909
4098
  computedState: "uninitialized"
910
4099
  }}
911
- constructor(callable) {;_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);
4100
+ constructor(callable) {;_class12.prototype.__init27.call(this);_class12.prototype.__init28.call(this);
912
4101
  this.callable = callable;
913
4102
  }
914
4103
  get() {
@@ -936,13 +4125,13 @@ var LazyValue = (_class2 = class {
936
4125
  get hasSucceeded() {
937
4126
  return this.value.computedState === "succeeded";
938
4127
  }
939
- }, _class2);
940
- var SyncLazyValue = (_class3 = class {
4128
+ }, _class12);
4129
+ var SyncLazyValue = (_class13 = class {
941
4130
 
942
- __init5() {this.value = {
4131
+ __init29() {this.value = {
943
4132
  computedState: "uninitialized"
944
4133
  }}
945
- constructor(callable) {;_class3.prototype.__init5.call(this);
4134
+ constructor(callable) {;_class13.prototype.__init29.call(this);
946
4135
  this.callable = callable;
947
4136
  }
948
4137
  get() {
@@ -958,7 +4147,7 @@ var SyncLazyValue = (_class3 = class {
958
4147
  get hasSucceeded() {
959
4148
  return this.value.computedState === "succeeded";
960
4149
  }
961
- }, _class3);
4150
+ }, _class13);
962
4151
  function addAzureBlobHeaders(headers, url) {
963
4152
  if (url.includes("blob.core.windows.net")) {
964
4153
  headers["x-ms-blob-type"] = "BlockBlob";
@@ -986,11 +4175,11 @@ function objectIsEmpty(obj) {
986
4175
  // src/mustache-utils.ts
987
4176
 
988
4177
 
989
- function lintTemplate(template, context) {
4178
+ function lintTemplate(template, context2) {
990
4179
  const variables = getMustacheVars(template);
991
4180
  for (const variable of variables) {
992
4181
  const arrPathsReplaced = variable[1].replaceAll(/\.\d+/g, ".0");
993
- const fieldExists = _core.getObjValueByPath.call(void 0, context, arrPathsReplaced.split(".")) !== void 0;
4182
+ const fieldExists = _core.getObjValueByPath.call(void 0, context2, arrPathsReplaced.split(".")) !== void 0;
994
4183
  if (!fieldExists) {
995
4184
  throw new Error(`Variable '${variable[1]}' does not exist.`);
996
4185
  }
@@ -1001,19 +4190,19 @@ function getMustacheVars(prompt) {
1001
4190
  return _mustache2.default.parse(prompt).filter(
1002
4191
  (span) => span[0] === "name" || span[0] === "&"
1003
4192
  );
1004
- } catch (e3) {
4193
+ } catch (e7) {
1005
4194
  return [];
1006
4195
  }
1007
4196
  }
1008
4197
 
1009
4198
  // src/logger.ts
1010
- var NoopSpan = (_class4 = class {
4199
+ var NoopSpan = (_class14 = class {
1011
4200
 
1012
4201
 
1013
4202
 
1014
4203
 
1015
- __init6() {this.kind = "span"}
1016
- constructor() {;_class4.prototype.__init6.call(this);
4204
+ __init30() {this.kind = "span"}
4205
+ constructor() {;_class14.prototype.__init30.call(this);
1017
4206
  this.id = "";
1018
4207
  this.spanId = "";
1019
4208
  this.rootSpanId = "";
@@ -1030,7 +4219,7 @@ var NoopSpan = (_class4 = class {
1030
4219
  return this;
1031
4220
  }
1032
4221
  end(args) {
1033
- return _nullishCoalesce(_optionalChain([args, 'optionalAccess', _11 => _11.endTime]), () => ( getCurrentUnixTimestamp()));
4222
+ return _nullishCoalesce(_optionalChain([args, 'optionalAccess', _74 => _74.endTime]), () => ( getCurrentUnixTimestamp()));
1034
4223
  }
1035
4224
  async export() {
1036
4225
  return "";
@@ -1054,7 +4243,7 @@ var NoopSpan = (_class4 = class {
1054
4243
  state() {
1055
4244
  return _internalGetGlobalState();
1056
4245
  }
1057
- }, _class4);
4246
+ }, _class14);
1058
4247
  var NOOP_SPAN = new NoopSpan();
1059
4248
  var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
1060
4249
  var loginSchema = _zod.z.strictObject({
@@ -1068,8 +4257,8 @@ var loginSchema = _zod.z.strictObject({
1068
4257
  gitMetadataSettings: _typespecs.gitMetadataSettingsSchema.nullish()
1069
4258
  });
1070
4259
  var stateNonce = 0;
1071
- var BraintrustState = (_class5 = class _BraintrustState {
1072
- constructor(loginParams) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);
4260
+ var BraintrustState = (_class15 = class _BraintrustState {
4261
+ constructor(loginParams) {;_class15.prototype.__init31.call(this);_class15.prototype.__init32.call(this);_class15.prototype.__init33.call(this);_class15.prototype.__init34.call(this);_class15.prototype.__init35.call(this);_class15.prototype.__init36.call(this);_class15.prototype.__init37.call(this);_class15.prototype.__init38.call(this);_class15.prototype.__init39.call(this);_class15.prototype.__init40.call(this);_class15.prototype.__init41.call(this);_class15.prototype.__init42.call(this);_class15.prototype.__init43.call(this);
1073
4262
  this.loginParams = loginParams;
1074
4263
  this.id = `${(/* @__PURE__ */ new Date()).toLocaleString()}-${stateNonce++}`;
1075
4264
  this.currentExperiment = void 0;
@@ -1108,20 +4297,20 @@ var BraintrustState = (_class5 = class _BraintrustState {
1108
4297
  // possibility of multiple loggers floating around, which may not log in a
1109
4298
  // deterministic order.
1110
4299
 
1111
- __init7() {this._overrideBgLogger = null}
1112
- __init8() {this.appUrl = null}
1113
- __init9() {this.appPublicUrl = null}
1114
- __init10() {this.loginToken = null}
1115
- __init11() {this.orgId = null}
1116
- __init12() {this.orgName = null}
1117
- __init13() {this.apiUrl = null}
1118
- __init14() {this.proxyUrl = null}
1119
- __init15() {this.loggedIn = false}
4300
+ __init31() {this._overrideBgLogger = null}
4301
+ __init32() {this.appUrl = null}
4302
+ __init33() {this.appPublicUrl = null}
4303
+ __init34() {this.loginToken = null}
4304
+ __init35() {this.orgId = null}
4305
+ __init36() {this.orgName = null}
4306
+ __init37() {this.apiUrl = null}
4307
+ __init38() {this.proxyUrl = null}
4308
+ __init39() {this.loggedIn = false}
1120
4309
 
1121
- __init16() {this.fetch = globalThis.fetch}
1122
- __init17() {this._appConn = null}
1123
- __init18() {this._apiConn = null}
1124
- __init19() {this._proxyConn = null}
4310
+ __init40() {this.fetch = globalThis.fetch}
4311
+ __init41() {this._appConn = null}
4312
+ __init42() {this._apiConn = null}
4313
+ __init43() {this._proxyConn = null}
1125
4314
 
1126
4315
  resetLoginInfo() {
1127
4316
  this.appUrl = null;
@@ -1204,8 +4393,8 @@ var BraintrustState = (_class5 = class _BraintrustState {
1204
4393
  setFetch(fetch2) {
1205
4394
  this.loginParams.fetch = fetch2;
1206
4395
  this.fetch = fetch2;
1207
- _optionalChain([this, 'access', _12 => _12._apiConn, 'optionalAccess', _13 => _13.setFetch, 'call', _14 => _14(fetch2)]);
1208
- _optionalChain([this, 'access', _15 => _15._appConn, 'optionalAccess', _16 => _16.setFetch, 'call', _17 => _17(fetch2)]);
4396
+ _optionalChain([this, 'access', _75 => _75._apiConn, 'optionalAccess', _76 => _76.setFetch, 'call', _77 => _77(fetch2)]);
4397
+ _optionalChain([this, 'access', _78 => _78._appConn, 'optionalAccess', _79 => _79.setFetch, 'call', _80 => _80(fetch2)]);
1209
4398
  }
1210
4399
  async login(loginParams) {
1211
4400
  if (this.apiUrl && !loginParams.forceLogin) {
@@ -1271,7 +4460,7 @@ var BraintrustState = (_class5 = class _BraintrustState {
1271
4460
  enforceQueueSizeLimit(enforce) {
1272
4461
  this._bgLogger.get().enforceQueueSizeLimit(enforce);
1273
4462
  }
1274
- }, _class5);
4463
+ }, _class15);
1275
4464
  var _globalState;
1276
4465
  function useTestBackgroundLogger() {
1277
4466
  const state = _internalGetGlobalState();
@@ -1283,7 +4472,7 @@ function useTestBackgroundLogger() {
1283
4472
  return logger;
1284
4473
  }
1285
4474
  function clearTestBackgroundLogger() {
1286
- _optionalChain([_internalGetGlobalState, 'call', _18 => _18(), 'optionalAccess', _19 => _19.setOverrideBgLogger, 'call', _20 => _20(null)]);
4475
+ _optionalChain([_internalGetGlobalState, 'call', _81 => _81(), 'optionalAccess', _82 => _82.setOverrideBgLogger, 'call', _83 => _83(null)]);
1287
4476
  }
1288
4477
  function _internalSetInitialState() {
1289
4478
  if (_globalState) {
@@ -1918,9 +5107,9 @@ async function permalink(slug, opts) {
1918
5107
  if (slug === "") {
1919
5108
  return NOOP_SPAN_PERMALINK;
1920
5109
  }
1921
- const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _21 => _21.state]), () => ( _globalState));
5110
+ const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _84 => _84.state]), () => ( _globalState));
1922
5111
  const getOrgName = async () => {
1923
- if (_optionalChain([opts, 'optionalAccess', _22 => _22.orgName])) {
5112
+ if (_optionalChain([opts, 'optionalAccess', _85 => _85.orgName])) {
1924
5113
  return opts.orgName;
1925
5114
  }
1926
5115
  await state.login({});
@@ -1930,7 +5119,7 @@ async function permalink(slug, opts) {
1930
5119
  return state.orgName;
1931
5120
  };
1932
5121
  const getAppUrl = async () => {
1933
- if (_optionalChain([opts, 'optionalAccess', _23 => _23.appUrl])) {
5122
+ if (_optionalChain([opts, 'optionalAccess', _86 => _86.appUrl])) {
1934
5123
  return opts.appUrl;
1935
5124
  }
1936
5125
  await state.login({});
@@ -2008,7 +5197,7 @@ function startSpanParentArgs(args) {
2008
5197
  propagatedEvent: argPropagatedEvent
2009
5198
  };
2010
5199
  }
2011
- var Logger = (_class6 = class {
5200
+ var Logger = (_class16 = class {
2012
5201
 
2013
5202
 
2014
5203
 
@@ -2017,8 +5206,8 @@ var Logger = (_class6 = class {
2017
5206
 
2018
5207
 
2019
5208
  // For type identification.
2020
- __init20() {this.kind = "logger"}
2021
- constructor(state, lazyMetadata, logOptions = {}) {;_class6.prototype.__init20.call(this);
5209
+ __init44() {this.kind = "logger"}
5210
+ constructor(state, lazyMetadata, logOptions = {}) {;_class16.prototype.__init44.call(this);
2022
5211
  this.lazyMetadata = lazyMetadata;
2023
5212
  this._asyncFlush = logOptions.asyncFlush;
2024
5213
  this.computeMetadataArgs = logOptions.computeMetadataArgs;
@@ -2060,7 +5249,7 @@ var Logger = (_class6 = class {
2060
5249
  * @returns The `id` of the logged event.
2061
5250
  */
2062
5251
  log(event, options) {
2063
- if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _24 => _24.allowConcurrentWithSpans])) {
5252
+ if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _87 => _87.allowConcurrentWithSpans])) {
2064
5253
  throw new Error(
2065
5254
  "Cannot run toplevel `log` method while using spans. To log to the span, call `logger.traced` and then log with `span.log`"
2066
5255
  );
@@ -2128,12 +5317,12 @@ var Logger = (_class6 = class {
2128
5317
  state: this.state,
2129
5318
  ...startSpanParentArgs({
2130
5319
  state: this.state,
2131
- parent: _optionalChain([args, 'optionalAccess', _25 => _25.parent]),
5320
+ parent: _optionalChain([args, 'optionalAccess', _88 => _88.parent]),
2132
5321
  parentObjectType: this.parentObjectType(),
2133
5322
  parentObjectId: this.lazyId,
2134
5323
  parentComputeObjectMetadataArgs: this.computeMetadataArgs,
2135
- parentSpanIds: _optionalChain([args, 'optionalAccess', _26 => _26.parentSpanIds]),
2136
- propagatedEvent: _optionalChain([args, 'optionalAccess', _27 => _27.propagatedEvent])
5324
+ parentSpanIds: _optionalChain([args, 'optionalAccess', _89 => _89.parentSpanIds]),
5325
+ propagatedEvent: _optionalChain([args, 'optionalAccess', _90 => _90.propagatedEvent])
2137
5326
  }),
2138
5327
  defaultRootType: _core.SpanTypeAttribute.TASK
2139
5328
  });
@@ -2191,7 +5380,7 @@ var Logger = (_class6 = class {
2191
5380
  get asyncFlush() {
2192
5381
  return this._asyncFlush;
2193
5382
  }
2194
- }, _class6);
5383
+ }, _class16);
2195
5384
  function castLogger(logger, asyncFlush) {
2196
5385
  if (logger === void 0) return void 0;
2197
5386
  if (asyncFlush !== void 0 && !!asyncFlush !== !!logger.asyncFlush) {
@@ -2207,8 +5396,8 @@ function constructLogs3Data(items) {
2207
5396
  function now() {
2208
5397
  return (/* @__PURE__ */ new Date()).getTime();
2209
5398
  }
2210
- var TestBackgroundLogger = (_class7 = class {constructor() { _class7.prototype.__init21.call(this); }
2211
- __init21() {this.items = []}
5399
+ var TestBackgroundLogger = (_class17 = class {constructor() { _class17.prototype.__init45.call(this); }
5400
+ __init45() {this.items = []}
2212
5401
  log(items) {
2213
5402
  this.items.push(items);
2214
5403
  }
@@ -2227,30 +5416,30 @@ var TestBackgroundLogger = (_class7 = class {constructor() { _class7.prototype._
2227
5416
  const batch = _core.mergeRowBatch.call(void 0, events);
2228
5417
  return batch.flat();
2229
5418
  }
2230
- }, _class7);
5419
+ }, _class17);
2231
5420
  var BACKGROUND_LOGGER_BASE_SLEEP_TIME_S = 1;
2232
- var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
5421
+ var HTTPBackgroundLogger = (_class18 = class _HTTPBackgroundLogger {
2233
5422
 
2234
5423
 
2235
- __init22() {this.activeFlush = Promise.resolve()}
2236
- __init23() {this.activeFlushResolved = true}
2237
- __init24() {this.activeFlushError = void 0}
5424
+ __init46() {this.activeFlush = Promise.resolve()}
5425
+ __init47() {this.activeFlushResolved = true}
5426
+ __init48() {this.activeFlushError = void 0}
2238
5427
 
2239
- __init25() {this.syncFlush = false}
5428
+ __init49() {this.syncFlush = false}
2240
5429
  // 6 MB for the AWS lambda gateway (from our own testing).
2241
- __init26() {this.maxRequestSize = 6 * 1024 * 1024}
2242
- __init27() {this.defaultBatchSize = 100}
2243
- __init28() {this.numTries = 3}
2244
- __init29() {this.queueDropExceedingMaxsize = DEFAULT_QUEUE_SIZE}
2245
- __init30() {this.queueDropLoggingPeriod = 60}
2246
- __init31() {this.failedPublishPayloadsDir = void 0}
2247
- __init32() {this.allPublishPayloadsDir = void 0}
2248
- __init33() {this._disabled = false}
2249
- __init34() {this.queueDropLoggingState = {
5430
+ __init50() {this.maxRequestSize = 6 * 1024 * 1024}
5431
+ __init51() {this.defaultBatchSize = 100}
5432
+ __init52() {this.numTries = 3}
5433
+ __init53() {this.queueDropExceedingMaxsize = DEFAULT_QUEUE_SIZE}
5434
+ __init54() {this.queueDropLoggingPeriod = 60}
5435
+ __init55() {this.failedPublishPayloadsDir = void 0}
5436
+ __init56() {this.allPublishPayloadsDir = void 0}
5437
+ __init57() {this._disabled = false}
5438
+ __init58() {this.queueDropLoggingState = {
2250
5439
  numDropped: 0,
2251
5440
  lastLoggedTimestamp: 0
2252
5441
  }}
2253
- constructor(apiConn, opts) {;_class8.prototype.__init22.call(this);_class8.prototype.__init23.call(this);_class8.prototype.__init24.call(this);_class8.prototype.__init25.call(this);_class8.prototype.__init26.call(this);_class8.prototype.__init27.call(this);_class8.prototype.__init28.call(this);_class8.prototype.__init29.call(this);_class8.prototype.__init30.call(this);_class8.prototype.__init31.call(this);_class8.prototype.__init32.call(this);_class8.prototype.__init33.call(this);_class8.prototype.__init34.call(this);
5442
+ constructor(apiConn, opts) {;_class18.prototype.__init46.call(this);_class18.prototype.__init47.call(this);_class18.prototype.__init48.call(this);_class18.prototype.__init49.call(this);_class18.prototype.__init50.call(this);_class18.prototype.__init51.call(this);_class18.prototype.__init52.call(this);_class18.prototype.__init53.call(this);_class18.prototype.__init54.call(this);_class18.prototype.__init55.call(this);_class18.prototype.__init56.call(this);_class18.prototype.__init57.call(this);_class18.prototype.__init58.call(this);
2254
5443
  opts = _nullishCoalesce(opts, () => ( {}));
2255
5444
  this.apiConn = apiConn;
2256
5445
  const syncFlushEnv = Number(isomorph_default.getEnv("BRAINTRUST_SYNC_FLUSH"));
@@ -2336,7 +5525,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
2336
5525
  this.queue.clear();
2337
5526
  return;
2338
5527
  }
2339
- const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _28 => _28.batchSize]), () => ( this.defaultBatchSize));
5528
+ const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _91 => _91.batchSize]), () => ( this.defaultBatchSize));
2340
5529
  const wrappedItems = this.queue.drain();
2341
5530
  const [allItems, attachments] = await this.unwrapLazyValues(wrappedItems);
2342
5531
  if (allItems.length === 0) {
@@ -2556,10 +5745,10 @@ Error: ${errorText}`;
2556
5745
  } catch (err) {
2557
5746
  if (err instanceof AggregateError) {
2558
5747
  for (const e of err.errors) {
2559
- _optionalChain([this, 'access', _29 => _29.onFlushError, 'optionalCall', _30 => _30(e)]);
5748
+ _optionalChain([this, 'access', _92 => _92.onFlushError, 'optionalCall', _93 => _93(e)]);
2560
5749
  }
2561
5750
  } else {
2562
- _optionalChain([this, 'access', _31 => _31.onFlushError, 'optionalCall', _32 => _32(err)]);
5751
+ _optionalChain([this, 'access', _94 => _94.onFlushError, 'optionalCall', _95 => _95(err)]);
2563
5752
  }
2564
5753
  this.activeFlushError = err;
2565
5754
  } finally {
@@ -2582,7 +5771,7 @@ Error: ${errorText}`;
2582
5771
  enforceQueueSizeLimit(enforce) {
2583
5772
  this.queue.enforceQueueSizeLimit(enforce);
2584
5773
  }
2585
- }, _class8);
5774
+ }, _class18);
2586
5775
  function init(projectOrOptions, optionalOptions) {
2587
5776
  const options = (() => {
2588
5777
  if (typeof projectOrOptions === "string") {
@@ -3156,19 +6345,19 @@ async function summarize(options = {}) {
3156
6345
  return await e.summarize(options);
3157
6346
  }
3158
6347
  function currentExperiment(options) {
3159
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _33 => _33.state]), () => ( _globalState));
6348
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _96 => _96.state]), () => ( _globalState));
3160
6349
  return state.currentExperiment;
3161
6350
  }
3162
6351
  function currentLogger(options) {
3163
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.state]), () => ( _globalState));
3164
- return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _35 => _35.asyncFlush]));
6352
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _97 => _97.state]), () => ( _globalState));
6353
+ return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _98 => _98.asyncFlush]));
3165
6354
  }
3166
6355
  function currentSpan(options) {
3167
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _36 => _36.state]), () => ( _globalState));
6356
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _99 => _99.state]), () => ( _globalState));
3168
6357
  return _nullishCoalesce(state.currentSpan.getStore(), () => ( NOOP_SPAN));
3169
6358
  }
3170
6359
  function getSpanParentObject(options) {
3171
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _37 => _37.state]), () => ( _globalState));
6360
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _100 => _100.state]), () => ( _globalState));
3172
6361
  const parentSpan = currentSpan({ state });
3173
6362
  if (!Object.is(parentSpan, NOOP_SPAN)) {
3174
6363
  return parentSpan;
@@ -3200,7 +6389,7 @@ function traced(callback, args) {
3200
6389
  const { span, isSyncFlushLogger } = startSpanAndIsLogger(args);
3201
6390
  const ret = runCatchFinally(
3202
6391
  () => {
3203
- if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _38 => _38.setCurrent]), () => ( true))) {
6392
+ if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _101 => _101.setCurrent]), () => ( true))) {
3204
6393
  return withCurrent(span, callback);
3205
6394
  } else {
3206
6395
  return callback(span);
@@ -3212,7 +6401,7 @@ function traced(callback, args) {
3212
6401
  },
3213
6402
  () => span.end()
3214
6403
  );
3215
- if (_optionalChain([args, 'optionalAccess', _39 => _39.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _40 => _40.asyncFlush])) {
6404
+ if (_optionalChain([args, 'optionalAccess', _102 => _102.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _103 => _103.asyncFlush])) {
3216
6405
  return ret;
3217
6406
  } else {
3218
6407
  return (async () => {
@@ -3232,7 +6421,7 @@ function wrapTraced(fn, args) {
3232
6421
  };
3233
6422
  const hasExplicitInput = args && args.event && "input" in args.event && args.event.input !== void 0;
3234
6423
  const hasExplicitOutput = args && args.event && args.event.output !== void 0;
3235
- if (_optionalChain([args, 'optionalAccess', _41 => _41.asyncFlush])) {
6424
+ if (_optionalChain([args, 'optionalAccess', _104 => _104.asyncFlush])) {
3236
6425
  return (...fnArgs) => traced((span) => {
3237
6426
  if (!hasExplicitInput) {
3238
6427
  span.log({ input: fnArgs });
@@ -3270,15 +6459,15 @@ function startSpan(args) {
3270
6459
  return startSpanAndIsLogger(args).span;
3271
6460
  }
3272
6461
  async function flush(options) {
3273
- const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _42 => _42.state]), () => ( _globalState));
6462
+ const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _105 => _105.state]), () => ( _globalState));
3274
6463
  return await state.bgLogger().flush();
3275
6464
  }
3276
6465
  function setFetch(fetch2) {
3277
6466
  _globalState.setFetch(fetch2);
3278
6467
  }
3279
6468
  function startSpanAndIsLogger(args) {
3280
- const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _43 => _43.state]), () => ( _globalState));
3281
- const parentStr = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _44 => _44.parent]), () => ( state.currentParent.getStore()));
6469
+ const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _106 => _106.state]), () => ( _globalState));
6470
+ const parentStr = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _107 => _107.parent]), () => ( state.currentParent.getStore()));
3282
6471
  const components = parentStr ? _core.SpanComponentsV3.fromStr(parentStr) : void 0;
3283
6472
  if (components) {
3284
6473
  const parentSpanIds = components.data.row_id ? {
@@ -3294,18 +6483,18 @@ function startSpanAndIsLogger(args) {
3294
6483
  ),
3295
6484
  parentComputeObjectMetadataArgs: _nullishCoalesce(components.data.compute_object_metadata_args, () => ( void 0)),
3296
6485
  parentSpanIds,
3297
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _45 => _45.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
6486
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _108 => _108.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
3298
6487
  (_nullishCoalesce(components.data.propagated_event, () => ( void 0)))))
3299
6488
  });
3300
6489
  return {
3301
6490
  span,
3302
6491
  isSyncFlushLogger: components.data.object_type === _core.SpanObjectTypeV3.PROJECT_LOGS && // Since there's no parent logger here, we're free to choose the async flush
3303
6492
  // behavior, and therefore propagate along whatever we get from the arguments
3304
- _optionalChain([args, 'optionalAccess', _46 => _46.asyncFlush]) === false
6493
+ _optionalChain([args, 'optionalAccess', _109 => _109.asyncFlush]) === false
3305
6494
  };
3306
6495
  } else {
3307
6496
  const parentObject = getSpanParentObject({
3308
- asyncFlush: _optionalChain([args, 'optionalAccess', _47 => _47.asyncFlush])
6497
+ asyncFlush: _optionalChain([args, 'optionalAccess', _110 => _110.asyncFlush])
3309
6498
  });
3310
6499
  const span = parentObject.startSpan(args);
3311
6500
  return {
@@ -3447,10 +6636,10 @@ function extractAttachments(event, attachments) {
3447
6636
  event[key] = value.reference;
3448
6637
  continue;
3449
6638
  }
3450
- if (_optionalChain([value, 'optionalAccess', _48 => _48.type]) === _typespecs.BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
6639
+ if (_optionalChain([value, 'optionalAccess', _111 => _111.type]) === _typespecs.BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
3451
6640
  continue;
3452
6641
  }
3453
- if (_optionalChain([value, 'optionalAccess', _49 => _49.reference, 'optionalAccess', _50 => _50.type]) === _typespecs.BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _51 => _51.uploader])) {
6642
+ if (_optionalChain([value, 'optionalAccess', _112 => _112.reference, 'optionalAccess', _113 => _113.type]) === _typespecs.BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _114 => _114.uploader])) {
3454
6643
  const attachment = new Attachment({
3455
6644
  data: value.dataDebugString,
3456
6645
  filename: value.reference.filename,
@@ -3516,14 +6705,14 @@ function validateAndSanitizeExperimentLogFullArgs(event, hasDataset) {
3516
6705
  }
3517
6706
  var INTERNAL_BTQL_LIMIT = 1e3;
3518
6707
  var MAX_BTQL_ITERATIONS = 1e4;
3519
- var ObjectFetcher = (_class9 = class {
3520
- constructor(objectType, pinnedVersion, mutateRecord, _internal_btql) {;_class9.prototype.__init35.call(this);
6708
+ var ObjectFetcher = (_class19 = class {
6709
+ constructor(objectType, pinnedVersion, mutateRecord, _internal_btql) {;_class19.prototype.__init59.call(this);
3521
6710
  this.objectType = objectType;
3522
6711
  this.pinnedVersion = pinnedVersion;
3523
6712
  this.mutateRecord = mutateRecord;
3524
6713
  this._internal_btql = _internal_btql;
3525
6714
  }
3526
- __init35() {this._fetchedData = void 0}
6715
+ __init59() {this._fetchedData = void 0}
3527
6716
  get id() {
3528
6717
  throw new Error("ObjectFetcher subclasses must have an 'id' attribute");
3529
6718
  }
@@ -3588,7 +6777,7 @@ var ObjectFetcher = (_class9 = class {
3588
6777
  throw new Error("Too many BTQL iterations");
3589
6778
  }
3590
6779
  }
3591
- this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _52 => _52.map, 'call', _53 => _53(this.mutateRecord)]) : data;
6780
+ this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _115 => _115.map, 'call', _116 => _116(this.mutateRecord)]) : data;
3592
6781
  }
3593
6782
  return this._fetchedData || [];
3594
6783
  }
@@ -3610,8 +6799,8 @@ var ObjectFetcher = (_class9 = class {
3610
6799
  return maxVersion;
3611
6800
  }
3612
6801
  }
3613
- }, _class9);
3614
- var Experiment = (_class10 = class extends ObjectFetcher {
6802
+ }, _class19);
6803
+ var Experiment = (_class20 = class extends ObjectFetcher {
3615
6804
 
3616
6805
 
3617
6806
 
@@ -3619,9 +6808,9 @@ var Experiment = (_class10 = class extends ObjectFetcher {
3619
6808
 
3620
6809
 
3621
6810
  // For type identification.
3622
- __init36() {this.kind = "experiment"}
6811
+ __init60() {this.kind = "experiment"}
3623
6812
  constructor(state, lazyMetadata, dataset) {
3624
- super("experiment", void 0, (r) => enrichAttachments(r, state));_class10.prototype.__init36.call(this);;
6813
+ super("experiment", void 0, (r) => enrichAttachments(r, state));_class20.prototype.__init60.call(this);;
3625
6814
  this.lazyMetadata = lazyMetadata;
3626
6815
  this.dataset = dataset;
3627
6816
  this.lastStartTime = getCurrentUnixTimestamp();
@@ -3669,7 +6858,7 @@ var Experiment = (_class10 = class extends ObjectFetcher {
3669
6858
  * @returns The `id` of the logged event.
3670
6859
  */
3671
6860
  log(event, options) {
3672
- if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _54 => _54.allowConcurrentWithSpans])) {
6861
+ if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _117 => _117.allowConcurrentWithSpans])) {
3673
6862
  throw new Error(
3674
6863
  "Cannot run toplevel `log` method while using spans. To log to the span, call `experiment.traced` and then log with `span.log`"
3675
6864
  );
@@ -3722,12 +6911,12 @@ var Experiment = (_class10 = class extends ObjectFetcher {
3722
6911
  state: this.state,
3723
6912
  ...startSpanParentArgs({
3724
6913
  state: this.state,
3725
- parent: _optionalChain([args, 'optionalAccess', _55 => _55.parent]),
6914
+ parent: _optionalChain([args, 'optionalAccess', _118 => _118.parent]),
3726
6915
  parentObjectType: this.parentObjectType(),
3727
6916
  parentObjectId: this.lazyId,
3728
6917
  parentComputeObjectMetadataArgs: void 0,
3729
6918
  parentSpanIds: void 0,
3730
- propagatedEvent: _optionalChain([args, 'optionalAccess', _56 => _56.propagatedEvent])
6919
+ propagatedEvent: _optionalChain([args, 'optionalAccess', _119 => _119.propagatedEvent])
3731
6920
  }),
3732
6921
  defaultRootType: _core.SpanTypeAttribute.EVAL
3733
6922
  });
@@ -3873,7 +7062,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
3873
7062
  );
3874
7063
  return this.id;
3875
7064
  }
3876
- }, _class10);
7065
+ }, _class20);
3877
7066
  var ReadonlyExperiment = class extends ObjectFetcher {
3878
7067
  constructor(state, lazyMetadata) {
3879
7068
  super("experiment", void 0, (r) => enrichAttachments(r, state));
@@ -3915,7 +7104,7 @@ var executionCounter = 0;
3915
7104
  function newId() {
3916
7105
  return _uuid.v4.call(void 0, );
3917
7106
  }
3918
- var SpanImpl = (_class11 = class _SpanImpl {
7107
+ var SpanImpl = (_class21 = class _SpanImpl {
3919
7108
 
3920
7109
 
3921
7110
 
@@ -3928,8 +7117,8 @@ var SpanImpl = (_class11 = class _SpanImpl {
3928
7117
 
3929
7118
 
3930
7119
 
3931
- __init37() {this.kind = "span"}
3932
- constructor(args) {;_class11.prototype.__init37.call(this);
7120
+ __init61() {this.kind = "span"}
7121
+ constructor(args) {;_class21.prototype.__init61.call(this);
3933
7122
  this._state = args.state;
3934
7123
  const spanAttributes = _nullishCoalesce(args.spanAttributes, () => ( {}));
3935
7124
  const rawEvent = _nullishCoalesce(args.event, () => ( {}));
@@ -4019,10 +7208,10 @@ var SpanImpl = (_class11 = class _SpanImpl {
4019
7208
  ...serializableInternalData,
4020
7209
  [_core.IS_MERGE_FIELD]: this.isMerge
4021
7210
  });
4022
- if (_optionalChain([partialRecord, 'access', _57 => _57.metrics, 'optionalAccess', _58 => _58.end])) {
4023
- this.loggedEndTime = _optionalChain([partialRecord, 'access', _59 => _59.metrics, 'optionalAccess', _60 => _60.end]);
7211
+ if (_optionalChain([partialRecord, 'access', _120 => _120.metrics, 'optionalAccess', _121 => _121.end])) {
7212
+ this.loggedEndTime = _optionalChain([partialRecord, 'access', _122 => _122.metrics, 'optionalAccess', _123 => _123.end]);
4024
7213
  }
4025
- if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _61 => _61._spanParents, 'optionalAccess', _62 => _62.length])) {
7214
+ if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _124 => _124._spanParents, 'optionalAccess', _125 => _125.length])) {
4026
7215
  throw new Error("Tags can only be logged to the root span");
4027
7216
  }
4028
7217
  const computeRecord = async () => ({
@@ -4067,18 +7256,18 @@ var SpanImpl = (_class11 = class _SpanImpl {
4067
7256
  );
4068
7257
  }
4069
7258
  startSpan(args) {
4070
- const parentSpanIds = _optionalChain([args, 'optionalAccess', _63 => _63.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
7259
+ const parentSpanIds = _optionalChain([args, 'optionalAccess', _126 => _126.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
4071
7260
  return new _SpanImpl({
4072
7261
  state: this._state,
4073
7262
  ...args,
4074
7263
  ...startSpanParentArgs({
4075
7264
  state: this._state,
4076
- parent: _optionalChain([args, 'optionalAccess', _64 => _64.parent]),
7265
+ parent: _optionalChain([args, 'optionalAccess', _127 => _127.parent]),
4077
7266
  parentObjectType: this.parentObjectType,
4078
7267
  parentObjectId: this.parentObjectId,
4079
7268
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
4080
7269
  parentSpanIds,
4081
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _65 => _65.propagatedEvent]), () => ( this.propagatedEvent))
7270
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _128 => _128.propagatedEvent]), () => ( this.propagatedEvent))
4082
7271
  })
4083
7272
  });
4084
7273
  }
@@ -4092,12 +7281,12 @@ var SpanImpl = (_class11 = class _SpanImpl {
4092
7281
  ...args,
4093
7282
  ...startSpanParentArgs({
4094
7283
  state: this._state,
4095
- parent: _optionalChain([args, 'optionalAccess', _66 => _66.parent]),
7284
+ parent: _optionalChain([args, 'optionalAccess', _129 => _129.parent]),
4096
7285
  parentObjectType: this.parentObjectType,
4097
7286
  parentObjectId: this.parentObjectId,
4098
7287
  parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
4099
7288
  parentSpanIds,
4100
- propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _67 => _67.propagatedEvent]), () => ( this.propagatedEvent))
7289
+ propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _130 => _130.propagatedEvent]), () => ( this.propagatedEvent))
4101
7290
  }),
4102
7291
  spanId
4103
7292
  });
@@ -4106,7 +7295,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
4106
7295
  let endTime;
4107
7296
  let internalData = {};
4108
7297
  if (!this.loggedEndTime) {
4109
- endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _68 => _68.endTime]), () => ( getCurrentUnixTimestamp()));
7298
+ endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _131 => _131.endTime]), () => ( getCurrentUnixTimestamp()));
4110
7299
  internalData = { metrics: { end: endTime } };
4111
7300
  } else {
4112
7301
  endTime = this.loggedEndTime;
@@ -4149,8 +7338,8 @@ var SpanImpl = (_class11 = class _SpanImpl {
4149
7338
  const args = this.parentComputeObjectMetadataArgs;
4150
7339
  switch (this.parentObjectType) {
4151
7340
  case _core.SpanObjectTypeV3.PROJECT_LOGS: {
4152
- const projectID = _optionalChain([args, 'optionalAccess', _69 => _69.project_id]) || this.parentObjectId.getSync().value;
4153
- const projectName = _optionalChain([args, 'optionalAccess', _70 => _70.project_name]);
7341
+ const projectID = _optionalChain([args, 'optionalAccess', _132 => _132.project_id]) || this.parentObjectId.getSync().value;
7342
+ const projectName = _optionalChain([args, 'optionalAccess', _133 => _133.project_name]);
4154
7343
  if (projectID) {
4155
7344
  return `${baseUrl}/object?object_type=project_logs&object_id=${projectID}&id=${this._id}`;
4156
7345
  } else if (projectName) {
@@ -4160,7 +7349,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
4160
7349
  }
4161
7350
  }
4162
7351
  case _core.SpanObjectTypeV3.EXPERIMENT: {
4163
- const expID = _optionalChain([args, 'optionalAccess', _71 => _71.experiment_id]) || _optionalChain([this, 'access', _72 => _72.parentObjectId, 'optionalAccess', _73 => _73.getSync, 'call', _74 => _74(), 'optionalAccess', _75 => _75.value]);
7352
+ const expID = _optionalChain([args, 'optionalAccess', _134 => _134.experiment_id]) || _optionalChain([this, 'access', _135 => _135.parentObjectId, 'optionalAccess', _136 => _136.getSync, 'call', _137 => _137(), 'optionalAccess', _138 => _138.value]);
4164
7353
  if (!expID) {
4165
7354
  return getErrPermlink("provide-experiment-id");
4166
7355
  } else {
@@ -4186,7 +7375,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
4186
7375
  state() {
4187
7376
  return this._state;
4188
7377
  }
4189
- }, _class11);
7378
+ }, _class21);
4190
7379
  function splitLoggingData({
4191
7380
  event,
4192
7381
  internalData
@@ -4217,7 +7406,7 @@ function splitLoggingData({
4217
7406
  }
4218
7407
  return [serializableInternalData, lazyInternalData];
4219
7408
  }
4220
- var Dataset = (_class12 = class extends ObjectFetcher {
7409
+ var Dataset = (_class22 = class extends ObjectFetcher {
4221
7410
  constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql) {
4222
7411
  const isLegacyDataset = _nullishCoalesce(legacy, () => ( _core.DEFAULT_IS_LEGACY_DATASET));
4223
7412
  if (isLegacyDataset) {
@@ -4236,13 +7425,13 @@ var Dataset = (_class12 = class extends ObjectFetcher {
4236
7425
  )
4237
7426
  ),
4238
7427
  _internal_btql
4239
- );_class12.prototype.__init38.call(this);_class12.prototype.__init39.call(this);;
7428
+ );_class22.prototype.__init62.call(this);_class22.prototype.__init63.call(this);;
4240
7429
  this.state = state;
4241
7430
  this.lazyMetadata = lazyMetadata;
4242
7431
  }
4243
7432
 
4244
- __init38() {this.__braintrust_dataset_marker = true}
4245
- __init39() {this.newRecords = 0}
7433
+ __init62() {this.__braintrust_dataset_marker = true}
7434
+ __init63() {this.newRecords = 0}
4246
7435
  get id() {
4247
7436
  return (async () => {
4248
7437
  return (await this.lazyMetadata.get()).dataset.id;
@@ -4457,7 +7646,7 @@ var Dataset = (_class12 = class extends ObjectFetcher {
4457
7646
  static isDataset(data) {
4458
7647
  return typeof data === "object" && data !== null && "__braintrust_dataset_marker" in data;
4459
7648
  }
4460
- }, _class12);
7649
+ }, _class22);
4461
7650
  function renderMessage(render, message) {
4462
7651
  return {
4463
7652
  ...message,
@@ -4564,15 +7753,15 @@ function renderPromptParams(params, args, options) {
4564
7753
  }
4565
7754
  return params;
4566
7755
  }
4567
- var Prompt = (_class13 = class _Prompt {
4568
- constructor(metadata, defaults, noTrace) {;_class13.prototype.__init40.call(this);_class13.prototype.__init41.call(this);
7756
+ var Prompt = (_class23 = class _Prompt {
7757
+ constructor(metadata, defaults, noTrace) {;_class23.prototype.__init64.call(this);_class23.prototype.__init65.call(this);
4569
7758
  this.metadata = metadata;
4570
7759
  this.defaults = defaults;
4571
7760
  this.noTrace = noTrace;
4572
7761
  }
4573
7762
 
4574
- __init40() {this.hasParsedPromptData = false}
4575
- __init41() {this.__braintrust_prompt_marker = true}
7763
+ __init64() {this.hasParsedPromptData = false}
7764
+ __init65() {this.__braintrust_prompt_marker = true}
4576
7765
  get id() {
4577
7766
  return this.metadata.id;
4578
7767
  }
@@ -4586,13 +7775,13 @@ var Prompt = (_class13 = class _Prompt {
4586
7775
  return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
4587
7776
  }
4588
7777
  get prompt() {
4589
- return _optionalChain([this, 'access', _76 => _76.getParsedPromptData, 'call', _77 => _77(), 'optionalAccess', _78 => _78.prompt]);
7778
+ return _optionalChain([this, 'access', _139 => _139.getParsedPromptData, 'call', _140 => _140(), 'optionalAccess', _141 => _141.prompt]);
4590
7779
  }
4591
7780
  get version() {
4592
7781
  return this.metadata[_core.TRANSACTION_ID_FIELD];
4593
7782
  }
4594
7783
  get options() {
4595
- return _optionalChain([this, 'access', _79 => _79.getParsedPromptData, 'call', _80 => _80(), 'optionalAccess', _81 => _81.options]) || {};
7784
+ return _optionalChain([this, 'access', _142 => _142.getParsedPromptData, 'call', _143 => _143(), 'optionalAccess', _144 => _144.options]) || {};
4596
7785
  }
4597
7786
  get promptData() {
4598
7787
  return this.getParsedPromptData();
@@ -4743,7 +7932,7 @@ var Prompt = (_class13 = class _Prompt {
4743
7932
  return {
4744
7933
  type: "chat",
4745
7934
  messages,
4746
- ..._optionalChain([prompt, 'access', _82 => _82.tools, 'optionalAccess', _83 => _83.trim, 'call', _84 => _84()]) ? {
7935
+ ..._optionalChain([prompt, 'access', _145 => _145.tools, 'optionalAccess', _146 => _146.trim, 'call', _147 => _147()]) ? {
4747
7936
  tools: render(prompt.tools)
4748
7937
  } : void 0
4749
7938
  };
@@ -4788,7 +7977,7 @@ var Prompt = (_class13 = class _Prompt {
4788
7977
  false
4789
7978
  );
4790
7979
  }
4791
- }, _class13);
7980
+ }, _class23);
4792
7981
  var TEST_API_KEY = "___TEST_API_KEY__THIS_IS_NOT_REAL___";
4793
7982
  async function simulateLoginForTests() {
4794
7983
  return await login({
@@ -4811,8 +8000,8 @@ var _exportsForTestingOnly = {
4811
8000
  };
4812
8001
 
4813
8002
  // src/node.ts
4814
- var _util = require('util');
4815
- var _zlib = require('zlib'); var zlib = _interopRequireWildcard(_zlib);
8003
+
8004
+
4816
8005
  function configureNode() {
4817
8006
  isomorph_default.getRepoInfo = getRepoInfo;
4818
8007
  isomorph_default.getPastNAncestors = getPastNAncestors;
@@ -4840,10 +8029,13 @@ function configureNode() {
4840
8029
 
4841
8030
  // src/exports-node.ts
4842
8031
  var exports_node_exports = {};
4843
- __export(exports_node_exports, {
8032
+ _chunkCDBUTZMHjs.__export.call(void 0, exports_node_exports, {
8033
+ AISpanProcessor: () => AISpanProcessor,
4844
8034
  Attachment: () => Attachment,
4845
8035
  BaseAttachment: () => BaseAttachment,
4846
8036
  BaseExperiment: () => BaseExperiment,
8037
+ BraintrustExporter: () => BraintrustExporter,
8038
+ BraintrustSpanProcessor: () => BraintrustSpanProcessor,
4847
8039
  BraintrustState: () => BraintrustState,
4848
8040
  BraintrustStream: () => BraintrustStream,
4849
8041
  CodeFunction: () => CodeFunction,
@@ -4978,7 +8170,7 @@ async function invoke(args) {
4978
8170
  `Invalid function ID arguments: ${functionId.error.message}`
4979
8171
  );
4980
8172
  }
4981
- const request = {
8173
+ const request3 = {
4982
8174
  ...functionId.data,
4983
8175
  input,
4984
8176
  messages,
@@ -4989,7 +8181,7 @@ async function invoke(args) {
4989
8181
  mode,
4990
8182
  strict
4991
8183
  };
4992
- const resp = await state.proxyConn().post(`function/invoke`, request, {
8184
+ const resp = await state.proxyConn().post(`function/invoke`, request3, {
4993
8185
  headers: {
4994
8186
  Accept: stream ? "text/event-stream" : "application/json"
4995
8187
  }
@@ -5891,12 +9083,12 @@ function groupByLimit(coll, limit, iteratee, callback) {
5891
9083
  });
5892
9084
  }, (err, mapResults) => {
5893
9085
  var result = {};
5894
- var { hasOwnProperty } = Object.prototype;
9086
+ var { hasOwnProperty: hasOwnProperty2 } = Object.prototype;
5895
9087
  for (var i = 0; i < mapResults.length; i++) {
5896
9088
  if (mapResults[i]) {
5897
9089
  var { key } = mapResults[i];
5898
9090
  var { val } = mapResults[i];
5899
- if (hasOwnProperty.call(result, key)) {
9091
+ if (hasOwnProperty2.call(result, key)) {
5900
9092
  result[key].push(val);
5901
9093
  } else {
5902
9094
  result[key] = [val];
@@ -6077,10 +9269,10 @@ function fitNameToSpaces(name, length) {
6077
9269
  }
6078
9270
  return padded.substring(0, length - 3) + "...";
6079
9271
  }
6080
- var BarProgressReporter = (_class14 = class {
9272
+ var BarProgressReporter = (_class24 = class {
6081
9273
 
6082
- __init42() {this.bars = {}}
6083
- constructor() {;_class14.prototype.__init42.call(this);
9274
+ __init66() {this.bars = {}}
9275
+ constructor() {;_class24.prototype.__init66.call(this);
6084
9276
  this.multiBar = new cliProgress.MultiBar(
6085
9277
  {
6086
9278
  clearOnComplete: false,
@@ -6102,7 +9294,7 @@ var BarProgressReporter = (_class14 = class {
6102
9294
  evaluator: fitNameToSpaces(name, MAX_NAME_LENGTH)
6103
9295
  });
6104
9296
  }
6105
- }, _class14);
9297
+ }, _class24);
6106
9298
 
6107
9299
  // src/eval-parameters.ts
6108
9300
 
@@ -6124,15 +9316,15 @@ var ProjectBuilder = class {
6124
9316
  }
6125
9317
  };
6126
9318
  var projects = new ProjectBuilder();
6127
- var Project = (_class15 = class {
9319
+ var Project = (_class25 = class {
6128
9320
 
6129
9321
 
6130
9322
 
6131
9323
 
6132
9324
 
6133
- __init43() {this._publishableCodeFunctions = []}
6134
- __init44() {this._publishablePrompts = []}
6135
- constructor(args) {;_class15.prototype.__init43.call(this);_class15.prototype.__init44.call(this);
9325
+ __init67() {this._publishableCodeFunctions = []}
9326
+ __init68() {this._publishablePrompts = []}
9327
+ constructor(args) {;_class25.prototype.__init67.call(this);_class25.prototype.__init68.call(this);
6136
9328
  _initializeSpanContext();
6137
9329
  this.name = "name" in args ? args.name : void 0;
6138
9330
  this.id = "id" in args ? args.id : void 0;
@@ -6175,12 +9367,12 @@ var Project = (_class15 = class {
6175
9367
  functions: functionDefinitions
6176
9368
  });
6177
9369
  }
6178
- }, _class15);
6179
- var ToolBuilder = (_class16 = class {
6180
- constructor(project) {;_class16.prototype.__init45.call(this);
9370
+ }, _class25);
9371
+ var ToolBuilder = (_class26 = class {
9372
+ constructor(project) {;_class26.prototype.__init69.call(this);
6181
9373
  this.project = project;
6182
9374
  }
6183
- __init45() {this.taskCounter = 0}
9375
+ __init69() {this.taskCounter = 0}
6184
9376
  // This type definition is just a catch all so that the implementation can be
6185
9377
  // less specific than the two more specific declarations above.
6186
9378
  create(opts) {
@@ -6205,12 +9397,12 @@ var ToolBuilder = (_class16 = class {
6205
9397
  this.project.addCodeFunction(tool);
6206
9398
  return tool;
6207
9399
  }
6208
- }, _class16);
6209
- var ScorerBuilder = (_class17 = class {
6210
- constructor(project) {;_class17.prototype.__init46.call(this);
9400
+ }, _class26);
9401
+ var ScorerBuilder = (_class27 = class {
9402
+ constructor(project) {;_class27.prototype.__init70.call(this);
6211
9403
  this.project = project;
6212
9404
  }
6213
- __init46() {this.taskCounter = 0}
9405
+ __init70() {this.taskCounter = 0}
6214
9406
  create(opts) {
6215
9407
  this.taskCounter++;
6216
9408
  let resolvedName = opts.name;
@@ -6263,7 +9455,7 @@ var ScorerBuilder = (_class17 = class {
6263
9455
  this.project.addPrompt(codePrompt);
6264
9456
  }
6265
9457
  }
6266
- }, _class17);
9458
+ }, _class27);
6267
9459
  var CodeFunction = class {
6268
9460
  constructor(project, opts) {
6269
9461
  this.project = project;
@@ -6427,9 +9619,9 @@ function promptDefinitionToPromptData(promptDefinition, rawTools) {
6427
9619
  }
6428
9620
  };
6429
9621
  }
6430
- var ProjectNameIdMap = (_class18 = class {constructor() { _class18.prototype.__init47.call(this);_class18.prototype.__init48.call(this); }
6431
- __init47() {this.nameToId = {}}
6432
- __init48() {this.idToName = {}}
9622
+ var ProjectNameIdMap = (_class28 = class {constructor() { _class28.prototype.__init71.call(this);_class28.prototype.__init72.call(this); }
9623
+ __init71() {this.nameToId = {}}
9624
+ __init72() {this.idToName = {}}
6433
9625
  async getId(projectName) {
6434
9626
  if (!(projectName in this.nameToId)) {
6435
9627
  const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
@@ -6462,7 +9654,7 @@ var ProjectNameIdMap = (_class18 = class {constructor() { _class18.prototype.__i
6462
9654
  }
6463
9655
  return this.getId(project.name);
6464
9656
  }
6465
- }, _class18);
9657
+ }, _class28);
6466
9658
 
6467
9659
  // src/eval-parameters.ts
6468
9660
 
@@ -6758,14 +9950,20 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6758
9950
  } else {
6759
9951
  data = dataResult;
6760
9952
  }
6761
- data = data.filter((d) => filters.every((f) => evaluateFilter(d, f))).flatMap(
6762
- (datum) => [...Array(_nullishCoalesce(evaluator.trialCount, () => ( 1))).keys()].map(() => datum)
9953
+ const dataWithTrials = data.filter((d) => filters.every((f) => evaluateFilter(d, f))).flatMap(
9954
+ (datum) => [...Array(_nullishCoalesce(evaluator.trialCount, () => ( 1))).keys()].map((trialIndex) => ({
9955
+ datum,
9956
+ trialIndex
9957
+ }))
6763
9958
  );
6764
- progressReporter.start(evaluator.evalName, data.length);
9959
+ progressReporter.start(evaluator.evalName, dataWithTrials.length);
6765
9960
  const results = [];
6766
9961
  const q = queue(
6767
9962
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6768
- async (datum) => {
9963
+ async ({
9964
+ datum,
9965
+ trialIndex
9966
+ }) => {
6769
9967
  const eventDataset = experiment ? experiment.dataset : Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
6770
9968
  const baseEvent = {
6771
9969
  name: "eval",
@@ -6807,14 +10005,15 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6807
10005
  span,
6808
10006
  parameters: _nullishCoalesce(parameters, () => ( {})),
6809
10007
  reportProgress: (event) => {
6810
- _optionalChain([stream, 'optionalCall', _85 => _85({
10008
+ _optionalChain([stream, 'optionalCall', _148 => _148({
6811
10009
  ...event,
6812
10010
  id: rootSpan.id,
6813
- origin: _optionalChain([baseEvent, 'access', _86 => _86.event, 'optionalAccess', _87 => _87.origin]),
10011
+ origin: _optionalChain([baseEvent, 'access', _149 => _149.event, 'optionalAccess', _150 => _150.origin]),
6814
10012
  name: evaluator.evalName,
6815
10013
  object_type: "task"
6816
10014
  })]);
6817
- }
10015
+ },
10016
+ trialIndex
6818
10017
  });
6819
10018
  if (outputResult instanceof Promise) {
6820
10019
  output = await outputResult;
@@ -6952,7 +10151,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6952
10151
  ...scores
6953
10152
  },
6954
10153
  error: error2,
6955
- origin: _optionalChain([baseEvent, 'access', _88 => _88.event, 'optionalAccess', _89 => _89.origin])
10154
+ origin: _optionalChain([baseEvent, 'access', _151 => _151.event, 'optionalAccess', _152 => _152.origin])
6956
10155
  });
6957
10156
  };
6958
10157
  if (!experiment) {
@@ -6964,9 +10163,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
6964
10163
  return await experiment.traced(callback, baseEvent);
6965
10164
  }
6966
10165
  },
6967
- Math.max(_nullishCoalesce(evaluator.maxConcurrency, () => ( data.length)), 1)
10166
+ Math.max(_nullishCoalesce(evaluator.maxConcurrency, () => ( dataWithTrials.length)), 1)
6968
10167
  );
6969
- q.push(data);
10168
+ q.push(dataWithTrials);
6970
10169
  const cancel = async () => {
6971
10170
  await new Promise((_, reject2) => {
6972
10171
  if (evaluator.timeout) {
@@ -7109,7 +10308,7 @@ function formatMetricSummary(summary, longestMetricName) {
7109
10308
 
7110
10309
  // src/graph-framework.ts
7111
10310
  var graph_framework_exports = {};
7112
- __export(graph_framework_exports, {
10311
+ _chunkCDBUTZMHjs.__export.call(void 0, graph_framework_exports, {
7113
10312
  AggregatorNode: () => AggregatorNode,
7114
10313
  GateNode: () => GateNode,
7115
10314
  GraphBuilder: () => GraphBuilder,
@@ -7123,24 +10322,24 @@ __export(graph_framework_exports, {
7123
10322
  escapePath: () => escapePath,
7124
10323
  unescapePath: () => unescapePath
7125
10324
  });
7126
- var GraphBuilder = (_class19 = class {
7127
- __init49() {this.nodes = /* @__PURE__ */ new Map()}
7128
- __init50() {this.edges = {}}
7129
- __init51() {this.nodeLikeNodes = /* @__PURE__ */ new Map()}
10325
+ var GraphBuilder = (_class29 = class {
10326
+ __init73() {this.nodes = /* @__PURE__ */ new Map()}
10327
+ __init74() {this.edges = {}}
10328
+ __init75() {this.nodeLikeNodes = /* @__PURE__ */ new Map()}
7130
10329
  // Maps node-like objects, like prompts, to their nodes
7131
10330
  // Special nodes
7132
10331
 
7133
10332
 
7134
- constructor() {;_class19.prototype.__init49.call(this);_class19.prototype.__init50.call(this);_class19.prototype.__init51.call(this);
10333
+ constructor() {;_class29.prototype.__init73.call(this);_class29.prototype.__init74.call(this);_class29.prototype.__init75.call(this);
7135
10334
  this.IN = this.createInputNode();
7136
10335
  this.OUT = this.createOutputNode();
7137
10336
  }
7138
10337
  // Create the final GraphData object
7139
- async build(context) {
10338
+ async build(context2) {
7140
10339
  const nodes = await Promise.all(
7141
10340
  Array.from(this.nodes.values()).map(async (node) => [
7142
10341
  node.id,
7143
- await node.build(context)
10342
+ await node.build(context2)
7144
10343
  ])
7145
10344
  );
7146
10345
  return {
@@ -7261,7 +10460,7 @@ var GraphBuilder = (_class19 = class {
7261
10460
  this.nodes.set(id, promptNode);
7262
10461
  return promptNode;
7263
10462
  }
7264
- }, _class19);
10463
+ }, _class29);
7265
10464
  function isProxyVariable(node) {
7266
10465
  return typeof node === "object" && node !== null && "__type" in node && // @ts-ignore
7267
10466
  node.__type === "proxy-variable";
@@ -7269,22 +10468,22 @@ function isProxyVariable(node) {
7269
10468
  function proxyVariableToNode(proxy) {
7270
10469
  return [proxy.__node, proxy.__path];
7271
10470
  }
7272
- var BaseNode = (_class20 = class {
7273
- constructor(graph, id) {;_class20.prototype.__init52.call(this);_class20.prototype.__init53.call(this);
10471
+ var BaseNode = (_class30 = class {
10472
+ constructor(graph, id) {;_class30.prototype.__init76.call(this);_class30.prototype.__init77.call(this);
7274
10473
  this.graph = graph;
7275
10474
  this.id = id;
7276
10475
  }
7277
- __init52() {this.__type = "node"}
7278
- __init53() {this.dependencies = []}
10476
+ __init76() {this.__type = "node"}
10477
+ __init77() {this.dependencies = []}
7279
10478
  addDependency(dependency) {
7280
10479
  this.dependencies.push(dependency);
7281
10480
  }
7282
- }, _class20);
10481
+ }, _class30);
7283
10482
  var InputNode = class extends BaseNode {
7284
10483
  constructor(graph, id) {
7285
10484
  super(graph, id);
7286
10485
  }
7287
- async build(context) {
10486
+ async build(context2) {
7288
10487
  return {
7289
10488
  type: "input",
7290
10489
  description: "Input to the graph"
@@ -7295,7 +10494,7 @@ var OutputNode = class extends BaseNode {
7295
10494
  constructor(graph, id) {
7296
10495
  super(graph, id);
7297
10496
  }
7298
- async build(context) {
10497
+ async build(context2) {
7299
10498
  return {
7300
10499
  type: "output",
7301
10500
  description: "Output of the graph"
@@ -7307,10 +10506,10 @@ var PromptNode = class extends BaseNode {
7307
10506
  super(graph, id);
7308
10507
  this.prompt = prompt;
7309
10508
  }
7310
- async build(context) {
10509
+ async build(context2) {
7311
10510
  return {
7312
10511
  type: "function",
7313
- function: await context.getFunctionId(this.prompt)
10512
+ function: await context2.getFunctionId(this.prompt)
7314
10513
  };
7315
10514
  }
7316
10515
  };
@@ -7319,7 +10518,7 @@ var GateNode = class extends BaseNode {
7319
10518
  super(graph, id);
7320
10519
  this.condition = condition;
7321
10520
  }
7322
- async build(context) {
10521
+ async build(context2) {
7323
10522
  return {
7324
10523
  type: "gate",
7325
10524
  description: "Conditional gate",
@@ -7331,7 +10530,7 @@ var AggregatorNode = class extends BaseNode {
7331
10530
  constructor(graph, id) {
7332
10531
  super(graph, id);
7333
10532
  }
7334
- async build(context) {
10533
+ async build(context2) {
7335
10534
  return {
7336
10535
  type: "aggregator",
7337
10536
  description: "Aggregator"
@@ -7343,7 +10542,7 @@ var PromptTemplateNode = class extends BaseNode {
7343
10542
  super(graph, id);
7344
10543
  this.prompt = prompt;
7345
10544
  }
7346
- async build(context) {
10545
+ async build(context2) {
7347
10546
  return {
7348
10547
  type: "prompt_template",
7349
10548
  prompt: this.prompt
@@ -7355,7 +10554,7 @@ var LiteralNode = class extends BaseNode {
7355
10554
  super(graph, id);
7356
10555
  this.value = value;
7357
10556
  }
7358
- async build(context) {
10557
+ async build(context2) {
7359
10558
  return {
7360
10559
  type: "literal",
7361
10560
  value: this.value
@@ -7445,8 +10644,8 @@ function parseSpanFromResponseCreateParams(params) {
7445
10644
  }
7446
10645
  function parseEventFromResponseCreateResult(result) {
7447
10646
  return {
7448
- output: _optionalChain([result, 'optionalAccess', _90 => _90.output_text]) || "",
7449
- metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _91 => _91.usage]))
10647
+ output: _optionalChain([result, 'optionalAccess', _153 => _153.output_text]) || "",
10648
+ metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _154 => _154.usage]))
7450
10649
  };
7451
10650
  }
7452
10651
  function traceResponseCreateStream(stream, timedSpan) {
@@ -7463,7 +10662,7 @@ function traceResponseCreateStream(stream, timedSpan) {
7463
10662
  return result;
7464
10663
  }
7465
10664
  const item = result.value;
7466
- if (!item || !_optionalChain([item, 'optionalAccess', _92 => _92.type]) || !_optionalChain([item, 'optionalAccess', _93 => _93.response])) {
10665
+ if (!item || !_optionalChain([item, 'optionalAccess', _155 => _155.type]) || !_optionalChain([item, 'optionalAccess', _156 => _156.response])) {
7467
10666
  return result;
7468
10667
  }
7469
10668
  const event = parseLogFromItem(item);
@@ -7474,23 +10673,23 @@ function traceResponseCreateStream(stream, timedSpan) {
7474
10673
  };
7475
10674
  }
7476
10675
  function parseLogFromItem(item) {
7477
- if (!item || !_optionalChain([item, 'optionalAccess', _94 => _94.type]) || !_optionalChain([item, 'optionalAccess', _95 => _95.response])) {
10676
+ if (!item || !_optionalChain([item, 'optionalAccess', _157 => _157.type]) || !_optionalChain([item, 'optionalAccess', _158 => _158.response])) {
7478
10677
  return {};
7479
10678
  }
7480
10679
  const response = item.response;
7481
10680
  switch (item.type) {
7482
10681
  case "response.completed":
7483
10682
  const texts = [];
7484
- for (const output of _optionalChain([response, 'optionalAccess', _96 => _96.output]) || []) {
7485
- for (const content of _optionalChain([output, 'optionalAccess', _97 => _97.content]) || []) {
7486
- if (_optionalChain([content, 'optionalAccess', _98 => _98.type]) === "output_text") {
10683
+ for (const output of _optionalChain([response, 'optionalAccess', _159 => _159.output]) || []) {
10684
+ for (const content of _optionalChain([output, 'optionalAccess', _160 => _160.content]) || []) {
10685
+ if (_optionalChain([content, 'optionalAccess', _161 => _161.type]) === "output_text") {
7487
10686
  texts.push(content.text);
7488
10687
  }
7489
10688
  }
7490
10689
  }
7491
10690
  return {
7492
10691
  output: texts.join(""),
7493
- metrics: parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _99 => _99.usage]))
10692
+ metrics: parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _162 => _162.usage]))
7494
10693
  };
7495
10694
  default:
7496
10695
  return {};
@@ -7657,8 +10856,8 @@ function wrapOpenAIv4(openai) {
7657
10856
  const embeddingProxy = createEndpointProxy(openai.embeddings, wrapEmbeddings);
7658
10857
  const moderationProxy = createEndpointProxy(openai.moderations, wrapModerations);
7659
10858
  let betaProxy2;
7660
- if (_optionalChain([openai, 'access', _100 => _100.beta, 'optionalAccess', _101 => _101.chat, 'optionalAccess', _102 => _102.completions, 'optionalAccess', _103 => _103.stream])) {
7661
- const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess', _104 => _104.beta, 'optionalAccess', _105 => _105.chat, 'access', _106 => _106.completions]), {
10859
+ if (_optionalChain([openai, 'access', _163 => _163.beta, 'optionalAccess', _164 => _164.chat, 'optionalAccess', _165 => _165.completions, 'optionalAccess', _166 => _166.stream])) {
10860
+ const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess', _167 => _167.beta, 'optionalAccess', _168 => _168.chat, 'access', _169 => _169.completions]), {
7662
10861
  get(target, name, receiver) {
7663
10862
  const baseVal = Reflect.get(target, name, receiver);
7664
10863
  if (name === "parse") {
@@ -7706,7 +10905,7 @@ function wrapOpenAIv4(openai) {
7706
10905
  });
7707
10906
  }
7708
10907
  function logCompletionResponse(startTime, response, span) {
7709
- const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _107 => _107.usage]));
10908
+ const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _170 => _170.usage]));
7710
10909
  metrics.time_to_first_token = getCurrentUnixTimestamp() - startTime;
7711
10910
  span.log({
7712
10911
  output: response.choices,
@@ -7908,7 +11107,7 @@ function parseChatCompletionParams(params) {
7908
11107
  function processEmbeddingResponse(result, span) {
7909
11108
  span.log({
7910
11109
  output: { embedding_length: result.data[0].embedding.length },
7911
- metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _108 => _108.usage]))
11110
+ metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _171 => _171.usage]))
7912
11111
  });
7913
11112
  }
7914
11113
  function processModerationResponse(result, span) {
@@ -7938,10 +11137,10 @@ function postprocessStreamingResults(allResults) {
7938
11137
  if (result.usage) {
7939
11138
  metrics = {
7940
11139
  ...metrics,
7941
- ...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _109 => _109.usage]))
11140
+ ...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _172 => _172.usage]))
7942
11141
  };
7943
11142
  }
7944
- const delta = _optionalChain([result, 'access', _110 => _110.choices, 'optionalAccess', _111 => _111[0], 'optionalAccess', _112 => _112.delta]);
11143
+ const delta = _optionalChain([result, 'access', _173 => _173.choices, 'optionalAccess', _174 => _174[0], 'optionalAccess', _175 => _175.delta]);
7945
11144
  if (!delta) {
7946
11145
  continue;
7947
11146
  }
@@ -8024,7 +11223,7 @@ var WrapperStream = class {
8024
11223
  // src/wrappers/ai-sdk.ts
8025
11224
  function wrapAISDKModel(model) {
8026
11225
  const m = model;
8027
- if (_optionalChain([m, 'optionalAccess', _113 => _113.specificationVersion]) === "v1" && typeof _optionalChain([m, 'optionalAccess', _114 => _114.provider]) === "string" && typeof _optionalChain([m, 'optionalAccess', _115 => _115.modelId]) === "string") {
11226
+ if (_optionalChain([m, 'optionalAccess', _176 => _176.specificationVersion]) === "v1" && typeof _optionalChain([m, 'optionalAccess', _177 => _177.provider]) === "string" && typeof _optionalChain([m, 'optionalAccess', _178 => _178.modelId]) === "string") {
8028
11227
  return new BraintrustLanguageModelWrapper(m);
8029
11228
  } else {
8030
11229
  console.warn("Unsupported AI SDK model. Not wrapping.");
@@ -8080,10 +11279,10 @@ var BraintrustLanguageModelWrapper = class {
8080
11279
  metrics: {
8081
11280
  time_to_first_token: getCurrentUnixTimestamp() - startTime,
8082
11281
  tokens: !isEmpty(ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
8083
- prompt_tokens: _optionalChain([ret, 'access', _116 => _116.usage, 'optionalAccess', _117 => _117.promptTokens]),
8084
- completion_tokens: _optionalChain([ret, 'access', _118 => _118.usage, 'optionalAccess', _119 => _119.completionTokens]),
11282
+ prompt_tokens: _optionalChain([ret, 'access', _179 => _179.usage, 'optionalAccess', _180 => _180.promptTokens]),
11283
+ completion_tokens: _optionalChain([ret, 'access', _181 => _181.usage, 'optionalAccess', _182 => _182.completionTokens]),
8085
11284
  cached: parseCachedHeader(
8086
- _nullishCoalesce(_optionalChain([ret, 'access', _120 => _120.rawResponse, 'optionalAccess', _121 => _121.headers, 'optionalAccess', _122 => _122[X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _123 => _123.rawResponse, 'optionalAccess', _124 => _124.headers, 'optionalAccess', _125 => _125[LEGACY_CACHED_HEADER]])))
11285
+ _nullishCoalesce(_optionalChain([ret, 'access', _183 => _183.rawResponse, 'optionalAccess', _184 => _184.headers, 'optionalAccess', _185 => _185[X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _186 => _186.rawResponse, 'optionalAccess', _187 => _187.headers, 'optionalAccess', _188 => _188[LEGACY_CACHED_HEADER]])))
8087
11286
  )
8088
11287
  }
8089
11288
  });
@@ -8175,10 +11374,10 @@ var BraintrustLanguageModelWrapper = class {
8175
11374
  metrics: {
8176
11375
  time_to_first_token,
8177
11376
  tokens: !isEmpty(usage) ? usage.promptTokens + usage.completionTokens : void 0,
8178
- prompt_tokens: _optionalChain([usage, 'optionalAccess', _126 => _126.promptTokens]),
8179
- completion_tokens: _optionalChain([usage, 'optionalAccess', _127 => _127.completionTokens]),
11377
+ prompt_tokens: _optionalChain([usage, 'optionalAccess', _189 => _189.promptTokens]),
11378
+ completion_tokens: _optionalChain([usage, 'optionalAccess', _190 => _190.completionTokens]),
8180
11379
  cached: parseCachedHeader(
8181
- _nullishCoalesce(_optionalChain([ret, 'access', _128 => _128.rawResponse, 'optionalAccess', _129 => _129.headers, 'optionalAccess', _130 => _130[X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _131 => _131.rawResponse, 'optionalAccess', _132 => _132.headers, 'optionalAccess', _133 => _133[LEGACY_CACHED_HEADER]])))
11380
+ _nullishCoalesce(_optionalChain([ret, 'access', _191 => _191.rawResponse, 'optionalAccess', _192 => _192.headers, 'optionalAccess', _193 => _193[X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _194 => _194.rawResponse, 'optionalAccess', _195 => _195.headers, 'optionalAccess', _196 => _196[LEGACY_CACHED_HEADER]])))
8182
11381
  )
8183
11382
  }
8184
11383
  });
@@ -8225,7 +11424,7 @@ function postProcessPrompt(prompt) {
8225
11424
  return [
8226
11425
  {
8227
11426
  role: "assistant",
8228
- content: _optionalChain([textPart, 'optionalAccess', _134 => _134.text]),
11427
+ content: _optionalChain([textPart, 'optionalAccess', _197 => _197.text]),
8229
11428
  ...toolCallParts.length > 0 ? {
8230
11429
  tool_calls: toolCallParts.map((part) => ({
8231
11430
  id: part.toolCallId,
@@ -8450,9 +11649,9 @@ function streamNextProxy(stream, sspan) {
8450
11649
  return result;
8451
11650
  }
8452
11651
  const item = result.value;
8453
- switch (_optionalChain([item, 'optionalAccess', _135 => _135.type])) {
11652
+ switch (_optionalChain([item, 'optionalAccess', _198 => _198.type])) {
8454
11653
  case "message_start":
8455
- const msg = _optionalChain([item, 'optionalAccess', _136 => _136.message]);
11654
+ const msg = _optionalChain([item, 'optionalAccess', _199 => _199.message]);
8456
11655
  if (msg) {
8457
11656
  const event = parseEventFromMessage(msg);
8458
11657
  totals = { ...totals, ...event.metrics };
@@ -8460,20 +11659,20 @@ function streamNextProxy(stream, sspan) {
8460
11659
  }
8461
11660
  break;
8462
11661
  case "content_block_delta":
8463
- if (_optionalChain([item, 'access', _137 => _137.delta, 'optionalAccess', _138 => _138.type]) === "text_delta") {
8464
- const text = _optionalChain([item, 'optionalAccess', _139 => _139.delta, 'optionalAccess', _140 => _140.text]);
11662
+ if (_optionalChain([item, 'access', _200 => _200.delta, 'optionalAccess', _201 => _201.type]) === "text_delta") {
11663
+ const text = _optionalChain([item, 'optionalAccess', _202 => _202.delta, 'optionalAccess', _203 => _203.text]);
8465
11664
  if (text) {
8466
11665
  deltas.push(text);
8467
11666
  }
8468
11667
  }
8469
11668
  break;
8470
11669
  case "message_delta":
8471
- const usage = _optionalChain([item, 'optionalAccess', _141 => _141.usage]);
11670
+ const usage = _optionalChain([item, 'optionalAccess', _204 => _204.usage]);
8472
11671
  if (usage) {
8473
11672
  const metrics = parseMetricsFromUsage2(usage);
8474
11673
  totals = { ...totals, ...metrics };
8475
11674
  }
8476
- const delta = _optionalChain([item, 'optionalAccess', _142 => _142.delta]);
11675
+ const delta = _optionalChain([item, 'optionalAccess', _205 => _205.delta]);
8477
11676
  if (delta) {
8478
11677
  metadata = { ...metadata, ...delta };
8479
11678
  }
@@ -8485,8 +11684,8 @@ function streamNextProxy(stream, sspan) {
8485
11684
  };
8486
11685
  }
8487
11686
  function parseEventFromMessage(message) {
8488
- const output = _optionalChain([message, 'optionalAccess', _143 => _143.content]) || null;
8489
- const metrics = parseMetricsFromUsage2(_optionalChain([message, 'optionalAccess', _144 => _144.usage]));
11687
+ const output = _optionalChain([message, 'optionalAccess', _206 => _206.content]) || null;
11688
+ const metrics = parseMetricsFromUsage2(_optionalChain([message, 'optionalAccess', _207 => _207.usage]));
8490
11689
  const metas = ["stop_reason", "stop_sequence"];
8491
11690
  const metadata = {};
8492
11691
  for (const m of metas) {
@@ -8534,6 +11733,231 @@ function coalesceInput(messages, system) {
8534
11733
  return input;
8535
11734
  }
8536
11735
 
11736
+ // src/otel.ts
11737
+ var otelApi = null;
11738
+ var otelSdk = null;
11739
+ var OTEL_AVAILABLE = false;
11740
+ try {
11741
+ otelApi = (_chunkCDBUTZMHjs.init_esm.call(void 0, ), _chunkCDBUTZMHjs.__toCommonJS.call(void 0, _chunkCDBUTZMHjs.esm_exports));
11742
+ otelSdk = (init_esm5(), _chunkCDBUTZMHjs.__toCommonJS.call(void 0, esm_exports2));
11743
+ OTEL_AVAILABLE = true;
11744
+ } catch (error2) {
11745
+ console.warn(
11746
+ "OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions"
11747
+ );
11748
+ OTEL_AVAILABLE = false;
11749
+ }
11750
+ var FILTER_PREFIXES = ["gen_ai.", "braintrust.", "llm.", "ai."];
11751
+ var AISpanProcessor = class _AISpanProcessor {
11752
+ static checkOtelAvailable() {
11753
+ if (!OTEL_AVAILABLE) {
11754
+ throw new Error(
11755
+ "OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions"
11756
+ );
11757
+ }
11758
+ }
11759
+
11760
+
11761
+ /**
11762
+ * Initialize the filter span processor.
11763
+ *
11764
+ * @param processor - The wrapped span processor that will receive filtered spans
11765
+ * @param customFilter - Optional function that takes a span and returns:
11766
+ * true to keep, false to drop,
11767
+ * null/undefined to not influence the decision
11768
+ */
11769
+ constructor(processor, customFilter) {
11770
+ _AISpanProcessor.checkOtelAvailable();
11771
+ this.processor = processor;
11772
+ this.customFilter = customFilter;
11773
+ }
11774
+ /**
11775
+ * Forward span start events to the inner processor.
11776
+ */
11777
+ onStart(span, parentContext) {
11778
+ this.processor.onStart(span, parentContext);
11779
+ }
11780
+ /**
11781
+ * Apply filtering logic and conditionally forward span end events.
11782
+ */
11783
+ onEnd(span) {
11784
+ const shouldKeep = this.shouldKeepFilteredSpan(span);
11785
+ if (shouldKeep) {
11786
+ this.processor.onEnd(span);
11787
+ }
11788
+ }
11789
+ /**
11790
+ * Shutdown the inner processor.
11791
+ */
11792
+ shutdown() {
11793
+ return this.processor.shutdown();
11794
+ }
11795
+ /**
11796
+ * Force flush the inner processor.
11797
+ */
11798
+ forceFlush() {
11799
+ return this.processor.forceFlush();
11800
+ }
11801
+ /**
11802
+ * Determine if a span should be kept based on filtering criteria.
11803
+ *
11804
+ * Keep spans if:
11805
+ * 1. It's a root span (no parent)
11806
+ * 2. Custom filter returns true/false (if provided)
11807
+ * 3. Span name starts with 'gen_ai.', 'braintrust.', 'llm.', or 'ai.'
11808
+ * 4. Any attribute name starts with those prefixes
11809
+ */
11810
+ shouldKeepFilteredSpan(span) {
11811
+ if (!span) {
11812
+ return false;
11813
+ }
11814
+ if (!span.parentSpanContext) {
11815
+ return true;
11816
+ }
11817
+ if (this.customFilter) {
11818
+ const customResult = this.customFilter(span);
11819
+ if (customResult === true) {
11820
+ return true;
11821
+ } else if (customResult === false) {
11822
+ return false;
11823
+ }
11824
+ }
11825
+ if (FILTER_PREFIXES.some((prefix) => span.name.startsWith(prefix))) {
11826
+ return true;
11827
+ }
11828
+ const attributes = span.attributes;
11829
+ if (attributes) {
11830
+ const attributeNames = Object.keys(attributes);
11831
+ if (attributeNames.some(
11832
+ (name) => FILTER_PREFIXES.some((prefix) => name.startsWith(prefix))
11833
+ )) {
11834
+ return true;
11835
+ }
11836
+ }
11837
+ return false;
11838
+ }
11839
+ };
11840
+ var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
11841
+ static checkOtelAvailable() {
11842
+ if (!OTEL_AVAILABLE) {
11843
+ throw new Error(
11844
+ "OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions"
11845
+ );
11846
+ }
11847
+ }
11848
+
11849
+
11850
+ constructor(options = {}) {
11851
+ _BraintrustSpanProcessor.checkOtelAvailable();
11852
+ const apiKey = options.apiKey || process.env.BRAINTRUST_API_KEY;
11853
+ if (!apiKey) {
11854
+ throw new Error(
11855
+ "Braintrust API key is required. Set BRAINTRUST_API_KEY environment variable or pass apiKey option."
11856
+ );
11857
+ }
11858
+ let apiUrl = options.apiUrl || process.env.BRAINTRUST_API_URL || "https://api.braintrust.dev";
11859
+ if (!apiUrl.endsWith("/")) {
11860
+ apiUrl += "/";
11861
+ }
11862
+ let parent = options.parent || process.env.BRAINTRUST_PARENT;
11863
+ if (!parent) {
11864
+ parent = "project_name:default-otel-project";
11865
+ console.info(
11866
+ `No parent specified, using default: ${parent}. Configure with BRAINTRUST_PARENT environment variable or parent parameter.`
11867
+ );
11868
+ }
11869
+ let exporter;
11870
+ try {
11871
+ const {
11872
+ OTLPTraceExporter: OTLPTraceExporter2
11873
+ } = (init_esm9(), _chunkCDBUTZMHjs.__toCommonJS.call(void 0, esm_exports3));
11874
+ const headers = {
11875
+ Authorization: `Bearer ${apiKey}`,
11876
+ "Content-Type": "application/json",
11877
+ "x-bt-parent": parent,
11878
+ ...options.headers
11879
+ };
11880
+ exporter = new OTLPTraceExporter2({
11881
+ url: new URL("otel/v1/traces", apiUrl).href,
11882
+ headers
11883
+ });
11884
+ } catch (error2) {
11885
+ throw new Error(
11886
+ "Failed to create OTLP exporter. Make sure @opentelemetry/exporter-trace-otlp-http is installed."
11887
+ );
11888
+ }
11889
+ if (!otelSdk) {
11890
+ throw new Error("OpenTelemetry SDK not available");
11891
+ }
11892
+ this.processor = new otelSdk.BatchSpanProcessor(exporter);
11893
+ if (options.filterAISpans === true) {
11894
+ this.aiSpanProcessor = new AISpanProcessor(
11895
+ this.processor,
11896
+ options.customFilter
11897
+ );
11898
+ } else {
11899
+ this.aiSpanProcessor = this.processor;
11900
+ }
11901
+ }
11902
+ onStart(span, parentContext) {
11903
+ this.aiSpanProcessor.onStart(span, parentContext);
11904
+ }
11905
+ onEnd(span) {
11906
+ this.aiSpanProcessor.onEnd(span);
11907
+ }
11908
+ shutdown() {
11909
+ return this.aiSpanProcessor.shutdown();
11910
+ }
11911
+ forceFlush() {
11912
+ return this.aiSpanProcessor.forceFlush();
11913
+ }
11914
+ };
11915
+ var BraintrustExporter = (_class31 = class _BraintrustExporter {
11916
+ static checkOtelAvailable() {
11917
+ if (!OTEL_AVAILABLE) {
11918
+ throw new Error(
11919
+ "OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions"
11920
+ );
11921
+ }
11922
+ }
11923
+
11924
+ __init78() {this.spans = []}
11925
+ __init79() {this.callbacks = []}
11926
+ constructor(options = {}) {;_class31.prototype.__init78.call(this);_class31.prototype.__init79.call(this);
11927
+ _BraintrustExporter.checkOtelAvailable();
11928
+ this.processor = new BraintrustSpanProcessor(options);
11929
+ }
11930
+ /**
11931
+ * Export spans to Braintrust by simulating span processor behavior.
11932
+ */
11933
+ export(spans, resultCallback) {
11934
+ try {
11935
+ spans.forEach((span) => {
11936
+ this.processor.onEnd(span);
11937
+ });
11938
+ this.processor.forceFlush().then(() => {
11939
+ resultCallback({ code: 0 });
11940
+ }).catch((error2) => {
11941
+ resultCallback({ code: 1, error: error2 });
11942
+ });
11943
+ } catch (error2) {
11944
+ resultCallback({ code: 1, error: error2 });
11945
+ }
11946
+ }
11947
+ /**
11948
+ * Shutdown the exporter.
11949
+ */
11950
+ shutdown() {
11951
+ return this.processor.shutdown();
11952
+ }
11953
+ /**
11954
+ * Force flush the exporter.
11955
+ */
11956
+ forceFlush() {
11957
+ return this.processor.forceFlush();
11958
+ }
11959
+ }, _class31);
11960
+
8537
11961
  // dev/types.ts
8538
11962
 
8539
11963
 
@@ -8676,4 +12100,7 @@ var index_default = exports_node_exports;
8676
12100
 
8677
12101
 
8678
12102
 
8679
- exports.Attachment = Attachment; exports.BaseAttachment = BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustState = BraintrustState; exports.BraintrustStream = BraintrustStream; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.Dataset = Dataset; exports.ERR_PERMALINK = ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = Experiment; exports.ExternalAttachment = ExternalAttachment; exports.FailedHTTPResponse = FailedHTTPResponse; exports.INTERNAL_BTQL_LIMIT = INTERNAL_BTQL_LIMIT; exports.LEGACY_CACHED_HEADER = LEGACY_CACHED_HEADER; exports.LazyValue = LazyValue; exports.Logger = Logger; exports.NOOP_SPAN = NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = NOOP_SPAN_PERMALINK; exports.NoopSpan = NoopSpan; exports.Project = Project; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = ReadonlyAttachment; exports.ReadonlyExperiment = ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanImpl = SpanImpl; exports.TestBackgroundLogger = TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.X_CACHED_HEADER = X_CACHED_HEADER; exports._exportsForTestingOnly = _exportsForTestingOnly; exports._internalGetGlobalState = _internalGetGlobalState; exports._internalSetInitialState = _internalSetInitialState; exports.braintrustStreamChunkSchema = braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.createFinalValuePassThroughStream = createFinalValuePassThroughStream; exports.currentExperiment = currentExperiment; exports.currentLogger = currentLogger; exports.currentSpan = currentSpan; exports.default = index_default; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = deserializePlainStringAsJSON; exports.devNullWritableStream = devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.flush = flush; exports.getSpanParentObject = getSpanParentObject; exports.graph = graph_framework_exports; exports.init = init; exports.initDataset = initDataset; exports.initExperiment = initExperiment; exports.initFunction = initFunction; exports.initLogger = initLogger; exports.invoke = invoke; exports.loadPrompt = loadPrompt; exports.log = log; exports.logError = logError; exports.login = login; exports.loginToState = loginToState; exports.newId = newId; exports.parseCachedHeader = parseCachedHeader; exports.permalink = permalink; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.renderMessage = renderMessage; exports.renderPromptParams = renderPromptParams; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = setFetch; exports.spanComponentsToObjectId = spanComponentsToObjectId; exports.startSpan = startSpan; exports.summarize = summarize; exports.toolFunctionDefinitionSchema = _typespecs.toolFunctionDefinitionSchema; exports.traceable = traceable; exports.traced = traced; exports.updateSpan = updateSpan; exports.withCurrent = withCurrent; exports.withDataset = withDataset; exports.withExperiment = withExperiment; exports.withLogger = withLogger; exports.withParent = withParent; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAnthropic = wrapAnthropic; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapTraced = wrapTraced;
12103
+
12104
+
12105
+
12106
+ exports.AISpanProcessor = AISpanProcessor; exports.Attachment = Attachment; exports.BaseAttachment = BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustExporter = BraintrustExporter; exports.BraintrustSpanProcessor = BraintrustSpanProcessor; exports.BraintrustState = BraintrustState; exports.BraintrustStream = BraintrustStream; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.Dataset = Dataset; exports.ERR_PERMALINK = ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = Experiment; exports.ExternalAttachment = ExternalAttachment; exports.FailedHTTPResponse = FailedHTTPResponse; exports.INTERNAL_BTQL_LIMIT = INTERNAL_BTQL_LIMIT; exports.LEGACY_CACHED_HEADER = LEGACY_CACHED_HEADER; exports.LazyValue = LazyValue; exports.Logger = Logger; exports.NOOP_SPAN = NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = NOOP_SPAN_PERMALINK; exports.NoopSpan = NoopSpan; exports.Project = Project; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = ReadonlyAttachment; exports.ReadonlyExperiment = ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanImpl = SpanImpl; exports.TestBackgroundLogger = TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.X_CACHED_HEADER = X_CACHED_HEADER; exports._exportsForTestingOnly = _exportsForTestingOnly; exports._internalGetGlobalState = _internalGetGlobalState; exports._internalSetInitialState = _internalSetInitialState; exports.braintrustStreamChunkSchema = braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.createFinalValuePassThroughStream = createFinalValuePassThroughStream; exports.currentExperiment = currentExperiment; exports.currentLogger = currentLogger; exports.currentSpan = currentSpan; exports.default = index_default; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = deserializePlainStringAsJSON; exports.devNullWritableStream = devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.flush = flush; exports.getSpanParentObject = getSpanParentObject; exports.graph = graph_framework_exports; exports.init = init; exports.initDataset = initDataset; exports.initExperiment = initExperiment; exports.initFunction = initFunction; exports.initLogger = initLogger; exports.invoke = invoke; exports.loadPrompt = loadPrompt; exports.log = log; exports.logError = logError; exports.login = login; exports.loginToState = loginToState; exports.newId = newId; exports.parseCachedHeader = parseCachedHeader; exports.permalink = permalink; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.renderMessage = renderMessage; exports.renderPromptParams = renderPromptParams; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = setFetch; exports.spanComponentsToObjectId = spanComponentsToObjectId; exports.startSpan = startSpan; exports.summarize = summarize; exports.toolFunctionDefinitionSchema = _typespecs.toolFunctionDefinitionSchema; exports.traceable = traceable; exports.traced = traced; exports.updateSpan = updateSpan; exports.withCurrent = withCurrent; exports.withDataset = withDataset; exports.withExperiment = withExperiment; exports.withLogger = withLogger; exports.withParent = withParent; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAnthropic = wrapAnthropic; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapTraced = wrapTraced;