agentv 3.1.0 → 3.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.
Files changed (70) hide show
  1. package/dist/agentv-provider-5CJVBBGG-2XVZBW7L.js +9 -0
  2. package/dist/agentv-provider-5CJVBBGG-2XVZBW7L.js.map +1 -0
  3. package/dist/chunk-3L2L5GIL.js +51 -0
  4. package/dist/chunk-3L2L5GIL.js.map +1 -0
  5. package/dist/chunk-5H446C7X.js +50 -0
  6. package/dist/chunk-5H446C7X.js.map +1 -0
  7. package/dist/chunk-6GSYTMXD.js +31520 -0
  8. package/dist/chunk-6GSYTMXD.js.map +1 -0
  9. package/dist/chunk-BL4PVUAT.js +261 -0
  10. package/dist/chunk-BL4PVUAT.js.map +1 -0
  11. package/dist/chunk-C5GOHBQM.js +84 -0
  12. package/dist/chunk-C5GOHBQM.js.map +1 -0
  13. package/dist/chunk-FTPA72PY.js +6149 -0
  14. package/dist/chunk-FTPA72PY.js.map +1 -0
  15. package/dist/chunk-JK6V4KVD.js +114 -0
  16. package/dist/chunk-JK6V4KVD.js.map +1 -0
  17. package/dist/chunk-LRULMAAA.js +1711 -0
  18. package/dist/chunk-LRULMAAA.js.map +1 -0
  19. package/dist/chunk-OR4WXZAF.js +24302 -0
  20. package/dist/chunk-OR4WXZAF.js.map +1 -0
  21. package/dist/chunk-PCQA43SA.js +4248 -0
  22. package/dist/chunk-PCQA43SA.js.map +1 -0
  23. package/dist/chunk-SR4I5KET.js +1238 -0
  24. package/dist/chunk-SR4I5KET.js.map +1 -0
  25. package/dist/chunk-VQ2ZO7XJ.js +2098 -0
  26. package/dist/chunk-VQ2ZO7XJ.js.map +1 -0
  27. package/dist/chunk-XALGXSKB.js +21 -0
  28. package/dist/chunk-XALGXSKB.js.map +1 -0
  29. package/dist/chunk-XOSNETAV.js +565 -0
  30. package/dist/chunk-XOSNETAV.js.map +1 -0
  31. package/dist/cli.js +29 -0
  32. package/dist/cli.js.map +1 -0
  33. package/dist/dist-3BMOAU4X.js +305 -0
  34. package/dist/dist-3BMOAU4X.js.map +1 -0
  35. package/dist/esm-5Q4BZALM-5REQWAUV.js +924 -0
  36. package/dist/esm-5Q4BZALM-5REQWAUV.js.map +1 -0
  37. package/dist/esm-CZAWIY6F.js +32 -0
  38. package/dist/esm-CZAWIY6F.js.map +1 -0
  39. package/dist/esm-QNEMCJPL.js +933 -0
  40. package/dist/esm-QNEMCJPL.js.map +1 -0
  41. package/dist/esm-R77SNOF5.js +65 -0
  42. package/dist/esm-R77SNOF5.js.map +1 -0
  43. package/dist/esm-RVQPUGWH.js +1207 -0
  44. package/dist/esm-RVQPUGWH.js.map +1 -0
  45. package/dist/getMachineId-bsd-HSK5LZMG.js +41 -0
  46. package/dist/getMachineId-bsd-HSK5LZMG.js.map +1 -0
  47. package/dist/getMachineId-darwin-4DP6CCJV.js +41 -0
  48. package/dist/getMachineId-darwin-4DP6CCJV.js.map +1 -0
  49. package/dist/getMachineId-linux-44LJ5UJB.js +33 -0
  50. package/dist/getMachineId-linux-44LJ5UJB.js.map +1 -0
  51. package/dist/getMachineId-unsupported-NVK6IATM.js +24 -0
  52. package/dist/getMachineId-unsupported-NVK6IATM.js.map +1 -0
  53. package/dist/getMachineId-win-YZ36S7VA.js +43 -0
  54. package/dist/getMachineId-win-YZ36S7VA.js.map +1 -0
  55. package/dist/index.js +20 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/interactive-DLHPNSZ7.js +334 -0
  58. package/dist/interactive-DLHPNSZ7.js.map +1 -0
  59. package/dist/otlp-json-file-exporter-77FDBRSY-EZAPHWP6.js +9 -0
  60. package/dist/otlp-json-file-exporter-77FDBRSY-EZAPHWP6.js.map +1 -0
  61. package/dist/simple-trace-file-exporter-S76DMABU-5FCJESD2.js +9 -0
  62. package/dist/simple-trace-file-exporter-S76DMABU-5FCJESD2.js.map +1 -0
  63. package/dist/src-ML4D2MC2.js +1733 -0
  64. package/dist/src-ML4D2MC2.js.map +1 -0
  65. package/dist/templates/.agentv/targets.yaml +5 -24
  66. package/dist/token-POXF46NU.js +66 -0
  67. package/dist/token-POXF46NU.js.map +1 -0
  68. package/dist/token-util-6GWYZWGE.js +8 -0
  69. package/dist/token-util-6GWYZWGE.js.map +1 -0
  70. package/package.json +1 -1
@@ -0,0 +1,1733 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ defaultResource,
4
+ init_esm as init_esm4
5
+ } from "./chunk-XOSNETAV.js";
6
+ import {
7
+ BindOnceFuture,
8
+ ExportResultCode,
9
+ addHrTimes,
10
+ esm_exports as esm_exports2,
11
+ getNumberFromEnv,
12
+ getStringFromEnv,
13
+ globalErrorHandler,
14
+ hrTime,
15
+ hrTimeDuration,
16
+ hrTimeToMicroseconds,
17
+ init_esm as init_esm3,
18
+ internal,
19
+ isAttributeValue,
20
+ isTimeInput,
21
+ isTimeInputHrTime,
22
+ isTracingSuppressed,
23
+ merge,
24
+ millisToHrTime,
25
+ otperformance,
26
+ sanitizeAttributes,
27
+ suppressTracing
28
+ } from "./chunk-SR4I5KET.js";
29
+ import {
30
+ ATTR_EXCEPTION_MESSAGE,
31
+ ATTR_EXCEPTION_STACKTRACE,
32
+ ATTR_EXCEPTION_TYPE,
33
+ init_esm as init_esm2
34
+ } from "./chunk-VQ2ZO7XJ.js";
35
+ import {
36
+ INVALID_SPAN_CONTEXT,
37
+ SamplingDecision,
38
+ SpanKind,
39
+ SpanStatusCode,
40
+ TraceFlags,
41
+ context,
42
+ diag,
43
+ esm_exports,
44
+ init_esm,
45
+ isSpanContextValid,
46
+ isValidTraceId,
47
+ trace
48
+ } from "./chunk-LRULMAAA.js";
49
+ import {
50
+ __commonJS,
51
+ __esm,
52
+ __export,
53
+ __require,
54
+ __toCommonJS
55
+ } from "./chunk-5H446C7X.js";
56
+
57
+ // ../../node_modules/.bun/@opentelemetry+context-async-hooks@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/context-async-hooks/build/src/AbstractAsyncHooksContextManager.js
58
+ var require_AbstractAsyncHooksContextManager = __commonJS({
59
+ "../../node_modules/.bun/@opentelemetry+context-async-hooks@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/context-async-hooks/build/src/AbstractAsyncHooksContextManager.js"(exports) {
60
+ "use strict";
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.AbstractAsyncHooksContextManager = void 0;
63
+ var events_1 = __require("events");
64
+ var ADD_LISTENER_METHODS = [
65
+ "addListener",
66
+ "on",
67
+ "once",
68
+ "prependListener",
69
+ "prependOnceListener"
70
+ ];
71
+ var AbstractAsyncHooksContextManager = class {
72
+ /**
73
+ * Binds a the certain context or the active one to the target function and then returns the target
74
+ * @param context A context (span) to be bind to target
75
+ * @param target a function or event emitter. When target or one of its callbacks is called,
76
+ * the provided context will be used as the active context for the duration of the call.
77
+ */
78
+ bind(context2, target) {
79
+ if (target instanceof events_1.EventEmitter) {
80
+ return this._bindEventEmitter(context2, target);
81
+ }
82
+ if (typeof target === "function") {
83
+ return this._bindFunction(context2, target);
84
+ }
85
+ return target;
86
+ }
87
+ _bindFunction(context2, target) {
88
+ const manager = this;
89
+ const contextWrapper = function(...args) {
90
+ return manager.with(context2, () => target.apply(this, args));
91
+ };
92
+ Object.defineProperty(contextWrapper, "length", {
93
+ enumerable: false,
94
+ configurable: true,
95
+ writable: false,
96
+ value: target.length
97
+ });
98
+ return contextWrapper;
99
+ }
100
+ /**
101
+ * By default, EventEmitter call their callback with their context, which we do
102
+ * not want, instead we will bind a specific context to all callbacks that
103
+ * go through it.
104
+ * @param context the context we want to bind
105
+ * @param ee EventEmitter an instance of EventEmitter to patch
106
+ */
107
+ _bindEventEmitter(context2, ee) {
108
+ const map = this._getPatchMap(ee);
109
+ if (map !== void 0)
110
+ return ee;
111
+ this._createPatchMap(ee);
112
+ ADD_LISTENER_METHODS.forEach((methodName) => {
113
+ if (ee[methodName] === void 0)
114
+ return;
115
+ ee[methodName] = this._patchAddListener(ee, ee[methodName], context2);
116
+ });
117
+ if (typeof ee.removeListener === "function") {
118
+ ee.removeListener = this._patchRemoveListener(ee, ee.removeListener);
119
+ }
120
+ if (typeof ee.off === "function") {
121
+ ee.off = this._patchRemoveListener(ee, ee.off);
122
+ }
123
+ if (typeof ee.removeAllListeners === "function") {
124
+ ee.removeAllListeners = this._patchRemoveAllListeners(ee, ee.removeAllListeners);
125
+ }
126
+ return ee;
127
+ }
128
+ /**
129
+ * Patch methods that remove a given listener so that we match the "patched"
130
+ * version of that listener (the one that propagate context).
131
+ * @param ee EventEmitter instance
132
+ * @param original reference to the patched method
133
+ */
134
+ _patchRemoveListener(ee, original) {
135
+ const contextManager = this;
136
+ return function(event, listener) {
137
+ const events = contextManager._getPatchMap(ee)?.[event];
138
+ if (events === void 0) {
139
+ return original.call(this, event, listener);
140
+ }
141
+ const patchedListener = events.get(listener);
142
+ return original.call(this, event, patchedListener || listener);
143
+ };
144
+ }
145
+ /**
146
+ * Patch methods that remove all listeners so we remove our
147
+ * internal references for a given event.
148
+ * @param ee EventEmitter instance
149
+ * @param original reference to the patched method
150
+ */
151
+ _patchRemoveAllListeners(ee, original) {
152
+ const contextManager = this;
153
+ return function(event) {
154
+ const map = contextManager._getPatchMap(ee);
155
+ if (map !== void 0) {
156
+ if (arguments.length === 0) {
157
+ contextManager._createPatchMap(ee);
158
+ } else if (map[event] !== void 0) {
159
+ delete map[event];
160
+ }
161
+ }
162
+ return original.apply(this, arguments);
163
+ };
164
+ }
165
+ /**
166
+ * Patch methods on an event emitter instance that can add listeners so we
167
+ * can force them to propagate a given context.
168
+ * @param ee EventEmitter instance
169
+ * @param original reference to the patched method
170
+ * @param [context] context to propagate when calling listeners
171
+ */
172
+ _patchAddListener(ee, original, context2) {
173
+ const contextManager = this;
174
+ return function(event, listener) {
175
+ if (contextManager._wrapped) {
176
+ return original.call(this, event, listener);
177
+ }
178
+ let map = contextManager._getPatchMap(ee);
179
+ if (map === void 0) {
180
+ map = contextManager._createPatchMap(ee);
181
+ }
182
+ let listeners = map[event];
183
+ if (listeners === void 0) {
184
+ listeners = /* @__PURE__ */ new WeakMap();
185
+ map[event] = listeners;
186
+ }
187
+ const patchedListener = contextManager.bind(context2, listener);
188
+ listeners.set(listener, patchedListener);
189
+ contextManager._wrapped = true;
190
+ try {
191
+ return original.call(this, event, patchedListener);
192
+ } finally {
193
+ contextManager._wrapped = false;
194
+ }
195
+ };
196
+ }
197
+ _createPatchMap(ee) {
198
+ const map = /* @__PURE__ */ Object.create(null);
199
+ ee[this._kOtListeners] = map;
200
+ return map;
201
+ }
202
+ _getPatchMap(ee) {
203
+ return ee[this._kOtListeners];
204
+ }
205
+ _kOtListeners = Symbol("OtListeners");
206
+ _wrapped = false;
207
+ };
208
+ exports.AbstractAsyncHooksContextManager = AbstractAsyncHooksContextManager;
209
+ }
210
+ });
211
+
212
+ // ../../node_modules/.bun/@opentelemetry+context-async-hooks@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncHooksContextManager.js
213
+ var require_AsyncHooksContextManager = __commonJS({
214
+ "../../node_modules/.bun/@opentelemetry+context-async-hooks@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncHooksContextManager.js"(exports) {
215
+ "use strict";
216
+ Object.defineProperty(exports, "__esModule", { value: true });
217
+ exports.AsyncHooksContextManager = void 0;
218
+ var api_1 = (init_esm(), __toCommonJS(esm_exports));
219
+ var asyncHooks = __require("async_hooks");
220
+ var AbstractAsyncHooksContextManager_1 = require_AbstractAsyncHooksContextManager();
221
+ var AsyncHooksContextManager = class extends AbstractAsyncHooksContextManager_1.AbstractAsyncHooksContextManager {
222
+ _asyncHook;
223
+ _contexts = /* @__PURE__ */ new Map();
224
+ _stack = [];
225
+ constructor() {
226
+ super();
227
+ this._asyncHook = asyncHooks.createHook({
228
+ init: this._init.bind(this),
229
+ before: this._before.bind(this),
230
+ after: this._after.bind(this),
231
+ destroy: this._destroy.bind(this),
232
+ promiseResolve: this._destroy.bind(this)
233
+ });
234
+ }
235
+ active() {
236
+ return this._stack[this._stack.length - 1] ?? api_1.ROOT_CONTEXT;
237
+ }
238
+ with(context2, fn, thisArg, ...args) {
239
+ this._enterContext(context2);
240
+ try {
241
+ return fn.call(thisArg, ...args);
242
+ } finally {
243
+ this._exitContext();
244
+ }
245
+ }
246
+ enable() {
247
+ this._asyncHook.enable();
248
+ return this;
249
+ }
250
+ disable() {
251
+ this._asyncHook.disable();
252
+ this._contexts.clear();
253
+ this._stack = [];
254
+ return this;
255
+ }
256
+ /**
257
+ * Init hook will be called when userland create a async context, setting the
258
+ * context as the current one if it exist.
259
+ * @param uid id of the async context
260
+ * @param type the resource type
261
+ */
262
+ _init(uid, type) {
263
+ if (type === "TIMERWRAP")
264
+ return;
265
+ const context2 = this._stack[this._stack.length - 1];
266
+ if (context2 !== void 0) {
267
+ this._contexts.set(uid, context2);
268
+ }
269
+ }
270
+ /**
271
+ * Destroy hook will be called when a given context is no longer used so we can
272
+ * remove its attached context.
273
+ * @param uid uid of the async context
274
+ */
275
+ _destroy(uid) {
276
+ this._contexts.delete(uid);
277
+ }
278
+ /**
279
+ * Before hook is called just before executing a async context.
280
+ * @param uid uid of the async context
281
+ */
282
+ _before(uid) {
283
+ const context2 = this._contexts.get(uid);
284
+ if (context2 !== void 0) {
285
+ this._enterContext(context2);
286
+ }
287
+ }
288
+ /**
289
+ * After hook is called just after completing the execution of a async context.
290
+ */
291
+ _after() {
292
+ this._exitContext();
293
+ }
294
+ /**
295
+ * Set the given context as active
296
+ */
297
+ _enterContext(context2) {
298
+ this._stack.push(context2);
299
+ }
300
+ /**
301
+ * Remove the context at the root of the stack
302
+ */
303
+ _exitContext() {
304
+ this._stack.pop();
305
+ }
306
+ };
307
+ exports.AsyncHooksContextManager = AsyncHooksContextManager;
308
+ }
309
+ });
310
+
311
+ // ../../node_modules/.bun/@opentelemetry+context-async-hooks@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js
312
+ var require_AsyncLocalStorageContextManager = __commonJS({
313
+ "../../node_modules/.bun/@opentelemetry+context-async-hooks@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js"(exports) {
314
+ "use strict";
315
+ Object.defineProperty(exports, "__esModule", { value: true });
316
+ exports.AsyncLocalStorageContextManager = void 0;
317
+ var api_1 = (init_esm(), __toCommonJS(esm_exports));
318
+ var async_hooks_1 = __require("async_hooks");
319
+ var AbstractAsyncHooksContextManager_1 = require_AbstractAsyncHooksContextManager();
320
+ var AsyncLocalStorageContextManager = class extends AbstractAsyncHooksContextManager_1.AbstractAsyncHooksContextManager {
321
+ _asyncLocalStorage;
322
+ constructor() {
323
+ super();
324
+ this._asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
325
+ }
326
+ active() {
327
+ return this._asyncLocalStorage.getStore() ?? api_1.ROOT_CONTEXT;
328
+ }
329
+ with(context2, fn, thisArg, ...args) {
330
+ const cb = thisArg == null ? fn : fn.bind(thisArg);
331
+ return this._asyncLocalStorage.run(context2, cb, ...args);
332
+ }
333
+ enable() {
334
+ return this;
335
+ }
336
+ disable() {
337
+ this._asyncLocalStorage.disable();
338
+ return this;
339
+ }
340
+ };
341
+ exports.AsyncLocalStorageContextManager = AsyncLocalStorageContextManager;
342
+ }
343
+ });
344
+
345
+ // ../../node_modules/.bun/@opentelemetry+context-async-hooks@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/context-async-hooks/build/src/index.js
346
+ var require_src = __commonJS({
347
+ "../../node_modules/.bun/@opentelemetry+context-async-hooks@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/context-async-hooks/build/src/index.js"(exports) {
348
+ "use strict";
349
+ Object.defineProperty(exports, "__esModule", { value: true });
350
+ exports.AsyncLocalStorageContextManager = exports.AsyncHooksContextManager = void 0;
351
+ var AsyncHooksContextManager_1 = require_AsyncHooksContextManager();
352
+ Object.defineProperty(exports, "AsyncHooksContextManager", { enumerable: true, get: function() {
353
+ return AsyncHooksContextManager_1.AsyncHooksContextManager;
354
+ } });
355
+ var AsyncLocalStorageContextManager_1 = require_AsyncLocalStorageContextManager();
356
+ Object.defineProperty(exports, "AsyncLocalStorageContextManager", { enumerable: true, get: function() {
357
+ return AsyncLocalStorageContextManager_1.AsyncLocalStorageContextManager;
358
+ } });
359
+ }
360
+ });
361
+
362
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js
363
+ var ExceptionEventName;
364
+ var init_enums = __esm({
365
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js"() {
366
+ "use strict";
367
+ ExceptionEventName = "exception";
368
+ }
369
+ });
370
+
371
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js
372
+ var SpanImpl;
373
+ var init_Span = __esm({
374
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js"() {
375
+ "use strict";
376
+ init_esm();
377
+ init_esm3();
378
+ init_esm2();
379
+ init_enums();
380
+ SpanImpl = class {
381
+ // Below properties are included to implement ReadableSpan for export
382
+ // purposes but are not intended to be written-to directly.
383
+ _spanContext;
384
+ kind;
385
+ parentSpanContext;
386
+ attributes = {};
387
+ links = [];
388
+ events = [];
389
+ startTime;
390
+ resource;
391
+ instrumentationScope;
392
+ _droppedAttributesCount = 0;
393
+ _droppedEventsCount = 0;
394
+ _droppedLinksCount = 0;
395
+ _attributesCount = 0;
396
+ name;
397
+ status = {
398
+ code: SpanStatusCode.UNSET
399
+ };
400
+ endTime = [0, 0];
401
+ _ended = false;
402
+ _duration = [-1, -1];
403
+ _spanProcessor;
404
+ _spanLimits;
405
+ _attributeValueLengthLimit;
406
+ _performanceStartTime;
407
+ _performanceOffset;
408
+ _startTimeProvided;
409
+ /**
410
+ * Constructs a new SpanImpl instance.
411
+ */
412
+ constructor(opts) {
413
+ const now = Date.now();
414
+ this._spanContext = opts.spanContext;
415
+ this._performanceStartTime = otperformance.now();
416
+ this._performanceOffset = now - (this._performanceStartTime + otperformance.timeOrigin);
417
+ this._startTimeProvided = opts.startTime != null;
418
+ this._spanLimits = opts.spanLimits;
419
+ this._attributeValueLengthLimit = this._spanLimits.attributeValueLengthLimit || 0;
420
+ this._spanProcessor = opts.spanProcessor;
421
+ this.name = opts.name;
422
+ this.parentSpanContext = opts.parentSpanContext;
423
+ this.kind = opts.kind;
424
+ this.links = opts.links || [];
425
+ this.startTime = this._getTime(opts.startTime ?? now);
426
+ this.resource = opts.resource;
427
+ this.instrumentationScope = opts.scope;
428
+ if (opts.attributes != null) {
429
+ this.setAttributes(opts.attributes);
430
+ }
431
+ this._spanProcessor.onStart(this, opts.context);
432
+ }
433
+ spanContext() {
434
+ return this._spanContext;
435
+ }
436
+ setAttribute(key, value) {
437
+ if (value == null || this._isSpanEnded())
438
+ return this;
439
+ if (key.length === 0) {
440
+ diag.warn(`Invalid attribute key: ${key}`);
441
+ return this;
442
+ }
443
+ if (!isAttributeValue(value)) {
444
+ diag.warn(`Invalid attribute value set for key: ${key}`);
445
+ return this;
446
+ }
447
+ const { attributeCountLimit } = this._spanLimits;
448
+ const isNewKey = !Object.prototype.hasOwnProperty.call(this.attributes, key);
449
+ if (attributeCountLimit !== void 0 && this._attributesCount >= attributeCountLimit && isNewKey) {
450
+ this._droppedAttributesCount++;
451
+ return this;
452
+ }
453
+ this.attributes[key] = this._truncateToSize(value);
454
+ if (isNewKey) {
455
+ this._attributesCount++;
456
+ }
457
+ return this;
458
+ }
459
+ setAttributes(attributes) {
460
+ for (const [k, v] of Object.entries(attributes)) {
461
+ this.setAttribute(k, v);
462
+ }
463
+ return this;
464
+ }
465
+ /**
466
+ *
467
+ * @param name Span Name
468
+ * @param [attributesOrStartTime] Span attributes or start time
469
+ * if type is {@type TimeInput} and 3rd param is undefined
470
+ * @param [timeStamp] Specified time stamp for the event
471
+ */
472
+ addEvent(name, attributesOrStartTime, timeStamp) {
473
+ if (this._isSpanEnded())
474
+ return this;
475
+ const { eventCountLimit } = this._spanLimits;
476
+ if (eventCountLimit === 0) {
477
+ diag.warn("No events allowed.");
478
+ this._droppedEventsCount++;
479
+ return this;
480
+ }
481
+ if (eventCountLimit !== void 0 && this.events.length >= eventCountLimit) {
482
+ if (this._droppedEventsCount === 0) {
483
+ diag.debug("Dropping extra events.");
484
+ }
485
+ this.events.shift();
486
+ this._droppedEventsCount++;
487
+ }
488
+ if (isTimeInput(attributesOrStartTime)) {
489
+ if (!isTimeInput(timeStamp)) {
490
+ timeStamp = attributesOrStartTime;
491
+ }
492
+ attributesOrStartTime = void 0;
493
+ }
494
+ const attributes = sanitizeAttributes(attributesOrStartTime);
495
+ this.events.push({
496
+ name,
497
+ attributes,
498
+ time: this._getTime(timeStamp),
499
+ droppedAttributesCount: 0
500
+ });
501
+ return this;
502
+ }
503
+ addLink(link) {
504
+ this.links.push(link);
505
+ return this;
506
+ }
507
+ addLinks(links) {
508
+ this.links.push(...links);
509
+ return this;
510
+ }
511
+ setStatus(status) {
512
+ if (this._isSpanEnded())
513
+ return this;
514
+ this.status = { ...status };
515
+ if (this.status.message != null && typeof status.message !== "string") {
516
+ diag.warn(`Dropping invalid status.message of type '${typeof status.message}', expected 'string'`);
517
+ delete this.status.message;
518
+ }
519
+ return this;
520
+ }
521
+ updateName(name) {
522
+ if (this._isSpanEnded())
523
+ return this;
524
+ this.name = name;
525
+ return this;
526
+ }
527
+ end(endTime) {
528
+ if (this._isSpanEnded()) {
529
+ diag.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);
530
+ return;
531
+ }
532
+ this.endTime = this._getTime(endTime);
533
+ this._duration = hrTimeDuration(this.startTime, this.endTime);
534
+ if (this._duration[0] < 0) {
535
+ diag.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.", this.startTime, this.endTime);
536
+ this.endTime = this.startTime.slice();
537
+ this._duration = [0, 0];
538
+ }
539
+ if (this._droppedEventsCount > 0) {
540
+ diag.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`);
541
+ }
542
+ if (this._spanProcessor.onEnding) {
543
+ this._spanProcessor.onEnding(this);
544
+ }
545
+ this._ended = true;
546
+ this._spanProcessor.onEnd(this);
547
+ }
548
+ _getTime(inp) {
549
+ if (typeof inp === "number" && inp <= otperformance.now()) {
550
+ return hrTime(inp + this._performanceOffset);
551
+ }
552
+ if (typeof inp === "number") {
553
+ return millisToHrTime(inp);
554
+ }
555
+ if (inp instanceof Date) {
556
+ return millisToHrTime(inp.getTime());
557
+ }
558
+ if (isTimeInputHrTime(inp)) {
559
+ return inp;
560
+ }
561
+ if (this._startTimeProvided) {
562
+ return millisToHrTime(Date.now());
563
+ }
564
+ const msDuration = otperformance.now() - this._performanceStartTime;
565
+ return addHrTimes(this.startTime, millisToHrTime(msDuration));
566
+ }
567
+ isRecording() {
568
+ return this._ended === false;
569
+ }
570
+ recordException(exception, time) {
571
+ const attributes = {};
572
+ if (typeof exception === "string") {
573
+ attributes[ATTR_EXCEPTION_MESSAGE] = exception;
574
+ } else if (exception) {
575
+ if (exception.code) {
576
+ attributes[ATTR_EXCEPTION_TYPE] = exception.code.toString();
577
+ } else if (exception.name) {
578
+ attributes[ATTR_EXCEPTION_TYPE] = exception.name;
579
+ }
580
+ if (exception.message) {
581
+ attributes[ATTR_EXCEPTION_MESSAGE] = exception.message;
582
+ }
583
+ if (exception.stack) {
584
+ attributes[ATTR_EXCEPTION_STACKTRACE] = exception.stack;
585
+ }
586
+ }
587
+ if (attributes[ATTR_EXCEPTION_TYPE] || attributes[ATTR_EXCEPTION_MESSAGE]) {
588
+ this.addEvent(ExceptionEventName, attributes, time);
589
+ } else {
590
+ diag.warn(`Failed to record an exception ${exception}`);
591
+ }
592
+ }
593
+ get duration() {
594
+ return this._duration;
595
+ }
596
+ get ended() {
597
+ return this._ended;
598
+ }
599
+ get droppedAttributesCount() {
600
+ return this._droppedAttributesCount;
601
+ }
602
+ get droppedEventsCount() {
603
+ return this._droppedEventsCount;
604
+ }
605
+ get droppedLinksCount() {
606
+ return this._droppedLinksCount;
607
+ }
608
+ _isSpanEnded() {
609
+ if (this._ended) {
610
+ const error = new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);
611
+ diag.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`, error);
612
+ }
613
+ return this._ended;
614
+ }
615
+ // Utility function to truncate given value within size
616
+ // for value type of string, will truncate to given limit
617
+ // for type of non-string, will return same value
618
+ _truncateToLimitUtil(value, limit) {
619
+ if (value.length <= limit) {
620
+ return value;
621
+ }
622
+ return value.substring(0, limit);
623
+ }
624
+ /**
625
+ * If the given attribute value is of type string and has more characters than given {@code attributeValueLengthLimit} then
626
+ * return string with truncated to {@code attributeValueLengthLimit} characters
627
+ *
628
+ * If the given attribute value is array of strings then
629
+ * return new array of strings with each element truncated to {@code attributeValueLengthLimit} characters
630
+ *
631
+ * Otherwise return same Attribute {@code value}
632
+ *
633
+ * @param value Attribute value
634
+ * @returns truncated attribute value if required, otherwise same value
635
+ */
636
+ _truncateToSize(value) {
637
+ const limit = this._attributeValueLengthLimit;
638
+ if (limit <= 0) {
639
+ diag.warn(`Attribute value limit must be positive, got ${limit}`);
640
+ return value;
641
+ }
642
+ if (typeof value === "string") {
643
+ return this._truncateToLimitUtil(value, limit);
644
+ }
645
+ if (Array.isArray(value)) {
646
+ return value.map((val) => typeof val === "string" ? this._truncateToLimitUtil(val, limit) : val);
647
+ }
648
+ return value;
649
+ }
650
+ };
651
+ }
652
+ });
653
+
654
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js
655
+ var SamplingDecision2;
656
+ var init_Sampler = __esm({
657
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js"() {
658
+ "use strict";
659
+ (function(SamplingDecision3) {
660
+ SamplingDecision3[SamplingDecision3["NOT_RECORD"] = 0] = "NOT_RECORD";
661
+ SamplingDecision3[SamplingDecision3["RECORD"] = 1] = "RECORD";
662
+ SamplingDecision3[SamplingDecision3["RECORD_AND_SAMPLED"] = 2] = "RECORD_AND_SAMPLED";
663
+ })(SamplingDecision2 || (SamplingDecision2 = {}));
664
+ }
665
+ });
666
+
667
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js
668
+ var AlwaysOffSampler;
669
+ var init_AlwaysOffSampler = __esm({
670
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js"() {
671
+ "use strict";
672
+ init_Sampler();
673
+ AlwaysOffSampler = class {
674
+ shouldSample() {
675
+ return {
676
+ decision: SamplingDecision2.NOT_RECORD
677
+ };
678
+ }
679
+ toString() {
680
+ return "AlwaysOffSampler";
681
+ }
682
+ };
683
+ }
684
+ });
685
+
686
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js
687
+ var AlwaysOnSampler;
688
+ var init_AlwaysOnSampler = __esm({
689
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js"() {
690
+ "use strict";
691
+ init_Sampler();
692
+ AlwaysOnSampler = class {
693
+ shouldSample() {
694
+ return {
695
+ decision: SamplingDecision2.RECORD_AND_SAMPLED
696
+ };
697
+ }
698
+ toString() {
699
+ return "AlwaysOnSampler";
700
+ }
701
+ };
702
+ }
703
+ });
704
+
705
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js
706
+ var ParentBasedSampler;
707
+ var init_ParentBasedSampler = __esm({
708
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js"() {
709
+ "use strict";
710
+ init_esm();
711
+ init_esm3();
712
+ init_AlwaysOffSampler();
713
+ init_AlwaysOnSampler();
714
+ ParentBasedSampler = class {
715
+ _root;
716
+ _remoteParentSampled;
717
+ _remoteParentNotSampled;
718
+ _localParentSampled;
719
+ _localParentNotSampled;
720
+ constructor(config) {
721
+ this._root = config.root;
722
+ if (!this._root) {
723
+ globalErrorHandler(new Error("ParentBasedSampler must have a root sampler configured"));
724
+ this._root = new AlwaysOnSampler();
725
+ }
726
+ this._remoteParentSampled = config.remoteParentSampled ?? new AlwaysOnSampler();
727
+ this._remoteParentNotSampled = config.remoteParentNotSampled ?? new AlwaysOffSampler();
728
+ this._localParentSampled = config.localParentSampled ?? new AlwaysOnSampler();
729
+ this._localParentNotSampled = config.localParentNotSampled ?? new AlwaysOffSampler();
730
+ }
731
+ shouldSample(context2, traceId, spanName, spanKind, attributes, links) {
732
+ const parentContext = trace.getSpanContext(context2);
733
+ if (!parentContext || !isSpanContextValid(parentContext)) {
734
+ return this._root.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
735
+ }
736
+ if (parentContext.isRemote) {
737
+ if (parentContext.traceFlags & TraceFlags.SAMPLED) {
738
+ return this._remoteParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
739
+ }
740
+ return this._remoteParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
741
+ }
742
+ if (parentContext.traceFlags & TraceFlags.SAMPLED) {
743
+ return this._localParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
744
+ }
745
+ return this._localParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
746
+ }
747
+ toString() {
748
+ return `ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`;
749
+ }
750
+ };
751
+ }
752
+ });
753
+
754
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js
755
+ var TraceIdRatioBasedSampler;
756
+ var init_TraceIdRatioBasedSampler = __esm({
757
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js"() {
758
+ "use strict";
759
+ init_esm();
760
+ init_Sampler();
761
+ TraceIdRatioBasedSampler = class {
762
+ _ratio;
763
+ _upperBound;
764
+ constructor(ratio = 0) {
765
+ this._ratio = this._normalize(ratio);
766
+ this._upperBound = Math.floor(this._ratio * 4294967295);
767
+ }
768
+ shouldSample(context2, traceId) {
769
+ return {
770
+ decision: isValidTraceId(traceId) && this._accumulate(traceId) < this._upperBound ? SamplingDecision2.RECORD_AND_SAMPLED : SamplingDecision2.NOT_RECORD
771
+ };
772
+ }
773
+ toString() {
774
+ return `TraceIdRatioBased{${this._ratio}}`;
775
+ }
776
+ _normalize(ratio) {
777
+ if (typeof ratio !== "number" || isNaN(ratio))
778
+ return 0;
779
+ return ratio >= 1 ? 1 : ratio <= 0 ? 0 : ratio;
780
+ }
781
+ _accumulate(traceId) {
782
+ let accumulation = 0;
783
+ for (let i = 0; i < traceId.length / 8; i++) {
784
+ const pos = i * 8;
785
+ const part = parseInt(traceId.slice(pos, pos + 8), 16);
786
+ accumulation = (accumulation ^ part) >>> 0;
787
+ }
788
+ return accumulation;
789
+ }
790
+ };
791
+ }
792
+ });
793
+
794
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js
795
+ function loadDefaultConfig() {
796
+ return {
797
+ sampler: buildSamplerFromEnv(),
798
+ forceFlushTimeoutMillis: 3e4,
799
+ generalLimits: {
800
+ attributeValueLengthLimit: getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT") ?? Infinity,
801
+ attributeCountLimit: getNumberFromEnv("OTEL_ATTRIBUTE_COUNT_LIMIT") ?? 128
802
+ },
803
+ spanLimits: {
804
+ attributeValueLengthLimit: getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT") ?? Infinity,
805
+ attributeCountLimit: getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT") ?? 128,
806
+ linkCountLimit: getNumberFromEnv("OTEL_SPAN_LINK_COUNT_LIMIT") ?? 128,
807
+ eventCountLimit: getNumberFromEnv("OTEL_SPAN_EVENT_COUNT_LIMIT") ?? 128,
808
+ attributePerEventCountLimit: getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT") ?? 128,
809
+ attributePerLinkCountLimit: getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT") ?? 128
810
+ }
811
+ };
812
+ }
813
+ function buildSamplerFromEnv() {
814
+ const sampler = getStringFromEnv("OTEL_TRACES_SAMPLER") ?? TracesSamplerValues.ParentBasedAlwaysOn;
815
+ switch (sampler) {
816
+ case TracesSamplerValues.AlwaysOn:
817
+ return new AlwaysOnSampler();
818
+ case TracesSamplerValues.AlwaysOff:
819
+ return new AlwaysOffSampler();
820
+ case TracesSamplerValues.ParentBasedAlwaysOn:
821
+ return new ParentBasedSampler({
822
+ root: new AlwaysOnSampler()
823
+ });
824
+ case TracesSamplerValues.ParentBasedAlwaysOff:
825
+ return new ParentBasedSampler({
826
+ root: new AlwaysOffSampler()
827
+ });
828
+ case TracesSamplerValues.TraceIdRatio:
829
+ return new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv());
830
+ case TracesSamplerValues.ParentBasedTraceIdRatio:
831
+ return new ParentBasedSampler({
832
+ root: new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv())
833
+ });
834
+ default:
835
+ diag.error(`OTEL_TRACES_SAMPLER value "${sampler}" invalid, defaulting to "${TracesSamplerValues.ParentBasedAlwaysOn}".`);
836
+ return new ParentBasedSampler({
837
+ root: new AlwaysOnSampler()
838
+ });
839
+ }
840
+ }
841
+ function getSamplerProbabilityFromEnv() {
842
+ const probability = getNumberFromEnv("OTEL_TRACES_SAMPLER_ARG");
843
+ if (probability == null) {
844
+ diag.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${DEFAULT_RATIO}.`);
845
+ return DEFAULT_RATIO;
846
+ }
847
+ if (probability < 0 || probability > 1) {
848
+ diag.error(`OTEL_TRACES_SAMPLER_ARG=${probability} was given, but it is out of range ([0..1]), defaulting to ${DEFAULT_RATIO}.`);
849
+ return DEFAULT_RATIO;
850
+ }
851
+ return probability;
852
+ }
853
+ var TracesSamplerValues, DEFAULT_RATIO;
854
+ var init_config = __esm({
855
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js"() {
856
+ "use strict";
857
+ init_esm();
858
+ init_esm3();
859
+ init_AlwaysOffSampler();
860
+ init_AlwaysOnSampler();
861
+ init_ParentBasedSampler();
862
+ init_TraceIdRatioBasedSampler();
863
+ (function(TracesSamplerValues2) {
864
+ TracesSamplerValues2["AlwaysOff"] = "always_off";
865
+ TracesSamplerValues2["AlwaysOn"] = "always_on";
866
+ TracesSamplerValues2["ParentBasedAlwaysOff"] = "parentbased_always_off";
867
+ TracesSamplerValues2["ParentBasedAlwaysOn"] = "parentbased_always_on";
868
+ TracesSamplerValues2["ParentBasedTraceIdRatio"] = "parentbased_traceidratio";
869
+ TracesSamplerValues2["TraceIdRatio"] = "traceidratio";
870
+ })(TracesSamplerValues || (TracesSamplerValues = {}));
871
+ DEFAULT_RATIO = 1;
872
+ }
873
+ });
874
+
875
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js
876
+ function mergeConfig(userConfig) {
877
+ const perInstanceDefaults = {
878
+ sampler: buildSamplerFromEnv()
879
+ };
880
+ const DEFAULT_CONFIG = loadDefaultConfig();
881
+ const target = Object.assign({}, DEFAULT_CONFIG, perInstanceDefaults, userConfig);
882
+ target.generalLimits = Object.assign({}, DEFAULT_CONFIG.generalLimits, userConfig.generalLimits || {});
883
+ target.spanLimits = Object.assign({}, DEFAULT_CONFIG.spanLimits, userConfig.spanLimits || {});
884
+ return target;
885
+ }
886
+ function reconfigureLimits(userConfig) {
887
+ const spanLimits = Object.assign({}, userConfig.spanLimits);
888
+ spanLimits.attributeCountLimit = userConfig.spanLimits?.attributeCountLimit ?? userConfig.generalLimits?.attributeCountLimit ?? getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT") ?? getNumberFromEnv("OTEL_ATTRIBUTE_COUNT_LIMIT") ?? DEFAULT_ATTRIBUTE_COUNT_LIMIT;
889
+ spanLimits.attributeValueLengthLimit = userConfig.spanLimits?.attributeValueLengthLimit ?? userConfig.generalLimits?.attributeValueLengthLimit ?? getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT") ?? getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT") ?? DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
890
+ return Object.assign({}, userConfig, { spanLimits });
891
+ }
892
+ var DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
893
+ var init_utility = __esm({
894
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js"() {
895
+ "use strict";
896
+ init_config();
897
+ init_esm3();
898
+ DEFAULT_ATTRIBUTE_COUNT_LIMIT = 128;
899
+ DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT = Infinity;
900
+ }
901
+ });
902
+
903
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js
904
+ var BatchSpanProcessorBase;
905
+ var init_BatchSpanProcessorBase = __esm({
906
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js"() {
907
+ "use strict";
908
+ init_esm();
909
+ init_esm3();
910
+ BatchSpanProcessorBase = class {
911
+ _maxExportBatchSize;
912
+ _maxQueueSize;
913
+ _scheduledDelayMillis;
914
+ _exportTimeoutMillis;
915
+ _exporter;
916
+ _isExporting = false;
917
+ _finishedSpans = [];
918
+ _timer;
919
+ _shutdownOnce;
920
+ _droppedSpansCount = 0;
921
+ constructor(exporter, config) {
922
+ this._exporter = exporter;
923
+ this._maxExportBatchSize = typeof config?.maxExportBatchSize === "number" ? config.maxExportBatchSize : getNumberFromEnv("OTEL_BSP_MAX_EXPORT_BATCH_SIZE") ?? 512;
924
+ this._maxQueueSize = typeof config?.maxQueueSize === "number" ? config.maxQueueSize : getNumberFromEnv("OTEL_BSP_MAX_QUEUE_SIZE") ?? 2048;
925
+ this._scheduledDelayMillis = typeof config?.scheduledDelayMillis === "number" ? config.scheduledDelayMillis : getNumberFromEnv("OTEL_BSP_SCHEDULE_DELAY") ?? 5e3;
926
+ this._exportTimeoutMillis = typeof config?.exportTimeoutMillis === "number" ? config.exportTimeoutMillis : getNumberFromEnv("OTEL_BSP_EXPORT_TIMEOUT") ?? 3e4;
927
+ this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
928
+ if (this._maxExportBatchSize > this._maxQueueSize) {
929
+ diag.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize");
930
+ this._maxExportBatchSize = this._maxQueueSize;
931
+ }
932
+ }
933
+ forceFlush() {
934
+ if (this._shutdownOnce.isCalled) {
935
+ return this._shutdownOnce.promise;
936
+ }
937
+ return this._flushAll();
938
+ }
939
+ // does nothing.
940
+ onStart(_span, _parentContext) {
941
+ }
942
+ onEnd(span) {
943
+ if (this._shutdownOnce.isCalled) {
944
+ return;
945
+ }
946
+ if ((span.spanContext().traceFlags & TraceFlags.SAMPLED) === 0) {
947
+ return;
948
+ }
949
+ this._addToBuffer(span);
950
+ }
951
+ shutdown() {
952
+ return this._shutdownOnce.call();
953
+ }
954
+ _shutdown() {
955
+ return Promise.resolve().then(() => {
956
+ return this.onShutdown();
957
+ }).then(() => {
958
+ return this._flushAll();
959
+ }).then(() => {
960
+ return this._exporter.shutdown();
961
+ });
962
+ }
963
+ /** Add a span in the buffer. */
964
+ _addToBuffer(span) {
965
+ if (this._finishedSpans.length >= this._maxQueueSize) {
966
+ if (this._droppedSpansCount === 0) {
967
+ diag.debug("maxQueueSize reached, dropping spans");
968
+ }
969
+ this._droppedSpansCount++;
970
+ return;
971
+ }
972
+ if (this._droppedSpansCount > 0) {
973
+ diag.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`);
974
+ this._droppedSpansCount = 0;
975
+ }
976
+ this._finishedSpans.push(span);
977
+ this._maybeStartTimer();
978
+ }
979
+ /**
980
+ * Send all spans to the exporter respecting the batch size limit
981
+ * This function is used only on forceFlush or shutdown,
982
+ * for all other cases _flush should be used
983
+ * */
984
+ _flushAll() {
985
+ return new Promise((resolve, reject) => {
986
+ const promises = [];
987
+ const count = Math.ceil(this._finishedSpans.length / this._maxExportBatchSize);
988
+ for (let i = 0, j = count; i < j; i++) {
989
+ promises.push(this._flushOneBatch());
990
+ }
991
+ Promise.all(promises).then(() => {
992
+ resolve();
993
+ }).catch(reject);
994
+ });
995
+ }
996
+ _flushOneBatch() {
997
+ this._clearTimer();
998
+ if (this._finishedSpans.length === 0) {
999
+ return Promise.resolve();
1000
+ }
1001
+ return new Promise((resolve, reject) => {
1002
+ const timer = setTimeout(() => {
1003
+ reject(new Error("Timeout"));
1004
+ }, this._exportTimeoutMillis);
1005
+ context.with(suppressTracing(context.active()), () => {
1006
+ let spans;
1007
+ if (this._finishedSpans.length <= this._maxExportBatchSize) {
1008
+ spans = this._finishedSpans;
1009
+ this._finishedSpans = [];
1010
+ } else {
1011
+ spans = this._finishedSpans.splice(0, this._maxExportBatchSize);
1012
+ }
1013
+ const doExport = () => this._exporter.export(spans, (result) => {
1014
+ clearTimeout(timer);
1015
+ if (result.code === ExportResultCode.SUCCESS) {
1016
+ resolve();
1017
+ } else {
1018
+ reject(result.error ?? new Error("BatchSpanProcessor: span export failed"));
1019
+ }
1020
+ });
1021
+ let pendingResources = null;
1022
+ for (let i = 0, len = spans.length; i < len; i++) {
1023
+ const span = spans[i];
1024
+ if (span.resource.asyncAttributesPending && span.resource.waitForAsyncAttributes) {
1025
+ pendingResources ??= [];
1026
+ pendingResources.push(span.resource.waitForAsyncAttributes());
1027
+ }
1028
+ }
1029
+ if (pendingResources === null) {
1030
+ doExport();
1031
+ } else {
1032
+ Promise.all(pendingResources).then(doExport, (err) => {
1033
+ globalErrorHandler(err);
1034
+ reject(err);
1035
+ });
1036
+ }
1037
+ });
1038
+ });
1039
+ }
1040
+ _maybeStartTimer() {
1041
+ if (this._isExporting)
1042
+ return;
1043
+ const flush = () => {
1044
+ this._isExporting = true;
1045
+ this._flushOneBatch().finally(() => {
1046
+ this._isExporting = false;
1047
+ if (this._finishedSpans.length > 0) {
1048
+ this._clearTimer();
1049
+ this._maybeStartTimer();
1050
+ }
1051
+ }).catch((e) => {
1052
+ this._isExporting = false;
1053
+ globalErrorHandler(e);
1054
+ });
1055
+ };
1056
+ if (this._finishedSpans.length >= this._maxExportBatchSize) {
1057
+ return flush();
1058
+ }
1059
+ if (this._timer !== void 0)
1060
+ return;
1061
+ this._timer = setTimeout(() => flush(), this._scheduledDelayMillis);
1062
+ if (typeof this._timer !== "number") {
1063
+ this._timer.unref();
1064
+ }
1065
+ }
1066
+ _clearTimer() {
1067
+ if (this._timer !== void 0) {
1068
+ clearTimeout(this._timer);
1069
+ this._timer = void 0;
1070
+ }
1071
+ }
1072
+ };
1073
+ }
1074
+ });
1075
+
1076
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js
1077
+ var BatchSpanProcessor;
1078
+ var init_BatchSpanProcessor = __esm({
1079
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js"() {
1080
+ "use strict";
1081
+ init_BatchSpanProcessorBase();
1082
+ BatchSpanProcessor = class extends BatchSpanProcessorBase {
1083
+ onShutdown() {
1084
+ }
1085
+ };
1086
+ }
1087
+ });
1088
+
1089
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js
1090
+ function getIdGenerator(bytes) {
1091
+ return function generateId() {
1092
+ for (let i = 0; i < bytes / 4; i++) {
1093
+ SHARED_BUFFER.writeUInt32BE(Math.random() * 2 ** 32 >>> 0, i * 4);
1094
+ }
1095
+ for (let i = 0; i < bytes; i++) {
1096
+ if (SHARED_BUFFER[i] > 0) {
1097
+ break;
1098
+ } else if (i === bytes - 1) {
1099
+ SHARED_BUFFER[bytes - 1] = 1;
1100
+ }
1101
+ }
1102
+ return SHARED_BUFFER.toString("hex", 0, bytes);
1103
+ };
1104
+ }
1105
+ var SPAN_ID_BYTES, TRACE_ID_BYTES, RandomIdGenerator, SHARED_BUFFER;
1106
+ var init_RandomIdGenerator = __esm({
1107
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js"() {
1108
+ "use strict";
1109
+ SPAN_ID_BYTES = 8;
1110
+ TRACE_ID_BYTES = 16;
1111
+ RandomIdGenerator = class {
1112
+ /**
1113
+ * Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex
1114
+ * characters corresponding to 128 bits.
1115
+ */
1116
+ generateTraceId = getIdGenerator(TRACE_ID_BYTES);
1117
+ /**
1118
+ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex
1119
+ * characters corresponding to 64 bits.
1120
+ */
1121
+ generateSpanId = getIdGenerator(SPAN_ID_BYTES);
1122
+ };
1123
+ SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES);
1124
+ }
1125
+ });
1126
+
1127
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js
1128
+ var init_node = __esm({
1129
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js"() {
1130
+ "use strict";
1131
+ init_BatchSpanProcessor();
1132
+ init_RandomIdGenerator();
1133
+ }
1134
+ });
1135
+
1136
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js
1137
+ var init_platform = __esm({
1138
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js"() {
1139
+ "use strict";
1140
+ init_node();
1141
+ }
1142
+ });
1143
+
1144
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
1145
+ var Tracer;
1146
+ var init_Tracer = __esm({
1147
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js"() {
1148
+ "use strict";
1149
+ init_esm();
1150
+ init_esm3();
1151
+ init_Span();
1152
+ init_utility();
1153
+ init_platform();
1154
+ Tracer = class {
1155
+ _sampler;
1156
+ _generalLimits;
1157
+ _spanLimits;
1158
+ _idGenerator;
1159
+ instrumentationScope;
1160
+ _resource;
1161
+ _spanProcessor;
1162
+ /**
1163
+ * Constructs a new Tracer instance.
1164
+ */
1165
+ constructor(instrumentationScope, config, resource, spanProcessor) {
1166
+ const localConfig = mergeConfig(config);
1167
+ this._sampler = localConfig.sampler;
1168
+ this._generalLimits = localConfig.generalLimits;
1169
+ this._spanLimits = localConfig.spanLimits;
1170
+ this._idGenerator = config.idGenerator || new RandomIdGenerator();
1171
+ this._resource = resource;
1172
+ this._spanProcessor = spanProcessor;
1173
+ this.instrumentationScope = instrumentationScope;
1174
+ }
1175
+ /**
1176
+ * Starts a new Span or returns the default NoopSpan based on the sampling
1177
+ * decision.
1178
+ */
1179
+ startSpan(name, options = {}, context2 = context.active()) {
1180
+ if (options.root) {
1181
+ context2 = trace.deleteSpan(context2);
1182
+ }
1183
+ const parentSpan = trace.getSpan(context2);
1184
+ if (isTracingSuppressed(context2)) {
1185
+ diag.debug("Instrumentation suppressed, returning Noop Span");
1186
+ const nonRecordingSpan = trace.wrapSpanContext(INVALID_SPAN_CONTEXT);
1187
+ return nonRecordingSpan;
1188
+ }
1189
+ const parentSpanContext = parentSpan?.spanContext();
1190
+ const spanId = this._idGenerator.generateSpanId();
1191
+ let validParentSpanContext;
1192
+ let traceId;
1193
+ let traceState;
1194
+ if (!parentSpanContext || !trace.isSpanContextValid(parentSpanContext)) {
1195
+ traceId = this._idGenerator.generateTraceId();
1196
+ } else {
1197
+ traceId = parentSpanContext.traceId;
1198
+ traceState = parentSpanContext.traceState;
1199
+ validParentSpanContext = parentSpanContext;
1200
+ }
1201
+ const spanKind = options.kind ?? SpanKind.INTERNAL;
1202
+ const links = (options.links ?? []).map((link) => {
1203
+ return {
1204
+ context: link.context,
1205
+ attributes: sanitizeAttributes(link.attributes)
1206
+ };
1207
+ });
1208
+ const attributes = sanitizeAttributes(options.attributes);
1209
+ const samplingResult = this._sampler.shouldSample(context2, traceId, name, spanKind, attributes, links);
1210
+ traceState = samplingResult.traceState ?? traceState;
1211
+ const traceFlags = samplingResult.decision === SamplingDecision.RECORD_AND_SAMPLED ? TraceFlags.SAMPLED : TraceFlags.NONE;
1212
+ const spanContext = { traceId, spanId, traceFlags, traceState };
1213
+ if (samplingResult.decision === SamplingDecision.NOT_RECORD) {
1214
+ diag.debug("Recording is off, propagating context in a non-recording span");
1215
+ const nonRecordingSpan = trace.wrapSpanContext(spanContext);
1216
+ return nonRecordingSpan;
1217
+ }
1218
+ const initAttributes = sanitizeAttributes(Object.assign(attributes, samplingResult.attributes));
1219
+ const span = new SpanImpl({
1220
+ resource: this._resource,
1221
+ scope: this.instrumentationScope,
1222
+ context: context2,
1223
+ spanContext,
1224
+ name,
1225
+ kind: spanKind,
1226
+ links,
1227
+ parentSpanContext: validParentSpanContext,
1228
+ attributes: initAttributes,
1229
+ startTime: options.startTime,
1230
+ spanProcessor: this._spanProcessor,
1231
+ spanLimits: this._spanLimits
1232
+ });
1233
+ return span;
1234
+ }
1235
+ startActiveSpan(name, arg2, arg3, arg4) {
1236
+ let opts;
1237
+ let ctx;
1238
+ let fn;
1239
+ if (arguments.length < 2) {
1240
+ return;
1241
+ } else if (arguments.length === 2) {
1242
+ fn = arg2;
1243
+ } else if (arguments.length === 3) {
1244
+ opts = arg2;
1245
+ fn = arg3;
1246
+ } else {
1247
+ opts = arg2;
1248
+ ctx = arg3;
1249
+ fn = arg4;
1250
+ }
1251
+ const parentContext = ctx ?? context.active();
1252
+ const span = this.startSpan(name, opts, parentContext);
1253
+ const contextWithSpanSet = trace.setSpan(parentContext, span);
1254
+ return context.with(contextWithSpanSet, fn, void 0, span);
1255
+ }
1256
+ /** Returns the active {@link GeneralLimits}. */
1257
+ getGeneralLimits() {
1258
+ return this._generalLimits;
1259
+ }
1260
+ /** Returns the active {@link SpanLimits}. */
1261
+ getSpanLimits() {
1262
+ return this._spanLimits;
1263
+ }
1264
+ };
1265
+ }
1266
+ });
1267
+
1268
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js
1269
+ var MultiSpanProcessor;
1270
+ var init_MultiSpanProcessor = __esm({
1271
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js"() {
1272
+ "use strict";
1273
+ init_esm3();
1274
+ MultiSpanProcessor = class {
1275
+ _spanProcessors;
1276
+ constructor(spanProcessors) {
1277
+ this._spanProcessors = spanProcessors;
1278
+ }
1279
+ forceFlush() {
1280
+ const promises = [];
1281
+ for (const spanProcessor of this._spanProcessors) {
1282
+ promises.push(spanProcessor.forceFlush());
1283
+ }
1284
+ return new Promise((resolve) => {
1285
+ Promise.all(promises).then(() => {
1286
+ resolve();
1287
+ }).catch((error) => {
1288
+ globalErrorHandler(error || new Error("MultiSpanProcessor: forceFlush failed"));
1289
+ resolve();
1290
+ });
1291
+ });
1292
+ }
1293
+ onStart(span, context2) {
1294
+ for (const spanProcessor of this._spanProcessors) {
1295
+ spanProcessor.onStart(span, context2);
1296
+ }
1297
+ }
1298
+ onEnding(span) {
1299
+ for (const spanProcessor of this._spanProcessors) {
1300
+ if (spanProcessor.onEnding) {
1301
+ spanProcessor.onEnding(span);
1302
+ }
1303
+ }
1304
+ }
1305
+ onEnd(span) {
1306
+ for (const spanProcessor of this._spanProcessors) {
1307
+ spanProcessor.onEnd(span);
1308
+ }
1309
+ }
1310
+ shutdown() {
1311
+ const promises = [];
1312
+ for (const spanProcessor of this._spanProcessors) {
1313
+ promises.push(spanProcessor.shutdown());
1314
+ }
1315
+ return new Promise((resolve, reject) => {
1316
+ Promise.all(promises).then(() => {
1317
+ resolve();
1318
+ }, reject);
1319
+ });
1320
+ }
1321
+ };
1322
+ }
1323
+ });
1324
+
1325
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js
1326
+ var ForceFlushState, BasicTracerProvider;
1327
+ var init_BasicTracerProvider = __esm({
1328
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js"() {
1329
+ "use strict";
1330
+ init_esm3();
1331
+ init_esm4();
1332
+ init_Tracer();
1333
+ init_config();
1334
+ init_MultiSpanProcessor();
1335
+ init_utility();
1336
+ (function(ForceFlushState2) {
1337
+ ForceFlushState2[ForceFlushState2["resolved"] = 0] = "resolved";
1338
+ ForceFlushState2[ForceFlushState2["timeout"] = 1] = "timeout";
1339
+ ForceFlushState2[ForceFlushState2["error"] = 2] = "error";
1340
+ ForceFlushState2[ForceFlushState2["unresolved"] = 3] = "unresolved";
1341
+ })(ForceFlushState || (ForceFlushState = {}));
1342
+ BasicTracerProvider = class {
1343
+ _config;
1344
+ _tracers = /* @__PURE__ */ new Map();
1345
+ _resource;
1346
+ _activeSpanProcessor;
1347
+ constructor(config = {}) {
1348
+ const mergedConfig = merge({}, loadDefaultConfig(), reconfigureLimits(config));
1349
+ this._resource = mergedConfig.resource ?? defaultResource();
1350
+ this._config = Object.assign({}, mergedConfig, {
1351
+ resource: this._resource
1352
+ });
1353
+ const spanProcessors = [];
1354
+ if (config.spanProcessors?.length) {
1355
+ spanProcessors.push(...config.spanProcessors);
1356
+ }
1357
+ this._activeSpanProcessor = new MultiSpanProcessor(spanProcessors);
1358
+ }
1359
+ getTracer(name, version, options) {
1360
+ const key = `${name}@${version || ""}:${options?.schemaUrl || ""}`;
1361
+ if (!this._tracers.has(key)) {
1362
+ this._tracers.set(key, new Tracer({ name, version, schemaUrl: options?.schemaUrl }, this._config, this._resource, this._activeSpanProcessor));
1363
+ }
1364
+ return this._tracers.get(key);
1365
+ }
1366
+ forceFlush() {
1367
+ const timeout = this._config.forceFlushTimeoutMillis;
1368
+ const promises = this._activeSpanProcessor["_spanProcessors"].map((spanProcessor) => {
1369
+ return new Promise((resolve) => {
1370
+ let state;
1371
+ const timeoutInterval = setTimeout(() => {
1372
+ resolve(new Error(`Span processor did not completed within timeout period of ${timeout} ms`));
1373
+ state = ForceFlushState.timeout;
1374
+ }, timeout);
1375
+ spanProcessor.forceFlush().then(() => {
1376
+ clearTimeout(timeoutInterval);
1377
+ if (state !== ForceFlushState.timeout) {
1378
+ state = ForceFlushState.resolved;
1379
+ resolve(state);
1380
+ }
1381
+ }).catch((error) => {
1382
+ clearTimeout(timeoutInterval);
1383
+ state = ForceFlushState.error;
1384
+ resolve(error);
1385
+ });
1386
+ });
1387
+ });
1388
+ return new Promise((resolve, reject) => {
1389
+ Promise.all(promises).then((results) => {
1390
+ const errors = results.filter((result) => result !== ForceFlushState.resolved);
1391
+ if (errors.length > 0) {
1392
+ reject(errors);
1393
+ } else {
1394
+ resolve();
1395
+ }
1396
+ }).catch((error) => reject([error]));
1397
+ });
1398
+ }
1399
+ shutdown() {
1400
+ return this._activeSpanProcessor.shutdown();
1401
+ }
1402
+ };
1403
+ }
1404
+ });
1405
+
1406
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/ConsoleSpanExporter.js
1407
+ var ConsoleSpanExporter;
1408
+ var init_ConsoleSpanExporter = __esm({
1409
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/ConsoleSpanExporter.js"() {
1410
+ "use strict";
1411
+ init_esm3();
1412
+ ConsoleSpanExporter = class {
1413
+ /**
1414
+ * Export spans.
1415
+ * @param spans
1416
+ * @param resultCallback
1417
+ */
1418
+ export(spans, resultCallback) {
1419
+ return this._sendSpans(spans, resultCallback);
1420
+ }
1421
+ /**
1422
+ * Shutdown the exporter.
1423
+ */
1424
+ shutdown() {
1425
+ this._sendSpans([]);
1426
+ return this.forceFlush();
1427
+ }
1428
+ /**
1429
+ * Exports any pending spans in exporter
1430
+ */
1431
+ forceFlush() {
1432
+ return Promise.resolve();
1433
+ }
1434
+ /**
1435
+ * converts span info into more readable format
1436
+ * @param span
1437
+ */
1438
+ _exportInfo(span) {
1439
+ return {
1440
+ resource: {
1441
+ attributes: span.resource.attributes
1442
+ },
1443
+ instrumentationScope: span.instrumentationScope,
1444
+ traceId: span.spanContext().traceId,
1445
+ parentSpanContext: span.parentSpanContext,
1446
+ traceState: span.spanContext().traceState?.serialize(),
1447
+ name: span.name,
1448
+ id: span.spanContext().spanId,
1449
+ kind: span.kind,
1450
+ timestamp: hrTimeToMicroseconds(span.startTime),
1451
+ duration: hrTimeToMicroseconds(span.duration),
1452
+ attributes: span.attributes,
1453
+ status: span.status,
1454
+ events: span.events,
1455
+ links: span.links
1456
+ };
1457
+ }
1458
+ /**
1459
+ * Showing spans in console
1460
+ * @param spans
1461
+ * @param done
1462
+ */
1463
+ _sendSpans(spans, done) {
1464
+ for (const span of spans) {
1465
+ console.dir(this._exportInfo(span), { depth: 3 });
1466
+ }
1467
+ if (done) {
1468
+ return done({ code: ExportResultCode.SUCCESS });
1469
+ }
1470
+ }
1471
+ };
1472
+ }
1473
+ });
1474
+
1475
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/InMemorySpanExporter.js
1476
+ var InMemorySpanExporter;
1477
+ var init_InMemorySpanExporter = __esm({
1478
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/InMemorySpanExporter.js"() {
1479
+ "use strict";
1480
+ init_esm3();
1481
+ InMemorySpanExporter = class {
1482
+ _finishedSpans = [];
1483
+ /**
1484
+ * Indicates if the exporter has been "shutdown."
1485
+ * When false, exported spans will not be stored in-memory.
1486
+ */
1487
+ _stopped = false;
1488
+ export(spans, resultCallback) {
1489
+ if (this._stopped)
1490
+ return resultCallback({
1491
+ code: ExportResultCode.FAILED,
1492
+ error: new Error("Exporter has been stopped")
1493
+ });
1494
+ this._finishedSpans.push(...spans);
1495
+ setTimeout(() => resultCallback({ code: ExportResultCode.SUCCESS }), 0);
1496
+ }
1497
+ shutdown() {
1498
+ this._stopped = true;
1499
+ this._finishedSpans = [];
1500
+ return this.forceFlush();
1501
+ }
1502
+ /**
1503
+ * Exports any pending spans in the exporter
1504
+ */
1505
+ forceFlush() {
1506
+ return Promise.resolve();
1507
+ }
1508
+ reset() {
1509
+ this._finishedSpans = [];
1510
+ }
1511
+ getFinishedSpans() {
1512
+ return this._finishedSpans;
1513
+ }
1514
+ };
1515
+ }
1516
+ });
1517
+
1518
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/SimpleSpanProcessor.js
1519
+ var SimpleSpanProcessor;
1520
+ var init_SimpleSpanProcessor = __esm({
1521
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/SimpleSpanProcessor.js"() {
1522
+ "use strict";
1523
+ init_esm();
1524
+ init_esm3();
1525
+ SimpleSpanProcessor = class {
1526
+ _exporter;
1527
+ _shutdownOnce;
1528
+ _pendingExports;
1529
+ constructor(exporter) {
1530
+ this._exporter = exporter;
1531
+ this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
1532
+ this._pendingExports = /* @__PURE__ */ new Set();
1533
+ }
1534
+ async forceFlush() {
1535
+ await Promise.all(Array.from(this._pendingExports));
1536
+ if (this._exporter.forceFlush) {
1537
+ await this._exporter.forceFlush();
1538
+ }
1539
+ }
1540
+ onStart(_span, _parentContext) {
1541
+ }
1542
+ onEnd(span) {
1543
+ if (this._shutdownOnce.isCalled) {
1544
+ return;
1545
+ }
1546
+ if ((span.spanContext().traceFlags & TraceFlags.SAMPLED) === 0) {
1547
+ return;
1548
+ }
1549
+ const pendingExport = this._doExport(span).catch((err) => globalErrorHandler(err));
1550
+ this._pendingExports.add(pendingExport);
1551
+ void pendingExport.finally(() => this._pendingExports.delete(pendingExport));
1552
+ }
1553
+ async _doExport(span) {
1554
+ if (span.resource.asyncAttributesPending) {
1555
+ await span.resource.waitForAsyncAttributes?.();
1556
+ }
1557
+ const result = await internal._export(this._exporter, [span]);
1558
+ if (result.code !== ExportResultCode.SUCCESS) {
1559
+ throw result.error ?? new Error(`SimpleSpanProcessor: span export failed (status ${result})`);
1560
+ }
1561
+ }
1562
+ shutdown() {
1563
+ return this._shutdownOnce.call();
1564
+ }
1565
+ _shutdown() {
1566
+ return this._exporter.shutdown();
1567
+ }
1568
+ };
1569
+ }
1570
+ });
1571
+
1572
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/NoopSpanProcessor.js
1573
+ var NoopSpanProcessor;
1574
+ var init_NoopSpanProcessor = __esm({
1575
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/NoopSpanProcessor.js"() {
1576
+ "use strict";
1577
+ NoopSpanProcessor = class {
1578
+ onStart(_span, _context) {
1579
+ }
1580
+ onEnd(_span) {
1581
+ }
1582
+ shutdown() {
1583
+ return Promise.resolve();
1584
+ }
1585
+ forceFlush() {
1586
+ return Promise.resolve();
1587
+ }
1588
+ };
1589
+ }
1590
+ });
1591
+
1592
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js
1593
+ var esm_exports3 = {};
1594
+ __export(esm_exports3, {
1595
+ AlwaysOffSampler: () => AlwaysOffSampler,
1596
+ AlwaysOnSampler: () => AlwaysOnSampler,
1597
+ BasicTracerProvider: () => BasicTracerProvider,
1598
+ BatchSpanProcessor: () => BatchSpanProcessor,
1599
+ ConsoleSpanExporter: () => ConsoleSpanExporter,
1600
+ InMemorySpanExporter: () => InMemorySpanExporter,
1601
+ NoopSpanProcessor: () => NoopSpanProcessor,
1602
+ ParentBasedSampler: () => ParentBasedSampler,
1603
+ RandomIdGenerator: () => RandomIdGenerator,
1604
+ SamplingDecision: () => SamplingDecision2,
1605
+ SimpleSpanProcessor: () => SimpleSpanProcessor,
1606
+ TraceIdRatioBasedSampler: () => TraceIdRatioBasedSampler
1607
+ });
1608
+ var init_esm5 = __esm({
1609
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-base@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js"() {
1610
+ "use strict";
1611
+ init_BasicTracerProvider();
1612
+ init_platform();
1613
+ init_ConsoleSpanExporter();
1614
+ init_InMemorySpanExporter();
1615
+ init_SimpleSpanProcessor();
1616
+ init_NoopSpanProcessor();
1617
+ init_AlwaysOffSampler();
1618
+ init_AlwaysOnSampler();
1619
+ init_ParentBasedSampler();
1620
+ init_TraceIdRatioBasedSampler();
1621
+ init_Sampler();
1622
+ }
1623
+ });
1624
+
1625
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-node@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-node/build/src/NodeTracerProvider.js
1626
+ var require_NodeTracerProvider = __commonJS({
1627
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-node@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-node/build/src/NodeTracerProvider.js"(exports) {
1628
+ "use strict";
1629
+ Object.defineProperty(exports, "__esModule", { value: true });
1630
+ exports.NodeTracerProvider = void 0;
1631
+ var context_async_hooks_1 = require_src();
1632
+ var sdk_trace_base_1 = (init_esm5(), __toCommonJS(esm_exports3));
1633
+ var api_1 = (init_esm(), __toCommonJS(esm_exports));
1634
+ var core_1 = (init_esm3(), __toCommonJS(esm_exports2));
1635
+ function setupContextManager(contextManager) {
1636
+ if (contextManager === null) {
1637
+ return;
1638
+ }
1639
+ if (contextManager === void 0) {
1640
+ const defaultContextManager = new context_async_hooks_1.AsyncLocalStorageContextManager();
1641
+ defaultContextManager.enable();
1642
+ api_1.context.setGlobalContextManager(defaultContextManager);
1643
+ return;
1644
+ }
1645
+ contextManager.enable();
1646
+ api_1.context.setGlobalContextManager(contextManager);
1647
+ }
1648
+ function setupPropagator(propagator) {
1649
+ if (propagator === null) {
1650
+ return;
1651
+ }
1652
+ if (propagator === void 0) {
1653
+ api_1.propagation.setGlobalPropagator(new core_1.CompositePropagator({
1654
+ propagators: [
1655
+ new core_1.W3CTraceContextPropagator(),
1656
+ new core_1.W3CBaggagePropagator()
1657
+ ]
1658
+ }));
1659
+ return;
1660
+ }
1661
+ api_1.propagation.setGlobalPropagator(propagator);
1662
+ }
1663
+ var NodeTracerProvider = class extends sdk_trace_base_1.BasicTracerProvider {
1664
+ constructor(config = {}) {
1665
+ super(config);
1666
+ }
1667
+ /**
1668
+ * Register this TracerProvider for use with the OpenTelemetry API.
1669
+ * Undefined values may be replaced with defaults, and
1670
+ * null values will be skipped.
1671
+ *
1672
+ * @param config Configuration object for SDK registration
1673
+ */
1674
+ register(config = {}) {
1675
+ api_1.trace.setGlobalTracerProvider(this);
1676
+ setupContextManager(config.contextManager);
1677
+ setupPropagator(config.propagator);
1678
+ }
1679
+ };
1680
+ exports.NodeTracerProvider = NodeTracerProvider;
1681
+ }
1682
+ });
1683
+
1684
+ // ../../node_modules/.bun/@opentelemetry+sdk-trace-node@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-node/build/src/index.js
1685
+ var require_src2 = __commonJS({
1686
+ "../../node_modules/.bun/@opentelemetry+sdk-trace-node@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/sdk-trace-node/build/src/index.js"(exports) {
1687
+ Object.defineProperty(exports, "__esModule", { value: true });
1688
+ exports.TraceIdRatioBasedSampler = exports.SimpleSpanProcessor = exports.SamplingDecision = exports.RandomIdGenerator = exports.ParentBasedSampler = exports.NoopSpanProcessor = exports.InMemorySpanExporter = exports.ConsoleSpanExporter = exports.BatchSpanProcessor = exports.BasicTracerProvider = exports.AlwaysOnSampler = exports.AlwaysOffSampler = exports.NodeTracerProvider = void 0;
1689
+ var NodeTracerProvider_1 = require_NodeTracerProvider();
1690
+ Object.defineProperty(exports, "NodeTracerProvider", { enumerable: true, get: function() {
1691
+ return NodeTracerProvider_1.NodeTracerProvider;
1692
+ } });
1693
+ var sdk_trace_base_1 = (init_esm5(), __toCommonJS(esm_exports3));
1694
+ Object.defineProperty(exports, "AlwaysOffSampler", { enumerable: true, get: function() {
1695
+ return sdk_trace_base_1.AlwaysOffSampler;
1696
+ } });
1697
+ Object.defineProperty(exports, "AlwaysOnSampler", { enumerable: true, get: function() {
1698
+ return sdk_trace_base_1.AlwaysOnSampler;
1699
+ } });
1700
+ Object.defineProperty(exports, "BasicTracerProvider", { enumerable: true, get: function() {
1701
+ return sdk_trace_base_1.BasicTracerProvider;
1702
+ } });
1703
+ Object.defineProperty(exports, "BatchSpanProcessor", { enumerable: true, get: function() {
1704
+ return sdk_trace_base_1.BatchSpanProcessor;
1705
+ } });
1706
+ Object.defineProperty(exports, "ConsoleSpanExporter", { enumerable: true, get: function() {
1707
+ return sdk_trace_base_1.ConsoleSpanExporter;
1708
+ } });
1709
+ Object.defineProperty(exports, "InMemorySpanExporter", { enumerable: true, get: function() {
1710
+ return sdk_trace_base_1.InMemorySpanExporter;
1711
+ } });
1712
+ Object.defineProperty(exports, "NoopSpanProcessor", { enumerable: true, get: function() {
1713
+ return sdk_trace_base_1.NoopSpanProcessor;
1714
+ } });
1715
+ Object.defineProperty(exports, "ParentBasedSampler", { enumerable: true, get: function() {
1716
+ return sdk_trace_base_1.ParentBasedSampler;
1717
+ } });
1718
+ Object.defineProperty(exports, "RandomIdGenerator", { enumerable: true, get: function() {
1719
+ return sdk_trace_base_1.RandomIdGenerator;
1720
+ } });
1721
+ Object.defineProperty(exports, "SamplingDecision", { enumerable: true, get: function() {
1722
+ return sdk_trace_base_1.SamplingDecision;
1723
+ } });
1724
+ Object.defineProperty(exports, "SimpleSpanProcessor", { enumerable: true, get: function() {
1725
+ return sdk_trace_base_1.SimpleSpanProcessor;
1726
+ } });
1727
+ Object.defineProperty(exports, "TraceIdRatioBasedSampler", { enumerable: true, get: function() {
1728
+ return sdk_trace_base_1.TraceIdRatioBasedSampler;
1729
+ } });
1730
+ }
1731
+ });
1732
+ export default require_src2();
1733
+ //# sourceMappingURL=src-ML4D2MC2.js.map