raindrop-ai 0.0.52 → 0.0.53

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.
@@ -0,0 +1,3188 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __esm = (fn, res) => function __init() {
15
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
+ };
17
+ var __commonJS = (cb, mod) => function __require2() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") {
26
+ for (let key of __getOwnPropNames(from))
27
+ if (!__hasOwnProp.call(to, key) && key !== except)
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
+ }
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
+ // If the importer is in node compatibility mode or this is not an ESM
34
+ // file that has been converted to a CommonJS file using a Babel-
35
+ // compatible transform (i.e. "__esModule" has not been set), then set
36
+ // "default" to the CommonJS "module.exports" for node compatibility.
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
+ mod
39
+ ));
40
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
42
+
43
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/context-async-hooks/build/src/AbstractAsyncHooksContextManager.js
44
+ var require_AbstractAsyncHooksContextManager = __commonJS({
45
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/context-async-hooks/build/src/AbstractAsyncHooksContextManager.js"(exports) {
46
+ "use strict";
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.AbstractAsyncHooksContextManager = void 0;
49
+ var events_1 = __require("events");
50
+ var ADD_LISTENER_METHODS = [
51
+ "addListener",
52
+ "on",
53
+ "once",
54
+ "prependListener",
55
+ "prependOnceListener"
56
+ ];
57
+ var AbstractAsyncHooksContextManager = class {
58
+ constructor() {
59
+ __publicField(this, "_kOtListeners", Symbol("OtListeners"));
60
+ __publicField(this, "_wrapped", false);
61
+ }
62
+ /**
63
+ * Binds a the certain context or the active one to the target function and then returns the target
64
+ * @param context A context (span) to be bind to target
65
+ * @param target a function or event emitter. When target or one of its callbacks is called,
66
+ * the provided context will be used as the active context for the duration of the call.
67
+ */
68
+ bind(context4, target) {
69
+ if (target instanceof events_1.EventEmitter) {
70
+ return this._bindEventEmitter(context4, target);
71
+ }
72
+ if (typeof target === "function") {
73
+ return this._bindFunction(context4, target);
74
+ }
75
+ return target;
76
+ }
77
+ _bindFunction(context4, target) {
78
+ const manager = this;
79
+ const contextWrapper = function(...args) {
80
+ return manager.with(context4, () => target.apply(this, args));
81
+ };
82
+ Object.defineProperty(contextWrapper, "length", {
83
+ enumerable: false,
84
+ configurable: true,
85
+ writable: false,
86
+ value: target.length
87
+ });
88
+ return contextWrapper;
89
+ }
90
+ /**
91
+ * By default, EventEmitter call their callback with their context, which we do
92
+ * not want, instead we will bind a specific context to all callbacks that
93
+ * go through it.
94
+ * @param context the context we want to bind
95
+ * @param ee EventEmitter an instance of EventEmitter to patch
96
+ */
97
+ _bindEventEmitter(context4, ee) {
98
+ const map = this._getPatchMap(ee);
99
+ if (map !== void 0)
100
+ return ee;
101
+ this._createPatchMap(ee);
102
+ ADD_LISTENER_METHODS.forEach((methodName) => {
103
+ if (ee[methodName] === void 0)
104
+ return;
105
+ ee[methodName] = this._patchAddListener(ee, ee[methodName], context4);
106
+ });
107
+ if (typeof ee.removeListener === "function") {
108
+ ee.removeListener = this._patchRemoveListener(ee, ee.removeListener);
109
+ }
110
+ if (typeof ee.off === "function") {
111
+ ee.off = this._patchRemoveListener(ee, ee.off);
112
+ }
113
+ if (typeof ee.removeAllListeners === "function") {
114
+ ee.removeAllListeners = this._patchRemoveAllListeners(ee, ee.removeAllListeners);
115
+ }
116
+ return ee;
117
+ }
118
+ /**
119
+ * Patch methods that remove a given listener so that we match the "patched"
120
+ * version of that listener (the one that propagate context).
121
+ * @param ee EventEmitter instance
122
+ * @param original reference to the patched method
123
+ */
124
+ _patchRemoveListener(ee, original) {
125
+ const contextManager = this;
126
+ return function(event, listener) {
127
+ var _a;
128
+ const events = (_a = contextManager._getPatchMap(ee)) == null ? void 0 : _a[event];
129
+ if (events === void 0) {
130
+ return original.call(this, event, listener);
131
+ }
132
+ const patchedListener = events.get(listener);
133
+ return original.call(this, event, patchedListener || listener);
134
+ };
135
+ }
136
+ /**
137
+ * Patch methods that remove all listeners so we remove our
138
+ * internal references for a given event.
139
+ * @param ee EventEmitter instance
140
+ * @param original reference to the patched method
141
+ */
142
+ _patchRemoveAllListeners(ee, original) {
143
+ const contextManager = this;
144
+ return function(event) {
145
+ const map = contextManager._getPatchMap(ee);
146
+ if (map !== void 0) {
147
+ if (arguments.length === 0) {
148
+ contextManager._createPatchMap(ee);
149
+ } else if (map[event] !== void 0) {
150
+ delete map[event];
151
+ }
152
+ }
153
+ return original.apply(this, arguments);
154
+ };
155
+ }
156
+ /**
157
+ * Patch methods on an event emitter instance that can add listeners so we
158
+ * can force them to propagate a given context.
159
+ * @param ee EventEmitter instance
160
+ * @param original reference to the patched method
161
+ * @param [context] context to propagate when calling listeners
162
+ */
163
+ _patchAddListener(ee, original, context4) {
164
+ const contextManager = this;
165
+ return function(event, listener) {
166
+ if (contextManager._wrapped) {
167
+ return original.call(this, event, listener);
168
+ }
169
+ let map = contextManager._getPatchMap(ee);
170
+ if (map === void 0) {
171
+ map = contextManager._createPatchMap(ee);
172
+ }
173
+ let listeners = map[event];
174
+ if (listeners === void 0) {
175
+ listeners = /* @__PURE__ */ new WeakMap();
176
+ map[event] = listeners;
177
+ }
178
+ const patchedListener = contextManager.bind(context4, listener);
179
+ listeners.set(listener, patchedListener);
180
+ contextManager._wrapped = true;
181
+ try {
182
+ return original.call(this, event, patchedListener);
183
+ } finally {
184
+ contextManager._wrapped = false;
185
+ }
186
+ };
187
+ }
188
+ _createPatchMap(ee) {
189
+ const map = /* @__PURE__ */ Object.create(null);
190
+ ee[this._kOtListeners] = map;
191
+ return map;
192
+ }
193
+ _getPatchMap(ee) {
194
+ return ee[this._kOtListeners];
195
+ }
196
+ };
197
+ exports.AbstractAsyncHooksContextManager = AbstractAsyncHooksContextManager;
198
+ }
199
+ });
200
+
201
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncHooksContextManager.js
202
+ var require_AsyncHooksContextManager = __commonJS({
203
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncHooksContextManager.js"(exports) {
204
+ "use strict";
205
+ Object.defineProperty(exports, "__esModule", { value: true });
206
+ exports.AsyncHooksContextManager = void 0;
207
+ var api_1 = __require("@opentelemetry/api");
208
+ var asyncHooks = __require("async_hooks");
209
+ var AbstractAsyncHooksContextManager_1 = require_AbstractAsyncHooksContextManager();
210
+ var AsyncHooksContextManager = class extends AbstractAsyncHooksContextManager_1.AbstractAsyncHooksContextManager {
211
+ constructor() {
212
+ super();
213
+ __publicField(this, "_asyncHook");
214
+ __publicField(this, "_contexts", /* @__PURE__ */ new Map());
215
+ __publicField(this, "_stack", []);
216
+ this._asyncHook = asyncHooks.createHook({
217
+ init: this._init.bind(this),
218
+ before: this._before.bind(this),
219
+ after: this._after.bind(this),
220
+ destroy: this._destroy.bind(this),
221
+ promiseResolve: this._destroy.bind(this)
222
+ });
223
+ }
224
+ active() {
225
+ var _a;
226
+ return (_a = this._stack[this._stack.length - 1]) != null ? _a : api_1.ROOT_CONTEXT;
227
+ }
228
+ with(context4, fn, thisArg, ...args) {
229
+ this._enterContext(context4);
230
+ try {
231
+ return fn.call(thisArg, ...args);
232
+ } finally {
233
+ this._exitContext();
234
+ }
235
+ }
236
+ enable() {
237
+ this._asyncHook.enable();
238
+ return this;
239
+ }
240
+ disable() {
241
+ this._asyncHook.disable();
242
+ this._contexts.clear();
243
+ this._stack = [];
244
+ return this;
245
+ }
246
+ /**
247
+ * Init hook will be called when userland create a async context, setting the
248
+ * context as the current one if it exist.
249
+ * @param uid id of the async context
250
+ * @param type the resource type
251
+ */
252
+ _init(uid, type) {
253
+ if (type === "TIMERWRAP")
254
+ return;
255
+ const context4 = this._stack[this._stack.length - 1];
256
+ if (context4 !== void 0) {
257
+ this._contexts.set(uid, context4);
258
+ }
259
+ }
260
+ /**
261
+ * Destroy hook will be called when a given context is no longer used so we can
262
+ * remove its attached context.
263
+ * @param uid uid of the async context
264
+ */
265
+ _destroy(uid) {
266
+ this._contexts.delete(uid);
267
+ }
268
+ /**
269
+ * Before hook is called just before executing a async context.
270
+ * @param uid uid of the async context
271
+ */
272
+ _before(uid) {
273
+ const context4 = this._contexts.get(uid);
274
+ if (context4 !== void 0) {
275
+ this._enterContext(context4);
276
+ }
277
+ }
278
+ /**
279
+ * After hook is called just after completing the execution of a async context.
280
+ */
281
+ _after() {
282
+ this._exitContext();
283
+ }
284
+ /**
285
+ * Set the given context as active
286
+ */
287
+ _enterContext(context4) {
288
+ this._stack.push(context4);
289
+ }
290
+ /**
291
+ * Remove the context at the root of the stack
292
+ */
293
+ _exitContext() {
294
+ this._stack.pop();
295
+ }
296
+ };
297
+ exports.AsyncHooksContextManager = AsyncHooksContextManager;
298
+ }
299
+ });
300
+
301
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js
302
+ var require_AsyncLocalStorageContextManager = __commonJS({
303
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js"(exports) {
304
+ "use strict";
305
+ Object.defineProperty(exports, "__esModule", { value: true });
306
+ exports.AsyncLocalStorageContextManager = void 0;
307
+ var api_1 = __require("@opentelemetry/api");
308
+ var async_hooks_1 = __require("async_hooks");
309
+ var AbstractAsyncHooksContextManager_1 = require_AbstractAsyncHooksContextManager();
310
+ var AsyncLocalStorageContextManager = class extends AbstractAsyncHooksContextManager_1.AbstractAsyncHooksContextManager {
311
+ constructor() {
312
+ super();
313
+ __publicField(this, "_asyncLocalStorage");
314
+ this._asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
315
+ }
316
+ active() {
317
+ var _a;
318
+ return (_a = this._asyncLocalStorage.getStore()) != null ? _a : api_1.ROOT_CONTEXT;
319
+ }
320
+ with(context4, fn, thisArg, ...args) {
321
+ const cb = thisArg == null ? fn : fn.bind(thisArg);
322
+ return this._asyncLocalStorage.run(context4, cb, ...args);
323
+ }
324
+ enable() {
325
+ return this;
326
+ }
327
+ disable() {
328
+ this._asyncLocalStorage.disable();
329
+ return this;
330
+ }
331
+ };
332
+ exports.AsyncLocalStorageContextManager = AsyncLocalStorageContextManager;
333
+ }
334
+ });
335
+
336
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/context-async-hooks/build/src/index.js
337
+ var require_src = __commonJS({
338
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/context-async-hooks/build/src/index.js"(exports) {
339
+ "use strict";
340
+ Object.defineProperty(exports, "__esModule", { value: true });
341
+ exports.AsyncLocalStorageContextManager = exports.AsyncHooksContextManager = void 0;
342
+ var AsyncHooksContextManager_1 = require_AsyncHooksContextManager();
343
+ Object.defineProperty(exports, "AsyncHooksContextManager", { enumerable: true, get: function() {
344
+ return AsyncHooksContextManager_1.AsyncHooksContextManager;
345
+ } });
346
+ var AsyncLocalStorageContextManager_1 = require_AsyncLocalStorageContextManager();
347
+ Object.defineProperty(exports, "AsyncLocalStorageContextManager", { enumerable: true, get: function() {
348
+ return AsyncLocalStorageContextManager_1.AsyncLocalStorageContextManager;
349
+ } });
350
+ }
351
+ });
352
+
353
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js
354
+ import { createContextKey } from "@opentelemetry/api";
355
+ function suppressTracing(context4) {
356
+ return context4.setValue(SUPPRESS_TRACING_KEY, true);
357
+ }
358
+ function unsuppressTracing(context4) {
359
+ return context4.deleteValue(SUPPRESS_TRACING_KEY);
360
+ }
361
+ function isTracingSuppressed(context4) {
362
+ return context4.getValue(SUPPRESS_TRACING_KEY) === true;
363
+ }
364
+ var SUPPRESS_TRACING_KEY;
365
+ var init_suppress_tracing = __esm({
366
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js"() {
367
+ "use strict";
368
+ SUPPRESS_TRACING_KEY = createContextKey("OpenTelemetry SDK Context Key SUPPRESS_TRACING");
369
+ }
370
+ });
371
+
372
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/baggage/constants.js
373
+ var BAGGAGE_KEY_PAIR_SEPARATOR, BAGGAGE_PROPERTIES_SEPARATOR, BAGGAGE_ITEMS_SEPARATOR, BAGGAGE_HEADER, BAGGAGE_MAX_NAME_VALUE_PAIRS, BAGGAGE_MAX_PER_NAME_VALUE_PAIRS, BAGGAGE_MAX_TOTAL_LENGTH;
374
+ var init_constants = __esm({
375
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/baggage/constants.js"() {
376
+ "use strict";
377
+ BAGGAGE_KEY_PAIR_SEPARATOR = "=";
378
+ BAGGAGE_PROPERTIES_SEPARATOR = ";";
379
+ BAGGAGE_ITEMS_SEPARATOR = ",";
380
+ BAGGAGE_HEADER = "baggage";
381
+ BAGGAGE_MAX_NAME_VALUE_PAIRS = 180;
382
+ BAGGAGE_MAX_PER_NAME_VALUE_PAIRS = 4096;
383
+ BAGGAGE_MAX_TOTAL_LENGTH = 8192;
384
+ }
385
+ });
386
+
387
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/baggage/utils.js
388
+ import { baggageEntryMetadataFromString } from "@opentelemetry/api";
389
+ function serializeKeyPairs(keyPairs) {
390
+ return keyPairs.reduce((hValue, current) => {
391
+ const value = `${hValue}${hValue !== "" ? BAGGAGE_ITEMS_SEPARATOR : ""}${current}`;
392
+ return value.length > BAGGAGE_MAX_TOTAL_LENGTH ? hValue : value;
393
+ }, "");
394
+ }
395
+ function getKeyPairs(baggage) {
396
+ return baggage.getAllEntries().map(([key, value]) => {
397
+ let entry = `${encodeURIComponent(key)}=${encodeURIComponent(value.value)}`;
398
+ if (value.metadata !== void 0) {
399
+ entry += BAGGAGE_PROPERTIES_SEPARATOR + value.metadata.toString();
400
+ }
401
+ return entry;
402
+ });
403
+ }
404
+ function parsePairKeyValue(entry) {
405
+ const valueProps = entry.split(BAGGAGE_PROPERTIES_SEPARATOR);
406
+ if (valueProps.length <= 0)
407
+ return;
408
+ const keyPairPart = valueProps.shift();
409
+ if (!keyPairPart)
410
+ return;
411
+ const separatorIndex = keyPairPart.indexOf(BAGGAGE_KEY_PAIR_SEPARATOR);
412
+ if (separatorIndex <= 0)
413
+ return;
414
+ const key = decodeURIComponent(keyPairPart.substring(0, separatorIndex).trim());
415
+ const value = decodeURIComponent(keyPairPart.substring(separatorIndex + 1).trim());
416
+ let metadata;
417
+ if (valueProps.length > 0) {
418
+ metadata = baggageEntryMetadataFromString(valueProps.join(BAGGAGE_PROPERTIES_SEPARATOR));
419
+ }
420
+ return { key, value, metadata };
421
+ }
422
+ function parseKeyPairsIntoRecord(value) {
423
+ const result = {};
424
+ if (typeof value === "string" && value.length > 0) {
425
+ value.split(BAGGAGE_ITEMS_SEPARATOR).forEach((entry) => {
426
+ const keyPair = parsePairKeyValue(entry);
427
+ if (keyPair !== void 0 && keyPair.value.length > 0) {
428
+ result[keyPair.key] = keyPair.value;
429
+ }
430
+ });
431
+ }
432
+ return result;
433
+ }
434
+ var init_utils = __esm({
435
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/baggage/utils.js"() {
436
+ "use strict";
437
+ init_constants();
438
+ }
439
+ });
440
+
441
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.js
442
+ import { propagation } from "@opentelemetry/api";
443
+ var W3CBaggagePropagator;
444
+ var init_W3CBaggagePropagator = __esm({
445
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.js"() {
446
+ "use strict";
447
+ init_suppress_tracing();
448
+ init_constants();
449
+ init_utils();
450
+ W3CBaggagePropagator = class {
451
+ inject(context4, carrier, setter) {
452
+ const baggage = propagation.getBaggage(context4);
453
+ if (!baggage || isTracingSuppressed(context4))
454
+ return;
455
+ const keyPairs = getKeyPairs(baggage).filter((pair) => {
456
+ return pair.length <= BAGGAGE_MAX_PER_NAME_VALUE_PAIRS;
457
+ }).slice(0, BAGGAGE_MAX_NAME_VALUE_PAIRS);
458
+ const headerValue = serializeKeyPairs(keyPairs);
459
+ if (headerValue.length > 0) {
460
+ setter.set(carrier, BAGGAGE_HEADER, headerValue);
461
+ }
462
+ }
463
+ extract(context4, carrier, getter) {
464
+ const headerValue = getter.get(carrier, BAGGAGE_HEADER);
465
+ const baggageString = Array.isArray(headerValue) ? headerValue.join(BAGGAGE_ITEMS_SEPARATOR) : headerValue;
466
+ if (!baggageString)
467
+ return context4;
468
+ const baggage = {};
469
+ if (baggageString.length === 0) {
470
+ return context4;
471
+ }
472
+ const pairs = baggageString.split(BAGGAGE_ITEMS_SEPARATOR);
473
+ pairs.forEach((entry) => {
474
+ const keyPair = parsePairKeyValue(entry);
475
+ if (keyPair) {
476
+ const baggageEntry = { value: keyPair.value };
477
+ if (keyPair.metadata) {
478
+ baggageEntry.metadata = keyPair.metadata;
479
+ }
480
+ baggage[keyPair.key] = baggageEntry;
481
+ }
482
+ });
483
+ if (Object.entries(baggage).length === 0) {
484
+ return context4;
485
+ }
486
+ return propagation.setBaggage(context4, propagation.createBaggage(baggage));
487
+ }
488
+ fields() {
489
+ return [BAGGAGE_HEADER];
490
+ }
491
+ };
492
+ }
493
+ });
494
+
495
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/anchored-clock.js
496
+ var AnchoredClock;
497
+ var init_anchored_clock = __esm({
498
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/anchored-clock.js"() {
499
+ "use strict";
500
+ AnchoredClock = class {
501
+ /**
502
+ * Create a new AnchoredClock anchored to the current time returned by systemClock.
503
+ *
504
+ * @param systemClock should be a clock that returns the number of milliseconds since January 1 1970 such as Date
505
+ * @param monotonicClock should be a clock that counts milliseconds monotonically such as window.performance or perf_hooks.performance
506
+ */
507
+ constructor(systemClock, monotonicClock) {
508
+ __publicField(this, "_monotonicClock");
509
+ __publicField(this, "_epochMillis");
510
+ __publicField(this, "_performanceMillis");
511
+ this._monotonicClock = monotonicClock;
512
+ this._epochMillis = systemClock.now();
513
+ this._performanceMillis = monotonicClock.now();
514
+ }
515
+ /**
516
+ * Returns the current time by adding the number of milliseconds since the
517
+ * AnchoredClock was created to the creation epoch time
518
+ */
519
+ now() {
520
+ const delta = this._monotonicClock.now() - this._performanceMillis;
521
+ return this._epochMillis + delta;
522
+ }
523
+ };
524
+ }
525
+ });
526
+
527
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/attributes.js
528
+ import { diag } from "@opentelemetry/api";
529
+ function sanitizeAttributes(attributes) {
530
+ const out = {};
531
+ if (typeof attributes !== "object" || attributes == null) {
532
+ return out;
533
+ }
534
+ for (const [key, val] of Object.entries(attributes)) {
535
+ if (!isAttributeKey(key)) {
536
+ diag.warn(`Invalid attribute key: ${key}`);
537
+ continue;
538
+ }
539
+ if (!isAttributeValue(val)) {
540
+ diag.warn(`Invalid attribute value set for key: ${key}`);
541
+ continue;
542
+ }
543
+ if (Array.isArray(val)) {
544
+ out[key] = val.slice();
545
+ } else {
546
+ out[key] = val;
547
+ }
548
+ }
549
+ return out;
550
+ }
551
+ function isAttributeKey(key) {
552
+ return typeof key === "string" && key.length > 0;
553
+ }
554
+ function isAttributeValue(val) {
555
+ if (val == null) {
556
+ return true;
557
+ }
558
+ if (Array.isArray(val)) {
559
+ return isHomogeneousAttributeValueArray(val);
560
+ }
561
+ return isValidPrimitiveAttributeValue(val);
562
+ }
563
+ function isHomogeneousAttributeValueArray(arr) {
564
+ let type;
565
+ for (const element of arr) {
566
+ if (element == null)
567
+ continue;
568
+ if (!type) {
569
+ if (isValidPrimitiveAttributeValue(element)) {
570
+ type = typeof element;
571
+ continue;
572
+ }
573
+ return false;
574
+ }
575
+ if (typeof element === type) {
576
+ continue;
577
+ }
578
+ return false;
579
+ }
580
+ return true;
581
+ }
582
+ function isValidPrimitiveAttributeValue(val) {
583
+ switch (typeof val) {
584
+ case "number":
585
+ case "boolean":
586
+ case "string":
587
+ return true;
588
+ }
589
+ return false;
590
+ }
591
+ var init_attributes = __esm({
592
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/attributes.js"() {
593
+ "use strict";
594
+ }
595
+ });
596
+
597
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js
598
+ import { diag as diag2 } from "@opentelemetry/api";
599
+ function loggingErrorHandler() {
600
+ return (ex) => {
601
+ diag2.error(stringifyException(ex));
602
+ };
603
+ }
604
+ function stringifyException(ex) {
605
+ if (typeof ex === "string") {
606
+ return ex;
607
+ } else {
608
+ return JSON.stringify(flattenException(ex));
609
+ }
610
+ }
611
+ function flattenException(ex) {
612
+ const result = {};
613
+ let current = ex;
614
+ while (current !== null) {
615
+ Object.getOwnPropertyNames(current).forEach((propertyName) => {
616
+ if (result[propertyName])
617
+ return;
618
+ const value = current[propertyName];
619
+ if (value) {
620
+ result[propertyName] = String(value);
621
+ }
622
+ });
623
+ current = Object.getPrototypeOf(current);
624
+ }
625
+ return result;
626
+ }
627
+ var init_logging_error_handler = __esm({
628
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js"() {
629
+ "use strict";
630
+ }
631
+ });
632
+
633
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js
634
+ function setGlobalErrorHandler(handler) {
635
+ delegateHandler = handler;
636
+ }
637
+ function globalErrorHandler(ex) {
638
+ try {
639
+ delegateHandler(ex);
640
+ } catch (e) {
641
+ }
642
+ }
643
+ var delegateHandler;
644
+ var init_global_error_handler = __esm({
645
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js"() {
646
+ "use strict";
647
+ init_logging_error_handler();
648
+ delegateHandler = loggingErrorHandler();
649
+ }
650
+ });
651
+
652
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js
653
+ import { diag as diag3 } from "@opentelemetry/api";
654
+ import { inspect } from "util";
655
+ function getNumberFromEnv(key) {
656
+ const raw = process.env[key];
657
+ if (raw == null || raw.trim() === "") {
658
+ return void 0;
659
+ }
660
+ const value = Number(raw);
661
+ if (isNaN(value)) {
662
+ diag3.warn(`Unknown value ${inspect(raw)} for ${key}, expected a number, using defaults`);
663
+ return void 0;
664
+ }
665
+ return value;
666
+ }
667
+ function getStringFromEnv(key) {
668
+ const raw = process.env[key];
669
+ if (raw == null || raw.trim() === "") {
670
+ return void 0;
671
+ }
672
+ return raw;
673
+ }
674
+ function getBooleanFromEnv(key) {
675
+ var _a;
676
+ const raw = (_a = process.env[key]) == null ? void 0 : _a.trim().toLowerCase();
677
+ if (raw == null || raw === "") {
678
+ return false;
679
+ }
680
+ if (raw === "true") {
681
+ return true;
682
+ } else if (raw === "false") {
683
+ return false;
684
+ } else {
685
+ diag3.warn(`Unknown value ${inspect(raw)} for ${key}, expected 'true' or 'false', falling back to 'false' (default)`);
686
+ return false;
687
+ }
688
+ }
689
+ function getStringListFromEnv(key) {
690
+ var _a;
691
+ return (_a = getStringFromEnv(key)) == null ? void 0 : _a.split(",").map((v) => v.trim()).filter((s) => s !== "");
692
+ }
693
+ var init_environment = __esm({
694
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js"() {
695
+ "use strict";
696
+ }
697
+ });
698
+
699
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/globalThis.js
700
+ var _globalThis;
701
+ var init_globalThis = __esm({
702
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/globalThis.js"() {
703
+ "use strict";
704
+ _globalThis = typeof globalThis === "object" ? globalThis : global;
705
+ }
706
+ });
707
+
708
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js
709
+ import { performance } from "perf_hooks";
710
+ var otperformance;
711
+ var init_performance = __esm({
712
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js"() {
713
+ "use strict";
714
+ otperformance = performance;
715
+ }
716
+ });
717
+
718
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/version.js
719
+ var VERSION;
720
+ var init_version = __esm({
721
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/version.js"() {
722
+ "use strict";
723
+ VERSION = "2.0.1";
724
+ }
725
+ });
726
+
727
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js
728
+ var init_SemanticAttributes = __esm({
729
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js"() {
730
+ "use strict";
731
+ }
732
+ });
733
+
734
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js
735
+ var init_trace = __esm({
736
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js"() {
737
+ "use strict";
738
+ init_SemanticAttributes();
739
+ }
740
+ });
741
+
742
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
743
+ var init_SemanticResourceAttributes = __esm({
744
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js"() {
745
+ "use strict";
746
+ }
747
+ });
748
+
749
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js
750
+ var init_resource = __esm({
751
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js"() {
752
+ "use strict";
753
+ init_SemanticResourceAttributes();
754
+ }
755
+ });
756
+
757
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
758
+ var ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, ATTR_EXCEPTION_TYPE, ATTR_TELEMETRY_SDK_LANGUAGE, TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_VERSION;
759
+ var init_stable_attributes = __esm({
760
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js"() {
761
+ "use strict";
762
+ ATTR_EXCEPTION_MESSAGE = "exception.message";
763
+ ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
764
+ ATTR_EXCEPTION_TYPE = "exception.type";
765
+ ATTR_TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language";
766
+ TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS = "nodejs";
767
+ ATTR_TELEMETRY_SDK_NAME = "telemetry.sdk.name";
768
+ ATTR_TELEMETRY_SDK_VERSION = "telemetry.sdk.version";
769
+ }
770
+ });
771
+
772
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js
773
+ var init_stable_metrics = __esm({
774
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js"() {
775
+ "use strict";
776
+ }
777
+ });
778
+
779
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js
780
+ var init_esm = __esm({
781
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js"() {
782
+ "use strict";
783
+ init_trace();
784
+ init_resource();
785
+ init_stable_attributes();
786
+ init_stable_metrics();
787
+ }
788
+ });
789
+
790
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/semconv.js
791
+ var ATTR_PROCESS_RUNTIME_NAME;
792
+ var init_semconv = __esm({
793
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/semconv.js"() {
794
+ "use strict";
795
+ ATTR_PROCESS_RUNTIME_NAME = "process.runtime.name";
796
+ }
797
+ });
798
+
799
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
800
+ var SDK_INFO;
801
+ var init_sdk_info = __esm({
802
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js"() {
803
+ "use strict";
804
+ init_version();
805
+ init_esm();
806
+ init_semconv();
807
+ SDK_INFO = {
808
+ [ATTR_TELEMETRY_SDK_NAME]: "opentelemetry",
809
+ [ATTR_PROCESS_RUNTIME_NAME]: "node",
810
+ [ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,
811
+ [ATTR_TELEMETRY_SDK_VERSION]: VERSION
812
+ };
813
+ }
814
+ });
815
+
816
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/timer-util.js
817
+ function unrefTimer(timer) {
818
+ timer.unref();
819
+ }
820
+ var init_timer_util = __esm({
821
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/timer-util.js"() {
822
+ "use strict";
823
+ }
824
+ });
825
+
826
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/index.js
827
+ var init_node = __esm({
828
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/node/index.js"() {
829
+ "use strict";
830
+ init_environment();
831
+ init_globalThis();
832
+ init_performance();
833
+ init_sdk_info();
834
+ init_timer_util();
835
+ }
836
+ });
837
+
838
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/index.js
839
+ var init_platform = __esm({
840
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/platform/index.js"() {
841
+ "use strict";
842
+ init_node();
843
+ }
844
+ });
845
+
846
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/time.js
847
+ function millisToHrTime(epochMillis) {
848
+ const epochSeconds = epochMillis / 1e3;
849
+ const seconds = Math.trunc(epochSeconds);
850
+ const nanos = Math.round(epochMillis % 1e3 * MILLISECONDS_TO_NANOSECONDS);
851
+ return [seconds, nanos];
852
+ }
853
+ function getTimeOrigin() {
854
+ let timeOrigin = otperformance.timeOrigin;
855
+ if (typeof timeOrigin !== "number") {
856
+ const perf = otperformance;
857
+ timeOrigin = perf.timing && perf.timing.fetchStart;
858
+ }
859
+ return timeOrigin;
860
+ }
861
+ function hrTime(performanceNow) {
862
+ const timeOrigin = millisToHrTime(getTimeOrigin());
863
+ const now = millisToHrTime(typeof performanceNow === "number" ? performanceNow : otperformance.now());
864
+ return addHrTimes(timeOrigin, now);
865
+ }
866
+ function timeInputToHrTime(time) {
867
+ if (isTimeInputHrTime(time)) {
868
+ return time;
869
+ } else if (typeof time === "number") {
870
+ if (time < getTimeOrigin()) {
871
+ return hrTime(time);
872
+ } else {
873
+ return millisToHrTime(time);
874
+ }
875
+ } else if (time instanceof Date) {
876
+ return millisToHrTime(time.getTime());
877
+ } else {
878
+ throw TypeError("Invalid input type");
879
+ }
880
+ }
881
+ function hrTimeDuration(startTime, endTime) {
882
+ let seconds = endTime[0] - startTime[0];
883
+ let nanos = endTime[1] - startTime[1];
884
+ if (nanos < 0) {
885
+ seconds -= 1;
886
+ nanos += SECOND_TO_NANOSECONDS;
887
+ }
888
+ return [seconds, nanos];
889
+ }
890
+ function hrTimeToTimeStamp(time) {
891
+ const precision = NANOSECOND_DIGITS;
892
+ const tmp = `${"0".repeat(precision)}${time[1]}Z`;
893
+ const nanoString = tmp.substring(tmp.length - precision - 1);
894
+ const date = new Date(time[0] * 1e3).toISOString();
895
+ return date.replace("000Z", nanoString);
896
+ }
897
+ function hrTimeToNanoseconds(time) {
898
+ return time[0] * SECOND_TO_NANOSECONDS + time[1];
899
+ }
900
+ function hrTimeToMilliseconds(time) {
901
+ return time[0] * 1e3 + time[1] / 1e6;
902
+ }
903
+ function hrTimeToMicroseconds(time) {
904
+ return time[0] * 1e6 + time[1] / 1e3;
905
+ }
906
+ function isTimeInputHrTime(value) {
907
+ return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" && typeof value[1] === "number";
908
+ }
909
+ function isTimeInput(value) {
910
+ return isTimeInputHrTime(value) || typeof value === "number" || value instanceof Date;
911
+ }
912
+ function addHrTimes(time1, time2) {
913
+ const out = [time1[0] + time2[0], time1[1] + time2[1]];
914
+ if (out[1] >= SECOND_TO_NANOSECONDS) {
915
+ out[1] -= SECOND_TO_NANOSECONDS;
916
+ out[0] += 1;
917
+ }
918
+ return out;
919
+ }
920
+ var NANOSECOND_DIGITS, NANOSECOND_DIGITS_IN_MILLIS, MILLISECONDS_TO_NANOSECONDS, SECOND_TO_NANOSECONDS;
921
+ var init_time = __esm({
922
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/common/time.js"() {
923
+ "use strict";
924
+ init_platform();
925
+ NANOSECOND_DIGITS = 9;
926
+ NANOSECOND_DIGITS_IN_MILLIS = 6;
927
+ MILLISECONDS_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS);
928
+ SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
929
+ }
930
+ });
931
+
932
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/ExportResult.js
933
+ var ExportResultCode;
934
+ var init_ExportResult = __esm({
935
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/ExportResult.js"() {
936
+ "use strict";
937
+ (function(ExportResultCode2) {
938
+ ExportResultCode2[ExportResultCode2["SUCCESS"] = 0] = "SUCCESS";
939
+ ExportResultCode2[ExportResultCode2["FAILED"] = 1] = "FAILED";
940
+ })(ExportResultCode || (ExportResultCode = {}));
941
+ }
942
+ });
943
+
944
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/propagation/composite.js
945
+ import { diag as diag4 } from "@opentelemetry/api";
946
+ var CompositePropagator;
947
+ var init_composite = __esm({
948
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/propagation/composite.js"() {
949
+ "use strict";
950
+ CompositePropagator = class {
951
+ /**
952
+ * Construct a composite propagator from a list of propagators.
953
+ *
954
+ * @param [config] Configuration object for composite propagator
955
+ */
956
+ constructor(config = {}) {
957
+ __publicField(this, "_propagators");
958
+ __publicField(this, "_fields");
959
+ var _a;
960
+ this._propagators = (_a = config.propagators) != null ? _a : [];
961
+ this._fields = Array.from(new Set(this._propagators.map((p) => typeof p.fields === "function" ? p.fields() : []).reduce((x, y) => x.concat(y), [])));
962
+ }
963
+ /**
964
+ * Run each of the configured propagators with the given context and carrier.
965
+ * Propagators are run in the order they are configured, so if multiple
966
+ * propagators write the same carrier key, the propagator later in the list
967
+ * will "win".
968
+ *
969
+ * @param context Context to inject
970
+ * @param carrier Carrier into which context will be injected
971
+ */
972
+ inject(context4, carrier, setter) {
973
+ for (const propagator of this._propagators) {
974
+ try {
975
+ propagator.inject(context4, carrier, setter);
976
+ } catch (err) {
977
+ diag4.warn(`Failed to inject with ${propagator.constructor.name}. Err: ${err.message}`);
978
+ }
979
+ }
980
+ }
981
+ /**
982
+ * Run each of the configured propagators with the given context and carrier.
983
+ * Propagators are run in the order they are configured, so if multiple
984
+ * propagators write the same context key, the propagator later in the list
985
+ * will "win".
986
+ *
987
+ * @param context Context to add values to
988
+ * @param carrier Carrier from which to extract context
989
+ */
990
+ extract(context4, carrier, getter) {
991
+ return this._propagators.reduce((ctx, propagator) => {
992
+ try {
993
+ return propagator.extract(ctx, carrier, getter);
994
+ } catch (err) {
995
+ diag4.warn(`Failed to extract with ${propagator.constructor.name}. Err: ${err.message}`);
996
+ }
997
+ return ctx;
998
+ }, context4);
999
+ }
1000
+ fields() {
1001
+ return this._fields.slice();
1002
+ }
1003
+ };
1004
+ }
1005
+ });
1006
+
1007
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/internal/validators.js
1008
+ function validateKey(key) {
1009
+ return VALID_KEY_REGEX.test(key);
1010
+ }
1011
+ function validateValue(value) {
1012
+ return VALID_VALUE_BASE_REGEX.test(value) && !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value);
1013
+ }
1014
+ var VALID_KEY_CHAR_RANGE, VALID_KEY, VALID_VENDOR_KEY, VALID_KEY_REGEX, VALID_VALUE_BASE_REGEX, INVALID_VALUE_COMMA_EQUAL_REGEX;
1015
+ var init_validators = __esm({
1016
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/internal/validators.js"() {
1017
+ "use strict";
1018
+ VALID_KEY_CHAR_RANGE = "[_0-9a-z-*/]";
1019
+ VALID_KEY = `[a-z]${VALID_KEY_CHAR_RANGE}{0,255}`;
1020
+ VALID_VENDOR_KEY = `[a-z0-9]${VALID_KEY_CHAR_RANGE}{0,240}@[a-z]${VALID_KEY_CHAR_RANGE}{0,13}`;
1021
+ VALID_KEY_REGEX = new RegExp(`^(?:${VALID_KEY}|${VALID_VENDOR_KEY})$`);
1022
+ VALID_VALUE_BASE_REGEX = /^[ -~]{0,255}[!-~]$/;
1023
+ INVALID_VALUE_COMMA_EQUAL_REGEX = /,|=/;
1024
+ }
1025
+ });
1026
+
1027
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/trace/TraceState.js
1028
+ var MAX_TRACE_STATE_ITEMS, MAX_TRACE_STATE_LEN, LIST_MEMBERS_SEPARATOR, LIST_MEMBER_KEY_VALUE_SPLITTER, TraceState;
1029
+ var init_TraceState = __esm({
1030
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/trace/TraceState.js"() {
1031
+ "use strict";
1032
+ init_validators();
1033
+ MAX_TRACE_STATE_ITEMS = 32;
1034
+ MAX_TRACE_STATE_LEN = 512;
1035
+ LIST_MEMBERS_SEPARATOR = ",";
1036
+ LIST_MEMBER_KEY_VALUE_SPLITTER = "=";
1037
+ TraceState = class _TraceState {
1038
+ constructor(rawTraceState) {
1039
+ __publicField(this, "_internalState", /* @__PURE__ */ new Map());
1040
+ if (rawTraceState)
1041
+ this._parse(rawTraceState);
1042
+ }
1043
+ set(key, value) {
1044
+ const traceState = this._clone();
1045
+ if (traceState._internalState.has(key)) {
1046
+ traceState._internalState.delete(key);
1047
+ }
1048
+ traceState._internalState.set(key, value);
1049
+ return traceState;
1050
+ }
1051
+ unset(key) {
1052
+ const traceState = this._clone();
1053
+ traceState._internalState.delete(key);
1054
+ return traceState;
1055
+ }
1056
+ get(key) {
1057
+ return this._internalState.get(key);
1058
+ }
1059
+ serialize() {
1060
+ return this._keys().reduce((agg, key) => {
1061
+ agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + this.get(key));
1062
+ return agg;
1063
+ }, []).join(LIST_MEMBERS_SEPARATOR);
1064
+ }
1065
+ _parse(rawTraceState) {
1066
+ if (rawTraceState.length > MAX_TRACE_STATE_LEN)
1067
+ return;
1068
+ this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reverse().reduce((agg, part) => {
1069
+ const listMember = part.trim();
1070
+ const i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
1071
+ if (i !== -1) {
1072
+ const key = listMember.slice(0, i);
1073
+ const value = listMember.slice(i + 1, part.length);
1074
+ if (validateKey(key) && validateValue(value)) {
1075
+ agg.set(key, value);
1076
+ } else {
1077
+ }
1078
+ }
1079
+ return agg;
1080
+ }, /* @__PURE__ */ new Map());
1081
+ if (this._internalState.size > MAX_TRACE_STATE_ITEMS) {
1082
+ this._internalState = new Map(Array.from(this._internalState.entries()).reverse().slice(0, MAX_TRACE_STATE_ITEMS));
1083
+ }
1084
+ }
1085
+ _keys() {
1086
+ return Array.from(this._internalState.keys()).reverse();
1087
+ }
1088
+ _clone() {
1089
+ const traceState = new _TraceState();
1090
+ traceState._internalState = new Map(this._internalState);
1091
+ return traceState;
1092
+ }
1093
+ };
1094
+ }
1095
+ });
1096
+
1097
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.js
1098
+ import { isSpanContextValid, trace, TraceFlags as TraceFlags2 } from "@opentelemetry/api";
1099
+ function parseTraceParent(traceParent) {
1100
+ const match = TRACE_PARENT_REGEX.exec(traceParent);
1101
+ if (!match)
1102
+ return null;
1103
+ if (match[1] === "00" && match[5])
1104
+ return null;
1105
+ return {
1106
+ traceId: match[2],
1107
+ spanId: match[3],
1108
+ traceFlags: parseInt(match[4], 16)
1109
+ };
1110
+ }
1111
+ var TRACE_PARENT_HEADER, TRACE_STATE_HEADER, VERSION2, VERSION_PART, TRACE_ID_PART, PARENT_ID_PART, FLAGS_PART, TRACE_PARENT_REGEX, W3CTraceContextPropagator;
1112
+ var init_W3CTraceContextPropagator = __esm({
1113
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.js"() {
1114
+ "use strict";
1115
+ init_suppress_tracing();
1116
+ init_TraceState();
1117
+ TRACE_PARENT_HEADER = "traceparent";
1118
+ TRACE_STATE_HEADER = "tracestate";
1119
+ VERSION2 = "00";
1120
+ VERSION_PART = "(?!ff)[\\da-f]{2}";
1121
+ TRACE_ID_PART = "(?![0]{32})[\\da-f]{32}";
1122
+ PARENT_ID_PART = "(?![0]{16})[\\da-f]{16}";
1123
+ FLAGS_PART = "[\\da-f]{2}";
1124
+ TRACE_PARENT_REGEX = new RegExp(`^\\s?(${VERSION_PART})-(${TRACE_ID_PART})-(${PARENT_ID_PART})-(${FLAGS_PART})(-.*)?\\s?$`);
1125
+ W3CTraceContextPropagator = class {
1126
+ inject(context4, carrier, setter) {
1127
+ const spanContext = trace.getSpanContext(context4);
1128
+ if (!spanContext || isTracingSuppressed(context4) || !isSpanContextValid(spanContext))
1129
+ return;
1130
+ const traceParent = `${VERSION2}-${spanContext.traceId}-${spanContext.spanId}-0${Number(spanContext.traceFlags || TraceFlags2.NONE).toString(16)}`;
1131
+ setter.set(carrier, TRACE_PARENT_HEADER, traceParent);
1132
+ if (spanContext.traceState) {
1133
+ setter.set(carrier, TRACE_STATE_HEADER, spanContext.traceState.serialize());
1134
+ }
1135
+ }
1136
+ extract(context4, carrier, getter) {
1137
+ const traceParentHeader = getter.get(carrier, TRACE_PARENT_HEADER);
1138
+ if (!traceParentHeader)
1139
+ return context4;
1140
+ const traceParent = Array.isArray(traceParentHeader) ? traceParentHeader[0] : traceParentHeader;
1141
+ if (typeof traceParent !== "string")
1142
+ return context4;
1143
+ const spanContext = parseTraceParent(traceParent);
1144
+ if (!spanContext)
1145
+ return context4;
1146
+ spanContext.isRemote = true;
1147
+ const traceStateHeader = getter.get(carrier, TRACE_STATE_HEADER);
1148
+ if (traceStateHeader) {
1149
+ const state = Array.isArray(traceStateHeader) ? traceStateHeader.join(",") : traceStateHeader;
1150
+ spanContext.traceState = new TraceState(typeof state === "string" ? state : void 0);
1151
+ }
1152
+ return trace.setSpanContext(context4, spanContext);
1153
+ }
1154
+ fields() {
1155
+ return [TRACE_PARENT_HEADER, TRACE_STATE_HEADER];
1156
+ }
1157
+ };
1158
+ }
1159
+ });
1160
+
1161
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/trace/rpc-metadata.js
1162
+ import { createContextKey as createContextKey2 } from "@opentelemetry/api";
1163
+ function setRPCMetadata(context4, meta) {
1164
+ return context4.setValue(RPC_METADATA_KEY, meta);
1165
+ }
1166
+ function deleteRPCMetadata(context4) {
1167
+ return context4.deleteValue(RPC_METADATA_KEY);
1168
+ }
1169
+ function getRPCMetadata(context4) {
1170
+ return context4.getValue(RPC_METADATA_KEY);
1171
+ }
1172
+ var RPC_METADATA_KEY, RPCType;
1173
+ var init_rpc_metadata = __esm({
1174
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/trace/rpc-metadata.js"() {
1175
+ "use strict";
1176
+ RPC_METADATA_KEY = createContextKey2("OpenTelemetry SDK Context Key RPC_METADATA");
1177
+ (function(RPCType2) {
1178
+ RPCType2["HTTP"] = "http";
1179
+ })(RPCType || (RPCType = {}));
1180
+ }
1181
+ });
1182
+
1183
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js
1184
+ function isPlainObject(value) {
1185
+ if (!isObjectLike(value) || baseGetTag(value) !== objectTag) {
1186
+ return false;
1187
+ }
1188
+ const proto = getPrototypeOf(value);
1189
+ if (proto === null) {
1190
+ return true;
1191
+ }
1192
+ const Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
1193
+ return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) === objectCtorString;
1194
+ }
1195
+ function isObjectLike(value) {
1196
+ return value != null && typeof value == "object";
1197
+ }
1198
+ function baseGetTag(value) {
1199
+ if (value == null) {
1200
+ return value === void 0 ? undefinedTag : nullTag;
1201
+ }
1202
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
1203
+ }
1204
+ function getRawTag(value) {
1205
+ const isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
1206
+ let unmasked = false;
1207
+ try {
1208
+ value[symToStringTag] = void 0;
1209
+ unmasked = true;
1210
+ } catch (e) {
1211
+ }
1212
+ const result = nativeObjectToString.call(value);
1213
+ if (unmasked) {
1214
+ if (isOwn) {
1215
+ value[symToStringTag] = tag;
1216
+ } else {
1217
+ delete value[symToStringTag];
1218
+ }
1219
+ }
1220
+ return result;
1221
+ }
1222
+ function objectToString(value) {
1223
+ return nativeObjectToString.call(value);
1224
+ }
1225
+ var objectTag, nullTag, undefinedTag, funcProto, funcToString, objectCtorString, getPrototypeOf, objectProto, hasOwnProperty, symToStringTag, nativeObjectToString;
1226
+ var init_lodash_merge = __esm({
1227
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js"() {
1228
+ "use strict";
1229
+ objectTag = "[object Object]";
1230
+ nullTag = "[object Null]";
1231
+ undefinedTag = "[object Undefined]";
1232
+ funcProto = Function.prototype;
1233
+ funcToString = funcProto.toString;
1234
+ objectCtorString = funcToString.call(Object);
1235
+ getPrototypeOf = Object.getPrototypeOf;
1236
+ objectProto = Object.prototype;
1237
+ hasOwnProperty = objectProto.hasOwnProperty;
1238
+ symToStringTag = Symbol ? Symbol.toStringTag : void 0;
1239
+ nativeObjectToString = objectProto.toString;
1240
+ }
1241
+ });
1242
+
1243
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/merge.js
1244
+ function merge(...args) {
1245
+ let result = args.shift();
1246
+ const objects = /* @__PURE__ */ new WeakMap();
1247
+ while (args.length > 0) {
1248
+ result = mergeTwoObjects(result, args.shift(), 0, objects);
1249
+ }
1250
+ return result;
1251
+ }
1252
+ function takeValue(value) {
1253
+ if (isArray(value)) {
1254
+ return value.slice();
1255
+ }
1256
+ return value;
1257
+ }
1258
+ function mergeTwoObjects(one, two, level = 0, objects) {
1259
+ let result;
1260
+ if (level > MAX_LEVEL) {
1261
+ return void 0;
1262
+ }
1263
+ level++;
1264
+ if (isPrimitive(one) || isPrimitive(two) || isFunction(two)) {
1265
+ result = takeValue(two);
1266
+ } else if (isArray(one)) {
1267
+ result = one.slice();
1268
+ if (isArray(two)) {
1269
+ for (let i = 0, j = two.length; i < j; i++) {
1270
+ result.push(takeValue(two[i]));
1271
+ }
1272
+ } else if (isObject(two)) {
1273
+ const keys = Object.keys(two);
1274
+ for (let i = 0, j = keys.length; i < j; i++) {
1275
+ const key = keys[i];
1276
+ result[key] = takeValue(two[key]);
1277
+ }
1278
+ }
1279
+ } else if (isObject(one)) {
1280
+ if (isObject(two)) {
1281
+ if (!shouldMerge(one, two)) {
1282
+ return two;
1283
+ }
1284
+ result = Object.assign({}, one);
1285
+ const keys = Object.keys(two);
1286
+ for (let i = 0, j = keys.length; i < j; i++) {
1287
+ const key = keys[i];
1288
+ const twoValue = two[key];
1289
+ if (isPrimitive(twoValue)) {
1290
+ if (typeof twoValue === "undefined") {
1291
+ delete result[key];
1292
+ } else {
1293
+ result[key] = twoValue;
1294
+ }
1295
+ } else {
1296
+ const obj1 = result[key];
1297
+ const obj2 = twoValue;
1298
+ if (wasObjectReferenced(one, key, objects) || wasObjectReferenced(two, key, objects)) {
1299
+ delete result[key];
1300
+ } else {
1301
+ if (isObject(obj1) && isObject(obj2)) {
1302
+ const arr1 = objects.get(obj1) || [];
1303
+ const arr2 = objects.get(obj2) || [];
1304
+ arr1.push({ obj: one, key });
1305
+ arr2.push({ obj: two, key });
1306
+ objects.set(obj1, arr1);
1307
+ objects.set(obj2, arr2);
1308
+ }
1309
+ result[key] = mergeTwoObjects(result[key], twoValue, level, objects);
1310
+ }
1311
+ }
1312
+ }
1313
+ } else {
1314
+ result = two;
1315
+ }
1316
+ }
1317
+ return result;
1318
+ }
1319
+ function wasObjectReferenced(obj, key, objects) {
1320
+ const arr = objects.get(obj[key]) || [];
1321
+ for (let i = 0, j = arr.length; i < j; i++) {
1322
+ const info = arr[i];
1323
+ if (info.key === key && info.obj === obj) {
1324
+ return true;
1325
+ }
1326
+ }
1327
+ return false;
1328
+ }
1329
+ function isArray(value) {
1330
+ return Array.isArray(value);
1331
+ }
1332
+ function isFunction(value) {
1333
+ return typeof value === "function";
1334
+ }
1335
+ function isObject(value) {
1336
+ return !isPrimitive(value) && !isArray(value) && !isFunction(value) && typeof value === "object";
1337
+ }
1338
+ function isPrimitive(value) {
1339
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "undefined" || value instanceof Date || value instanceof RegExp || value === null;
1340
+ }
1341
+ function shouldMerge(one, two) {
1342
+ if (!isPlainObject(one) || !isPlainObject(two)) {
1343
+ return false;
1344
+ }
1345
+ return true;
1346
+ }
1347
+ var MAX_LEVEL;
1348
+ var init_merge = __esm({
1349
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/merge.js"() {
1350
+ "use strict";
1351
+ init_lodash_merge();
1352
+ MAX_LEVEL = 20;
1353
+ }
1354
+ });
1355
+
1356
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/timeout.js
1357
+ function callWithTimeout(promise, timeout) {
1358
+ let timeoutHandle;
1359
+ const timeoutPromise = new Promise(function timeoutFunction(_resolve, reject) {
1360
+ timeoutHandle = setTimeout(function timeoutHandler() {
1361
+ reject(new TimeoutError("Operation timed out."));
1362
+ }, timeout);
1363
+ });
1364
+ return Promise.race([promise, timeoutPromise]).then((result) => {
1365
+ clearTimeout(timeoutHandle);
1366
+ return result;
1367
+ }, (reason) => {
1368
+ clearTimeout(timeoutHandle);
1369
+ throw reason;
1370
+ });
1371
+ }
1372
+ var TimeoutError;
1373
+ var init_timeout = __esm({
1374
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/timeout.js"() {
1375
+ "use strict";
1376
+ TimeoutError = class _TimeoutError extends Error {
1377
+ constructor(message) {
1378
+ super(message);
1379
+ Object.setPrototypeOf(this, _TimeoutError.prototype);
1380
+ }
1381
+ };
1382
+ }
1383
+ });
1384
+
1385
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/url.js
1386
+ function urlMatches(url, urlToMatch) {
1387
+ if (typeof urlToMatch === "string") {
1388
+ return url === urlToMatch;
1389
+ } else {
1390
+ return !!url.match(urlToMatch);
1391
+ }
1392
+ }
1393
+ function isUrlIgnored(url, ignoredUrls) {
1394
+ if (!ignoredUrls) {
1395
+ return false;
1396
+ }
1397
+ for (const ignoreUrl of ignoredUrls) {
1398
+ if (urlMatches(url, ignoreUrl)) {
1399
+ return true;
1400
+ }
1401
+ }
1402
+ return false;
1403
+ }
1404
+ var init_url = __esm({
1405
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/url.js"() {
1406
+ "use strict";
1407
+ }
1408
+ });
1409
+
1410
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/promise.js
1411
+ var Deferred;
1412
+ var init_promise = __esm({
1413
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/promise.js"() {
1414
+ "use strict";
1415
+ Deferred = class {
1416
+ constructor() {
1417
+ __publicField(this, "_promise");
1418
+ __publicField(this, "_resolve");
1419
+ __publicField(this, "_reject");
1420
+ this._promise = new Promise((resolve, reject) => {
1421
+ this._resolve = resolve;
1422
+ this._reject = reject;
1423
+ });
1424
+ }
1425
+ get promise() {
1426
+ return this._promise;
1427
+ }
1428
+ resolve(val) {
1429
+ this._resolve(val);
1430
+ }
1431
+ reject(err) {
1432
+ this._reject(err);
1433
+ }
1434
+ };
1435
+ }
1436
+ });
1437
+
1438
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/callback.js
1439
+ var BindOnceFuture;
1440
+ var init_callback = __esm({
1441
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/callback.js"() {
1442
+ "use strict";
1443
+ init_promise();
1444
+ BindOnceFuture = class {
1445
+ constructor(_callback, _that) {
1446
+ __publicField(this, "_callback");
1447
+ __publicField(this, "_that");
1448
+ __publicField(this, "_isCalled", false);
1449
+ __publicField(this, "_deferred", new Deferred());
1450
+ this._callback = _callback;
1451
+ this._that = _that;
1452
+ }
1453
+ get isCalled() {
1454
+ return this._isCalled;
1455
+ }
1456
+ get promise() {
1457
+ return this._deferred.promise;
1458
+ }
1459
+ call(...args) {
1460
+ if (!this._isCalled) {
1461
+ this._isCalled = true;
1462
+ try {
1463
+ Promise.resolve(this._callback.call(this._that, ...args)).then((val) => this._deferred.resolve(val), (err) => this._deferred.reject(err));
1464
+ } catch (err) {
1465
+ this._deferred.reject(err);
1466
+ }
1467
+ }
1468
+ return this._deferred.promise;
1469
+ }
1470
+ };
1471
+ }
1472
+ });
1473
+
1474
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/configuration.js
1475
+ import { diag as diag5, DiagLogLevel } from "@opentelemetry/api";
1476
+ function diagLogLevelFromString(value) {
1477
+ if (value == null) {
1478
+ return void 0;
1479
+ }
1480
+ const resolvedLogLevel = logLevelMap[value.toUpperCase()];
1481
+ if (resolvedLogLevel == null) {
1482
+ diag5.warn(`Unknown log level "${value}", expected one of ${Object.keys(logLevelMap)}, using default`);
1483
+ return DiagLogLevel.INFO;
1484
+ }
1485
+ return resolvedLogLevel;
1486
+ }
1487
+ var logLevelMap;
1488
+ var init_configuration = __esm({
1489
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/utils/configuration.js"() {
1490
+ "use strict";
1491
+ logLevelMap = {
1492
+ ALL: DiagLogLevel.ALL,
1493
+ VERBOSE: DiagLogLevel.VERBOSE,
1494
+ DEBUG: DiagLogLevel.DEBUG,
1495
+ INFO: DiagLogLevel.INFO,
1496
+ WARN: DiagLogLevel.WARN,
1497
+ ERROR: DiagLogLevel.ERROR,
1498
+ NONE: DiagLogLevel.NONE
1499
+ };
1500
+ }
1501
+ });
1502
+
1503
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/internal/exporter.js
1504
+ import { context } from "@opentelemetry/api";
1505
+ function _export(exporter, arg) {
1506
+ return new Promise((resolve) => {
1507
+ context.with(suppressTracing(context.active()), () => {
1508
+ exporter.export(arg, (result) => {
1509
+ resolve(result);
1510
+ });
1511
+ });
1512
+ });
1513
+ }
1514
+ var init_exporter = __esm({
1515
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/internal/exporter.js"() {
1516
+ "use strict";
1517
+ init_suppress_tracing();
1518
+ }
1519
+ });
1520
+
1521
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/index.js
1522
+ var esm_exports = {};
1523
+ __export(esm_exports, {
1524
+ AnchoredClock: () => AnchoredClock,
1525
+ BindOnceFuture: () => BindOnceFuture,
1526
+ CompositePropagator: () => CompositePropagator,
1527
+ ExportResultCode: () => ExportResultCode,
1528
+ RPCType: () => RPCType,
1529
+ SDK_INFO: () => SDK_INFO,
1530
+ TRACE_PARENT_HEADER: () => TRACE_PARENT_HEADER,
1531
+ TRACE_STATE_HEADER: () => TRACE_STATE_HEADER,
1532
+ TimeoutError: () => TimeoutError,
1533
+ TraceState: () => TraceState,
1534
+ W3CBaggagePropagator: () => W3CBaggagePropagator,
1535
+ W3CTraceContextPropagator: () => W3CTraceContextPropagator,
1536
+ _globalThis: () => _globalThis,
1537
+ addHrTimes: () => addHrTimes,
1538
+ callWithTimeout: () => callWithTimeout,
1539
+ deleteRPCMetadata: () => deleteRPCMetadata,
1540
+ diagLogLevelFromString: () => diagLogLevelFromString,
1541
+ getBooleanFromEnv: () => getBooleanFromEnv,
1542
+ getNumberFromEnv: () => getNumberFromEnv,
1543
+ getRPCMetadata: () => getRPCMetadata,
1544
+ getStringFromEnv: () => getStringFromEnv,
1545
+ getStringListFromEnv: () => getStringListFromEnv,
1546
+ getTimeOrigin: () => getTimeOrigin,
1547
+ globalErrorHandler: () => globalErrorHandler,
1548
+ hrTime: () => hrTime,
1549
+ hrTimeDuration: () => hrTimeDuration,
1550
+ hrTimeToMicroseconds: () => hrTimeToMicroseconds,
1551
+ hrTimeToMilliseconds: () => hrTimeToMilliseconds,
1552
+ hrTimeToNanoseconds: () => hrTimeToNanoseconds,
1553
+ hrTimeToTimeStamp: () => hrTimeToTimeStamp,
1554
+ internal: () => internal,
1555
+ isAttributeValue: () => isAttributeValue,
1556
+ isTimeInput: () => isTimeInput,
1557
+ isTimeInputHrTime: () => isTimeInputHrTime,
1558
+ isTracingSuppressed: () => isTracingSuppressed,
1559
+ isUrlIgnored: () => isUrlIgnored,
1560
+ loggingErrorHandler: () => loggingErrorHandler,
1561
+ merge: () => merge,
1562
+ millisToHrTime: () => millisToHrTime,
1563
+ otperformance: () => otperformance,
1564
+ parseKeyPairsIntoRecord: () => parseKeyPairsIntoRecord,
1565
+ parseTraceParent: () => parseTraceParent,
1566
+ sanitizeAttributes: () => sanitizeAttributes,
1567
+ setGlobalErrorHandler: () => setGlobalErrorHandler,
1568
+ setRPCMetadata: () => setRPCMetadata,
1569
+ suppressTracing: () => suppressTracing,
1570
+ timeInputToHrTime: () => timeInputToHrTime,
1571
+ unrefTimer: () => unrefTimer,
1572
+ unsuppressTracing: () => unsuppressTracing,
1573
+ urlMatches: () => urlMatches
1574
+ });
1575
+ var internal;
1576
+ var init_esm2 = __esm({
1577
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/core/build/esm/index.js"() {
1578
+ "use strict";
1579
+ init_W3CBaggagePropagator();
1580
+ init_anchored_clock();
1581
+ init_attributes();
1582
+ init_global_error_handler();
1583
+ init_logging_error_handler();
1584
+ init_time();
1585
+ init_ExportResult();
1586
+ init_utils();
1587
+ init_platform();
1588
+ init_composite();
1589
+ init_W3CTraceContextPropagator();
1590
+ init_rpc_metadata();
1591
+ init_suppress_tracing();
1592
+ init_TraceState();
1593
+ init_merge();
1594
+ init_timeout();
1595
+ init_url();
1596
+ init_callback();
1597
+ init_configuration();
1598
+ init_exporter();
1599
+ internal = {
1600
+ _export
1601
+ };
1602
+ }
1603
+ });
1604
+
1605
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js
1606
+ var ExceptionEventName;
1607
+ var init_enums = __esm({
1608
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js"() {
1609
+ "use strict";
1610
+ ExceptionEventName = "exception";
1611
+ }
1612
+ });
1613
+
1614
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js
1615
+ import { diag as diag6, SpanStatusCode } from "@opentelemetry/api";
1616
+ var SpanImpl;
1617
+ var init_Span = __esm({
1618
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js"() {
1619
+ "use strict";
1620
+ init_esm2();
1621
+ init_esm();
1622
+ init_enums();
1623
+ SpanImpl = class {
1624
+ /**
1625
+ * Constructs a new SpanImpl instance.
1626
+ */
1627
+ constructor(opts) {
1628
+ // Below properties are included to implement ReadableSpan for export
1629
+ // purposes but are not intended to be written-to directly.
1630
+ __publicField(this, "_spanContext");
1631
+ __publicField(this, "kind");
1632
+ __publicField(this, "parentSpanContext");
1633
+ __publicField(this, "attributes", {});
1634
+ __publicField(this, "links", []);
1635
+ __publicField(this, "events", []);
1636
+ __publicField(this, "startTime");
1637
+ __publicField(this, "resource");
1638
+ __publicField(this, "instrumentationScope");
1639
+ __publicField(this, "_droppedAttributesCount", 0);
1640
+ __publicField(this, "_droppedEventsCount", 0);
1641
+ __publicField(this, "_droppedLinksCount", 0);
1642
+ __publicField(this, "name");
1643
+ __publicField(this, "status", {
1644
+ code: SpanStatusCode.UNSET
1645
+ });
1646
+ __publicField(this, "endTime", [0, 0]);
1647
+ __publicField(this, "_ended", false);
1648
+ __publicField(this, "_duration", [-1, -1]);
1649
+ __publicField(this, "_spanProcessor");
1650
+ __publicField(this, "_spanLimits");
1651
+ __publicField(this, "_attributeValueLengthLimit");
1652
+ __publicField(this, "_performanceStartTime");
1653
+ __publicField(this, "_performanceOffset");
1654
+ __publicField(this, "_startTimeProvided");
1655
+ var _a;
1656
+ const now = Date.now();
1657
+ this._spanContext = opts.spanContext;
1658
+ this._performanceStartTime = otperformance.now();
1659
+ this._performanceOffset = now - (this._performanceStartTime + getTimeOrigin());
1660
+ this._startTimeProvided = opts.startTime != null;
1661
+ this._spanLimits = opts.spanLimits;
1662
+ this._attributeValueLengthLimit = this._spanLimits.attributeValueLengthLimit || 0;
1663
+ this._spanProcessor = opts.spanProcessor;
1664
+ this.name = opts.name;
1665
+ this.parentSpanContext = opts.parentSpanContext;
1666
+ this.kind = opts.kind;
1667
+ this.links = opts.links || [];
1668
+ this.startTime = this._getTime((_a = opts.startTime) != null ? _a : now);
1669
+ this.resource = opts.resource;
1670
+ this.instrumentationScope = opts.scope;
1671
+ if (opts.attributes != null) {
1672
+ this.setAttributes(opts.attributes);
1673
+ }
1674
+ this._spanProcessor.onStart(this, opts.context);
1675
+ }
1676
+ spanContext() {
1677
+ return this._spanContext;
1678
+ }
1679
+ setAttribute(key, value) {
1680
+ if (value == null || this._isSpanEnded())
1681
+ return this;
1682
+ if (key.length === 0) {
1683
+ diag6.warn(`Invalid attribute key: ${key}`);
1684
+ return this;
1685
+ }
1686
+ if (!isAttributeValue(value)) {
1687
+ diag6.warn(`Invalid attribute value set for key: ${key}`);
1688
+ return this;
1689
+ }
1690
+ const { attributeCountLimit } = this._spanLimits;
1691
+ if (attributeCountLimit !== void 0 && Object.keys(this.attributes).length >= attributeCountLimit && !Object.prototype.hasOwnProperty.call(this.attributes, key)) {
1692
+ this._droppedAttributesCount++;
1693
+ return this;
1694
+ }
1695
+ this.attributes[key] = this._truncateToSize(value);
1696
+ return this;
1697
+ }
1698
+ setAttributes(attributes) {
1699
+ for (const [k, v] of Object.entries(attributes)) {
1700
+ this.setAttribute(k, v);
1701
+ }
1702
+ return this;
1703
+ }
1704
+ /**
1705
+ *
1706
+ * @param name Span Name
1707
+ * @param [attributesOrStartTime] Span attributes or start time
1708
+ * if type is {@type TimeInput} and 3rd param is undefined
1709
+ * @param [timeStamp] Specified time stamp for the event
1710
+ */
1711
+ addEvent(name, attributesOrStartTime, timeStamp) {
1712
+ if (this._isSpanEnded())
1713
+ return this;
1714
+ const { eventCountLimit } = this._spanLimits;
1715
+ if (eventCountLimit === 0) {
1716
+ diag6.warn("No events allowed.");
1717
+ this._droppedEventsCount++;
1718
+ return this;
1719
+ }
1720
+ if (eventCountLimit !== void 0 && this.events.length >= eventCountLimit) {
1721
+ if (this._droppedEventsCount === 0) {
1722
+ diag6.debug("Dropping extra events.");
1723
+ }
1724
+ this.events.shift();
1725
+ this._droppedEventsCount++;
1726
+ }
1727
+ if (isTimeInput(attributesOrStartTime)) {
1728
+ if (!isTimeInput(timeStamp)) {
1729
+ timeStamp = attributesOrStartTime;
1730
+ }
1731
+ attributesOrStartTime = void 0;
1732
+ }
1733
+ const attributes = sanitizeAttributes(attributesOrStartTime);
1734
+ this.events.push({
1735
+ name,
1736
+ attributes,
1737
+ time: this._getTime(timeStamp),
1738
+ droppedAttributesCount: 0
1739
+ });
1740
+ return this;
1741
+ }
1742
+ addLink(link) {
1743
+ this.links.push(link);
1744
+ return this;
1745
+ }
1746
+ addLinks(links) {
1747
+ this.links.push(...links);
1748
+ return this;
1749
+ }
1750
+ setStatus(status) {
1751
+ if (this._isSpanEnded())
1752
+ return this;
1753
+ this.status = { ...status };
1754
+ if (this.status.message != null && typeof status.message !== "string") {
1755
+ diag6.warn(`Dropping invalid status.message of type '${typeof status.message}', expected 'string'`);
1756
+ delete this.status.message;
1757
+ }
1758
+ return this;
1759
+ }
1760
+ updateName(name) {
1761
+ if (this._isSpanEnded())
1762
+ return this;
1763
+ this.name = name;
1764
+ return this;
1765
+ }
1766
+ end(endTime) {
1767
+ if (this._isSpanEnded()) {
1768
+ diag6.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);
1769
+ return;
1770
+ }
1771
+ this._ended = true;
1772
+ this.endTime = this._getTime(endTime);
1773
+ this._duration = hrTimeDuration(this.startTime, this.endTime);
1774
+ if (this._duration[0] < 0) {
1775
+ diag6.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.", this.startTime, this.endTime);
1776
+ this.endTime = this.startTime.slice();
1777
+ this._duration = [0, 0];
1778
+ }
1779
+ if (this._droppedEventsCount > 0) {
1780
+ diag6.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`);
1781
+ }
1782
+ this._spanProcessor.onEnd(this);
1783
+ }
1784
+ _getTime(inp) {
1785
+ if (typeof inp === "number" && inp <= otperformance.now()) {
1786
+ return hrTime(inp + this._performanceOffset);
1787
+ }
1788
+ if (typeof inp === "number") {
1789
+ return millisToHrTime(inp);
1790
+ }
1791
+ if (inp instanceof Date) {
1792
+ return millisToHrTime(inp.getTime());
1793
+ }
1794
+ if (isTimeInputHrTime(inp)) {
1795
+ return inp;
1796
+ }
1797
+ if (this._startTimeProvided) {
1798
+ return millisToHrTime(Date.now());
1799
+ }
1800
+ const msDuration = otperformance.now() - this._performanceStartTime;
1801
+ return addHrTimes(this.startTime, millisToHrTime(msDuration));
1802
+ }
1803
+ isRecording() {
1804
+ return this._ended === false;
1805
+ }
1806
+ recordException(exception, time) {
1807
+ const attributes = {};
1808
+ if (typeof exception === "string") {
1809
+ attributes[ATTR_EXCEPTION_MESSAGE] = exception;
1810
+ } else if (exception) {
1811
+ if (exception.code) {
1812
+ attributes[ATTR_EXCEPTION_TYPE] = exception.code.toString();
1813
+ } else if (exception.name) {
1814
+ attributes[ATTR_EXCEPTION_TYPE] = exception.name;
1815
+ }
1816
+ if (exception.message) {
1817
+ attributes[ATTR_EXCEPTION_MESSAGE] = exception.message;
1818
+ }
1819
+ if (exception.stack) {
1820
+ attributes[ATTR_EXCEPTION_STACKTRACE] = exception.stack;
1821
+ }
1822
+ }
1823
+ if (attributes[ATTR_EXCEPTION_TYPE] || attributes[ATTR_EXCEPTION_MESSAGE]) {
1824
+ this.addEvent(ExceptionEventName, attributes, time);
1825
+ } else {
1826
+ diag6.warn(`Failed to record an exception ${exception}`);
1827
+ }
1828
+ }
1829
+ get duration() {
1830
+ return this._duration;
1831
+ }
1832
+ get ended() {
1833
+ return this._ended;
1834
+ }
1835
+ get droppedAttributesCount() {
1836
+ return this._droppedAttributesCount;
1837
+ }
1838
+ get droppedEventsCount() {
1839
+ return this._droppedEventsCount;
1840
+ }
1841
+ get droppedLinksCount() {
1842
+ return this._droppedLinksCount;
1843
+ }
1844
+ _isSpanEnded() {
1845
+ if (this._ended) {
1846
+ const error = new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);
1847
+ diag6.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`, error);
1848
+ }
1849
+ return this._ended;
1850
+ }
1851
+ // Utility function to truncate given value within size
1852
+ // for value type of string, will truncate to given limit
1853
+ // for type of non-string, will return same value
1854
+ _truncateToLimitUtil(value, limit) {
1855
+ if (value.length <= limit) {
1856
+ return value;
1857
+ }
1858
+ return value.substring(0, limit);
1859
+ }
1860
+ /**
1861
+ * If the given attribute value is of type string and has more characters than given {@code attributeValueLengthLimit} then
1862
+ * return string with truncated to {@code attributeValueLengthLimit} characters
1863
+ *
1864
+ * If the given attribute value is array of strings then
1865
+ * return new array of strings with each element truncated to {@code attributeValueLengthLimit} characters
1866
+ *
1867
+ * Otherwise return same Attribute {@code value}
1868
+ *
1869
+ * @param value Attribute value
1870
+ * @returns truncated attribute value if required, otherwise same value
1871
+ */
1872
+ _truncateToSize(value) {
1873
+ const limit = this._attributeValueLengthLimit;
1874
+ if (limit <= 0) {
1875
+ diag6.warn(`Attribute value limit must be positive, got ${limit}`);
1876
+ return value;
1877
+ }
1878
+ if (typeof value === "string") {
1879
+ return this._truncateToLimitUtil(value, limit);
1880
+ }
1881
+ if (Array.isArray(value)) {
1882
+ return value.map((val) => typeof val === "string" ? this._truncateToLimitUtil(val, limit) : val);
1883
+ }
1884
+ return value;
1885
+ }
1886
+ };
1887
+ }
1888
+ });
1889
+
1890
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js
1891
+ var SamplingDecision;
1892
+ var init_Sampler = __esm({
1893
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js"() {
1894
+ "use strict";
1895
+ (function(SamplingDecision3) {
1896
+ SamplingDecision3[SamplingDecision3["NOT_RECORD"] = 0] = "NOT_RECORD";
1897
+ SamplingDecision3[SamplingDecision3["RECORD"] = 1] = "RECORD";
1898
+ SamplingDecision3[SamplingDecision3["RECORD_AND_SAMPLED"] = 2] = "RECORD_AND_SAMPLED";
1899
+ })(SamplingDecision || (SamplingDecision = {}));
1900
+ }
1901
+ });
1902
+
1903
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js
1904
+ var AlwaysOffSampler;
1905
+ var init_AlwaysOffSampler = __esm({
1906
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js"() {
1907
+ "use strict";
1908
+ init_Sampler();
1909
+ AlwaysOffSampler = class {
1910
+ shouldSample() {
1911
+ return {
1912
+ decision: SamplingDecision.NOT_RECORD
1913
+ };
1914
+ }
1915
+ toString() {
1916
+ return "AlwaysOffSampler";
1917
+ }
1918
+ };
1919
+ }
1920
+ });
1921
+
1922
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js
1923
+ var AlwaysOnSampler;
1924
+ var init_AlwaysOnSampler = __esm({
1925
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js"() {
1926
+ "use strict";
1927
+ init_Sampler();
1928
+ AlwaysOnSampler = class {
1929
+ shouldSample() {
1930
+ return {
1931
+ decision: SamplingDecision.RECORD_AND_SAMPLED
1932
+ };
1933
+ }
1934
+ toString() {
1935
+ return "AlwaysOnSampler";
1936
+ }
1937
+ };
1938
+ }
1939
+ });
1940
+
1941
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js
1942
+ import { isSpanContextValid as isSpanContextValid2, TraceFlags as TraceFlags3, trace as trace2 } from "@opentelemetry/api";
1943
+ var ParentBasedSampler;
1944
+ var init_ParentBasedSampler = __esm({
1945
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js"() {
1946
+ "use strict";
1947
+ init_esm2();
1948
+ init_AlwaysOffSampler();
1949
+ init_AlwaysOnSampler();
1950
+ ParentBasedSampler = class {
1951
+ constructor(config) {
1952
+ __publicField(this, "_root");
1953
+ __publicField(this, "_remoteParentSampled");
1954
+ __publicField(this, "_remoteParentNotSampled");
1955
+ __publicField(this, "_localParentSampled");
1956
+ __publicField(this, "_localParentNotSampled");
1957
+ var _a, _b, _c, _d;
1958
+ this._root = config.root;
1959
+ if (!this._root) {
1960
+ globalErrorHandler(new Error("ParentBasedSampler must have a root sampler configured"));
1961
+ this._root = new AlwaysOnSampler();
1962
+ }
1963
+ this._remoteParentSampled = (_a = config.remoteParentSampled) != null ? _a : new AlwaysOnSampler();
1964
+ this._remoteParentNotSampled = (_b = config.remoteParentNotSampled) != null ? _b : new AlwaysOffSampler();
1965
+ this._localParentSampled = (_c = config.localParentSampled) != null ? _c : new AlwaysOnSampler();
1966
+ this._localParentNotSampled = (_d = config.localParentNotSampled) != null ? _d : new AlwaysOffSampler();
1967
+ }
1968
+ shouldSample(context4, traceId, spanName, spanKind, attributes, links) {
1969
+ const parentContext = trace2.getSpanContext(context4);
1970
+ if (!parentContext || !isSpanContextValid2(parentContext)) {
1971
+ return this._root.shouldSample(context4, traceId, spanName, spanKind, attributes, links);
1972
+ }
1973
+ if (parentContext.isRemote) {
1974
+ if (parentContext.traceFlags & TraceFlags3.SAMPLED) {
1975
+ return this._remoteParentSampled.shouldSample(context4, traceId, spanName, spanKind, attributes, links);
1976
+ }
1977
+ return this._remoteParentNotSampled.shouldSample(context4, traceId, spanName, spanKind, attributes, links);
1978
+ }
1979
+ if (parentContext.traceFlags & TraceFlags3.SAMPLED) {
1980
+ return this._localParentSampled.shouldSample(context4, traceId, spanName, spanKind, attributes, links);
1981
+ }
1982
+ return this._localParentNotSampled.shouldSample(context4, traceId, spanName, spanKind, attributes, links);
1983
+ }
1984
+ toString() {
1985
+ return `ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`;
1986
+ }
1987
+ };
1988
+ }
1989
+ });
1990
+
1991
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js
1992
+ import { isValidTraceId } from "@opentelemetry/api";
1993
+ var TraceIdRatioBasedSampler;
1994
+ var init_TraceIdRatioBasedSampler = __esm({
1995
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js"() {
1996
+ "use strict";
1997
+ init_Sampler();
1998
+ TraceIdRatioBasedSampler = class {
1999
+ constructor(_ratio = 0) {
2000
+ __publicField(this, "_ratio");
2001
+ __publicField(this, "_upperBound");
2002
+ this._ratio = _ratio;
2003
+ this._ratio = this._normalize(_ratio);
2004
+ this._upperBound = Math.floor(this._ratio * 4294967295);
2005
+ }
2006
+ shouldSample(context4, traceId) {
2007
+ return {
2008
+ decision: isValidTraceId(traceId) && this._accumulate(traceId) < this._upperBound ? SamplingDecision.RECORD_AND_SAMPLED : SamplingDecision.NOT_RECORD
2009
+ };
2010
+ }
2011
+ toString() {
2012
+ return `TraceIdRatioBased{${this._ratio}}`;
2013
+ }
2014
+ _normalize(ratio) {
2015
+ if (typeof ratio !== "number" || isNaN(ratio))
2016
+ return 0;
2017
+ return ratio >= 1 ? 1 : ratio <= 0 ? 0 : ratio;
2018
+ }
2019
+ _accumulate(traceId) {
2020
+ let accumulation = 0;
2021
+ for (let i = 0; i < traceId.length / 8; i++) {
2022
+ const pos = i * 8;
2023
+ const part = parseInt(traceId.slice(pos, pos + 8), 16);
2024
+ accumulation = (accumulation ^ part) >>> 0;
2025
+ }
2026
+ return accumulation;
2027
+ }
2028
+ };
2029
+ }
2030
+ });
2031
+
2032
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js
2033
+ import { diag as diag7 } from "@opentelemetry/api";
2034
+ function loadDefaultConfig() {
2035
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2036
+ return {
2037
+ sampler: buildSamplerFromEnv(),
2038
+ forceFlushTimeoutMillis: 3e4,
2039
+ generalLimits: {
2040
+ attributeValueLengthLimit: (_a = getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT")) != null ? _a : Infinity,
2041
+ attributeCountLimit: (_b = getNumberFromEnv("OTEL_ATTRIBUTE_COUNT_LIMIT")) != null ? _b : 128
2042
+ },
2043
+ spanLimits: {
2044
+ attributeValueLengthLimit: (_c = getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT")) != null ? _c : Infinity,
2045
+ attributeCountLimit: (_d = getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT")) != null ? _d : 128,
2046
+ linkCountLimit: (_e = getNumberFromEnv("OTEL_SPAN_LINK_COUNT_LIMIT")) != null ? _e : 128,
2047
+ eventCountLimit: (_f = getNumberFromEnv("OTEL_SPAN_EVENT_COUNT_LIMIT")) != null ? _f : 128,
2048
+ attributePerEventCountLimit: (_g = getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT")) != null ? _g : 128,
2049
+ attributePerLinkCountLimit: (_h = getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT")) != null ? _h : 128
2050
+ }
2051
+ };
2052
+ }
2053
+ function buildSamplerFromEnv() {
2054
+ var _a;
2055
+ const sampler = (_a = getStringFromEnv("OTEL_TRACES_SAMPLER")) != null ? _a : "parentbased_always_on";
2056
+ switch (sampler) {
2057
+ case "always_on":
2058
+ return new AlwaysOnSampler();
2059
+ case "always_off":
2060
+ return new AlwaysOffSampler();
2061
+ case "parentbased_always_on":
2062
+ return new ParentBasedSampler({
2063
+ root: new AlwaysOnSampler()
2064
+ });
2065
+ case "parentbased_always_off":
2066
+ return new ParentBasedSampler({
2067
+ root: new AlwaysOffSampler()
2068
+ });
2069
+ case "traceidratio":
2070
+ return new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv());
2071
+ case "parentbased_traceidratio":
2072
+ return new ParentBasedSampler({
2073
+ root: new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv())
2074
+ });
2075
+ default:
2076
+ diag7.error(`OTEL_TRACES_SAMPLER value "${sampler}" invalid, defaulting to "${"parentbased_always_on"}".`);
2077
+ return new ParentBasedSampler({
2078
+ root: new AlwaysOnSampler()
2079
+ });
2080
+ }
2081
+ }
2082
+ function getSamplerProbabilityFromEnv() {
2083
+ const probability = getNumberFromEnv("OTEL_TRACES_SAMPLER_ARG");
2084
+ if (probability == null) {
2085
+ diag7.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${DEFAULT_RATIO}.`);
2086
+ return DEFAULT_RATIO;
2087
+ }
2088
+ if (probability < 0 || probability > 1) {
2089
+ diag7.error(`OTEL_TRACES_SAMPLER_ARG=${probability} was given, but it is out of range ([0..1]), defaulting to ${DEFAULT_RATIO}.`);
2090
+ return DEFAULT_RATIO;
2091
+ }
2092
+ return probability;
2093
+ }
2094
+ var DEFAULT_RATIO;
2095
+ var init_config = __esm({
2096
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js"() {
2097
+ "use strict";
2098
+ init_esm2();
2099
+ init_AlwaysOffSampler();
2100
+ init_AlwaysOnSampler();
2101
+ init_ParentBasedSampler();
2102
+ init_TraceIdRatioBasedSampler();
2103
+ DEFAULT_RATIO = 1;
2104
+ }
2105
+ });
2106
+
2107
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js
2108
+ function mergeConfig(userConfig) {
2109
+ const perInstanceDefaults = {
2110
+ sampler: buildSamplerFromEnv()
2111
+ };
2112
+ const DEFAULT_CONFIG = loadDefaultConfig();
2113
+ const target = Object.assign({}, DEFAULT_CONFIG, perInstanceDefaults, userConfig);
2114
+ target.generalLimits = Object.assign({}, DEFAULT_CONFIG.generalLimits, userConfig.generalLimits || {});
2115
+ target.spanLimits = Object.assign({}, DEFAULT_CONFIG.spanLimits, userConfig.spanLimits || {});
2116
+ return target;
2117
+ }
2118
+ function reconfigureLimits(userConfig) {
2119
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2120
+ const spanLimits = Object.assign({}, userConfig.spanLimits);
2121
+ spanLimits.attributeCountLimit = (_f = (_e = (_d = (_c = (_a = userConfig.spanLimits) == null ? void 0 : _a.attributeCountLimit) != null ? _c : (_b = userConfig.generalLimits) == null ? void 0 : _b.attributeCountLimit) != null ? _d : getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT")) != null ? _e : getNumberFromEnv("OTEL_ATTRIBUTE_COUNT_LIMIT")) != null ? _f : DEFAULT_ATTRIBUTE_COUNT_LIMIT;
2122
+ spanLimits.attributeValueLengthLimit = (_l = (_k = (_j = (_i = (_g = userConfig.spanLimits) == null ? void 0 : _g.attributeValueLengthLimit) != null ? _i : (_h = userConfig.generalLimits) == null ? void 0 : _h.attributeValueLengthLimit) != null ? _j : getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT")) != null ? _k : getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT")) != null ? _l : DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
2123
+ return Object.assign({}, userConfig, { spanLimits });
2124
+ }
2125
+ var DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
2126
+ var init_utility = __esm({
2127
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js"() {
2128
+ "use strict";
2129
+ init_config();
2130
+ init_esm2();
2131
+ DEFAULT_ATTRIBUTE_COUNT_LIMIT = 128;
2132
+ DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT = Infinity;
2133
+ }
2134
+ });
2135
+
2136
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js
2137
+ import { context as context2, diag as diag8, TraceFlags as TraceFlags4 } from "@opentelemetry/api";
2138
+ var BatchSpanProcessorBase;
2139
+ var init_BatchSpanProcessorBase = __esm({
2140
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js"() {
2141
+ "use strict";
2142
+ init_esm2();
2143
+ BatchSpanProcessorBase = class {
2144
+ constructor(_exporter, config) {
2145
+ __publicField(this, "_exporter");
2146
+ __publicField(this, "_maxExportBatchSize");
2147
+ __publicField(this, "_maxQueueSize");
2148
+ __publicField(this, "_scheduledDelayMillis");
2149
+ __publicField(this, "_exportTimeoutMillis");
2150
+ __publicField(this, "_isExporting", false);
2151
+ __publicField(this, "_finishedSpans", []);
2152
+ __publicField(this, "_timer");
2153
+ __publicField(this, "_shutdownOnce");
2154
+ __publicField(this, "_droppedSpansCount", 0);
2155
+ var _a, _b, _c, _d;
2156
+ this._exporter = _exporter;
2157
+ this._maxExportBatchSize = typeof (config == null ? void 0 : config.maxExportBatchSize) === "number" ? config.maxExportBatchSize : (_a = getNumberFromEnv("OTEL_BSP_MAX_EXPORT_BATCH_SIZE")) != null ? _a : 512;
2158
+ this._maxQueueSize = typeof (config == null ? void 0 : config.maxQueueSize) === "number" ? config.maxQueueSize : (_b = getNumberFromEnv("OTEL_BSP_MAX_QUEUE_SIZE")) != null ? _b : 2048;
2159
+ this._scheduledDelayMillis = typeof (config == null ? void 0 : config.scheduledDelayMillis) === "number" ? config.scheduledDelayMillis : (_c = getNumberFromEnv("OTEL_BSP_SCHEDULE_DELAY")) != null ? _c : 5e3;
2160
+ this._exportTimeoutMillis = typeof (config == null ? void 0 : config.exportTimeoutMillis) === "number" ? config.exportTimeoutMillis : (_d = getNumberFromEnv("OTEL_BSP_EXPORT_TIMEOUT")) != null ? _d : 3e4;
2161
+ this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
2162
+ if (this._maxExportBatchSize > this._maxQueueSize) {
2163
+ diag8.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize");
2164
+ this._maxExportBatchSize = this._maxQueueSize;
2165
+ }
2166
+ }
2167
+ forceFlush() {
2168
+ if (this._shutdownOnce.isCalled) {
2169
+ return this._shutdownOnce.promise;
2170
+ }
2171
+ return this._flushAll();
2172
+ }
2173
+ // does nothing.
2174
+ onStart(_span, _parentContext) {
2175
+ }
2176
+ onEnd(span) {
2177
+ if (this._shutdownOnce.isCalled) {
2178
+ return;
2179
+ }
2180
+ if ((span.spanContext().traceFlags & TraceFlags4.SAMPLED) === 0) {
2181
+ return;
2182
+ }
2183
+ this._addToBuffer(span);
2184
+ }
2185
+ shutdown() {
2186
+ return this._shutdownOnce.call();
2187
+ }
2188
+ _shutdown() {
2189
+ return Promise.resolve().then(() => {
2190
+ return this.onShutdown();
2191
+ }).then(() => {
2192
+ return this._flushAll();
2193
+ }).then(() => {
2194
+ return this._exporter.shutdown();
2195
+ });
2196
+ }
2197
+ /** Add a span in the buffer. */
2198
+ _addToBuffer(span) {
2199
+ if (this._finishedSpans.length >= this._maxQueueSize) {
2200
+ if (this._droppedSpansCount === 0) {
2201
+ diag8.debug("maxQueueSize reached, dropping spans");
2202
+ }
2203
+ this._droppedSpansCount++;
2204
+ return;
2205
+ }
2206
+ if (this._droppedSpansCount > 0) {
2207
+ diag8.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`);
2208
+ this._droppedSpansCount = 0;
2209
+ }
2210
+ this._finishedSpans.push(span);
2211
+ this._maybeStartTimer();
2212
+ }
2213
+ /**
2214
+ * Send all spans to the exporter respecting the batch size limit
2215
+ * This function is used only on forceFlush or shutdown,
2216
+ * for all other cases _flush should be used
2217
+ * */
2218
+ _flushAll() {
2219
+ return new Promise((resolve, reject) => {
2220
+ const promises = [];
2221
+ const count = Math.ceil(this._finishedSpans.length / this._maxExportBatchSize);
2222
+ for (let i = 0, j = count; i < j; i++) {
2223
+ promises.push(this._flushOneBatch());
2224
+ }
2225
+ Promise.all(promises).then(() => {
2226
+ resolve();
2227
+ }).catch(reject);
2228
+ });
2229
+ }
2230
+ _flushOneBatch() {
2231
+ this._clearTimer();
2232
+ if (this._finishedSpans.length === 0) {
2233
+ return Promise.resolve();
2234
+ }
2235
+ return new Promise((resolve, reject) => {
2236
+ const timer = setTimeout(() => {
2237
+ reject(new Error("Timeout"));
2238
+ }, this._exportTimeoutMillis);
2239
+ context2.with(suppressTracing(context2.active()), () => {
2240
+ let spans;
2241
+ if (this._finishedSpans.length <= this._maxExportBatchSize) {
2242
+ spans = this._finishedSpans;
2243
+ this._finishedSpans = [];
2244
+ } else {
2245
+ spans = this._finishedSpans.splice(0, this._maxExportBatchSize);
2246
+ }
2247
+ const doExport = () => this._exporter.export(spans, (result) => {
2248
+ var _a;
2249
+ clearTimeout(timer);
2250
+ if (result.code === ExportResultCode.SUCCESS) {
2251
+ resolve();
2252
+ } else {
2253
+ reject((_a = result.error) != null ? _a : new Error("BatchSpanProcessor: span export failed"));
2254
+ }
2255
+ });
2256
+ let pendingResources = null;
2257
+ for (let i = 0, len = spans.length; i < len; i++) {
2258
+ const span = spans[i];
2259
+ if (span.resource.asyncAttributesPending && span.resource.waitForAsyncAttributes) {
2260
+ pendingResources != null ? pendingResources : pendingResources = [];
2261
+ pendingResources.push(span.resource.waitForAsyncAttributes());
2262
+ }
2263
+ }
2264
+ if (pendingResources === null) {
2265
+ doExport();
2266
+ } else {
2267
+ Promise.all(pendingResources).then(doExport, (err) => {
2268
+ globalErrorHandler(err);
2269
+ reject(err);
2270
+ });
2271
+ }
2272
+ });
2273
+ });
2274
+ }
2275
+ _maybeStartTimer() {
2276
+ if (this._isExporting)
2277
+ return;
2278
+ const flush = () => {
2279
+ this._isExporting = true;
2280
+ this._flushOneBatch().finally(() => {
2281
+ this._isExporting = false;
2282
+ if (this._finishedSpans.length > 0) {
2283
+ this._clearTimer();
2284
+ this._maybeStartTimer();
2285
+ }
2286
+ }).catch((e) => {
2287
+ this._isExporting = false;
2288
+ globalErrorHandler(e);
2289
+ });
2290
+ };
2291
+ if (this._finishedSpans.length >= this._maxExportBatchSize) {
2292
+ return flush();
2293
+ }
2294
+ if (this._timer !== void 0)
2295
+ return;
2296
+ this._timer = setTimeout(() => flush(), this._scheduledDelayMillis);
2297
+ unrefTimer(this._timer);
2298
+ }
2299
+ _clearTimer() {
2300
+ if (this._timer !== void 0) {
2301
+ clearTimeout(this._timer);
2302
+ this._timer = void 0;
2303
+ }
2304
+ }
2305
+ };
2306
+ }
2307
+ });
2308
+
2309
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js
2310
+ var BatchSpanProcessor;
2311
+ var init_BatchSpanProcessor = __esm({
2312
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js"() {
2313
+ "use strict";
2314
+ init_BatchSpanProcessorBase();
2315
+ BatchSpanProcessor = class extends BatchSpanProcessorBase {
2316
+ onShutdown() {
2317
+ }
2318
+ };
2319
+ }
2320
+ });
2321
+
2322
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js
2323
+ function getIdGenerator(bytes) {
2324
+ return function generateId() {
2325
+ for (let i = 0; i < bytes / 4; i++) {
2326
+ SHARED_BUFFER.writeUInt32BE(Math.random() * 2 ** 32 >>> 0, i * 4);
2327
+ }
2328
+ for (let i = 0; i < bytes; i++) {
2329
+ if (SHARED_BUFFER[i] > 0) {
2330
+ break;
2331
+ } else if (i === bytes - 1) {
2332
+ SHARED_BUFFER[bytes - 1] = 1;
2333
+ }
2334
+ }
2335
+ return SHARED_BUFFER.toString("hex", 0, bytes);
2336
+ };
2337
+ }
2338
+ var SPAN_ID_BYTES, TRACE_ID_BYTES, RandomIdGenerator, SHARED_BUFFER;
2339
+ var init_RandomIdGenerator = __esm({
2340
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js"() {
2341
+ "use strict";
2342
+ SPAN_ID_BYTES = 8;
2343
+ TRACE_ID_BYTES = 16;
2344
+ RandomIdGenerator = class {
2345
+ constructor() {
2346
+ /**
2347
+ * Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex
2348
+ * characters corresponding to 128 bits.
2349
+ */
2350
+ __publicField(this, "generateTraceId", getIdGenerator(TRACE_ID_BYTES));
2351
+ /**
2352
+ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex
2353
+ * characters corresponding to 64 bits.
2354
+ */
2355
+ __publicField(this, "generateSpanId", getIdGenerator(SPAN_ID_BYTES));
2356
+ }
2357
+ };
2358
+ SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES);
2359
+ }
2360
+ });
2361
+
2362
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js
2363
+ var init_node2 = __esm({
2364
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js"() {
2365
+ "use strict";
2366
+ init_BatchSpanProcessor();
2367
+ init_RandomIdGenerator();
2368
+ }
2369
+ });
2370
+
2371
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js
2372
+ var init_platform2 = __esm({
2373
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js"() {
2374
+ "use strict";
2375
+ init_node2();
2376
+ }
2377
+ });
2378
+
2379
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
2380
+ import * as api from "@opentelemetry/api";
2381
+ var Tracer;
2382
+ var init_Tracer = __esm({
2383
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js"() {
2384
+ "use strict";
2385
+ init_esm2();
2386
+ init_Span();
2387
+ init_utility();
2388
+ init_platform2();
2389
+ Tracer = class {
2390
+ /**
2391
+ * Constructs a new Tracer instance.
2392
+ */
2393
+ constructor(instrumentationScope, config, resource, spanProcessor) {
2394
+ __publicField(this, "_sampler");
2395
+ __publicField(this, "_generalLimits");
2396
+ __publicField(this, "_spanLimits");
2397
+ __publicField(this, "_idGenerator");
2398
+ __publicField(this, "instrumentationScope");
2399
+ __publicField(this, "_resource");
2400
+ __publicField(this, "_spanProcessor");
2401
+ const localConfig = mergeConfig(config);
2402
+ this._sampler = localConfig.sampler;
2403
+ this._generalLimits = localConfig.generalLimits;
2404
+ this._spanLimits = localConfig.spanLimits;
2405
+ this._idGenerator = config.idGenerator || new RandomIdGenerator();
2406
+ this._resource = resource;
2407
+ this._spanProcessor = spanProcessor;
2408
+ this.instrumentationScope = instrumentationScope;
2409
+ }
2410
+ /**
2411
+ * Starts a new Span or returns the default NoopSpan based on the sampling
2412
+ * decision.
2413
+ */
2414
+ startSpan(name, options = {}, context4 = api.context.active()) {
2415
+ var _a, _b, _c;
2416
+ if (options.root) {
2417
+ context4 = api.trace.deleteSpan(context4);
2418
+ }
2419
+ const parentSpan = api.trace.getSpan(context4);
2420
+ if (isTracingSuppressed(context4)) {
2421
+ api.diag.debug("Instrumentation suppressed, returning Noop Span");
2422
+ const nonRecordingSpan = api.trace.wrapSpanContext(api.INVALID_SPAN_CONTEXT);
2423
+ return nonRecordingSpan;
2424
+ }
2425
+ const parentSpanContext = parentSpan == null ? void 0 : parentSpan.spanContext();
2426
+ const spanId = this._idGenerator.generateSpanId();
2427
+ let validParentSpanContext;
2428
+ let traceId;
2429
+ let traceState;
2430
+ if (!parentSpanContext || !api.trace.isSpanContextValid(parentSpanContext)) {
2431
+ traceId = this._idGenerator.generateTraceId();
2432
+ } else {
2433
+ traceId = parentSpanContext.traceId;
2434
+ traceState = parentSpanContext.traceState;
2435
+ validParentSpanContext = parentSpanContext;
2436
+ }
2437
+ const spanKind = (_a = options.kind) != null ? _a : api.SpanKind.INTERNAL;
2438
+ const links = ((_b = options.links) != null ? _b : []).map((link) => {
2439
+ return {
2440
+ context: link.context,
2441
+ attributes: sanitizeAttributes(link.attributes)
2442
+ };
2443
+ });
2444
+ const attributes = sanitizeAttributes(options.attributes);
2445
+ const samplingResult = this._sampler.shouldSample(context4, traceId, name, spanKind, attributes, links);
2446
+ traceState = (_c = samplingResult.traceState) != null ? _c : traceState;
2447
+ const traceFlags = samplingResult.decision === api.SamplingDecision.RECORD_AND_SAMPLED ? api.TraceFlags.SAMPLED : api.TraceFlags.NONE;
2448
+ const spanContext = { traceId, spanId, traceFlags, traceState };
2449
+ if (samplingResult.decision === api.SamplingDecision.NOT_RECORD) {
2450
+ api.diag.debug("Recording is off, propagating context in a non-recording span");
2451
+ const nonRecordingSpan = api.trace.wrapSpanContext(spanContext);
2452
+ return nonRecordingSpan;
2453
+ }
2454
+ const initAttributes = sanitizeAttributes(Object.assign(attributes, samplingResult.attributes));
2455
+ const span = new SpanImpl({
2456
+ resource: this._resource,
2457
+ scope: this.instrumentationScope,
2458
+ context: context4,
2459
+ spanContext,
2460
+ name,
2461
+ kind: spanKind,
2462
+ links,
2463
+ parentSpanContext: validParentSpanContext,
2464
+ attributes: initAttributes,
2465
+ startTime: options.startTime,
2466
+ spanProcessor: this._spanProcessor,
2467
+ spanLimits: this._spanLimits
2468
+ });
2469
+ return span;
2470
+ }
2471
+ startActiveSpan(name, arg2, arg3, arg4) {
2472
+ let opts;
2473
+ let ctx;
2474
+ let fn;
2475
+ if (arguments.length < 2) {
2476
+ return;
2477
+ } else if (arguments.length === 2) {
2478
+ fn = arg2;
2479
+ } else if (arguments.length === 3) {
2480
+ opts = arg2;
2481
+ fn = arg3;
2482
+ } else {
2483
+ opts = arg2;
2484
+ ctx = arg3;
2485
+ fn = arg4;
2486
+ }
2487
+ const parentContext = ctx != null ? ctx : api.context.active();
2488
+ const span = this.startSpan(name, opts, parentContext);
2489
+ const contextWithSpanSet = api.trace.setSpan(parentContext, span);
2490
+ return api.context.with(contextWithSpanSet, fn, void 0, span);
2491
+ }
2492
+ /** Returns the active {@link GeneralLimits}. */
2493
+ getGeneralLimits() {
2494
+ return this._generalLimits;
2495
+ }
2496
+ /** Returns the active {@link SpanLimits}. */
2497
+ getSpanLimits() {
2498
+ return this._spanLimits;
2499
+ }
2500
+ };
2501
+ }
2502
+ });
2503
+
2504
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js
2505
+ var MultiSpanProcessor;
2506
+ var init_MultiSpanProcessor = __esm({
2507
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js"() {
2508
+ "use strict";
2509
+ init_esm2();
2510
+ MultiSpanProcessor = class {
2511
+ constructor(_spanProcessors) {
2512
+ __publicField(this, "_spanProcessors");
2513
+ this._spanProcessors = _spanProcessors;
2514
+ }
2515
+ forceFlush() {
2516
+ const promises = [];
2517
+ for (const spanProcessor of this._spanProcessors) {
2518
+ promises.push(spanProcessor.forceFlush());
2519
+ }
2520
+ return new Promise((resolve) => {
2521
+ Promise.all(promises).then(() => {
2522
+ resolve();
2523
+ }).catch((error) => {
2524
+ globalErrorHandler(error || new Error("MultiSpanProcessor: forceFlush failed"));
2525
+ resolve();
2526
+ });
2527
+ });
2528
+ }
2529
+ onStart(span, context4) {
2530
+ for (const spanProcessor of this._spanProcessors) {
2531
+ spanProcessor.onStart(span, context4);
2532
+ }
2533
+ }
2534
+ onEnd(span) {
2535
+ for (const spanProcessor of this._spanProcessors) {
2536
+ spanProcessor.onEnd(span);
2537
+ }
2538
+ }
2539
+ shutdown() {
2540
+ const promises = [];
2541
+ for (const spanProcessor of this._spanProcessors) {
2542
+ promises.push(spanProcessor.shutdown());
2543
+ }
2544
+ return new Promise((resolve, reject) => {
2545
+ Promise.all(promises).then(() => {
2546
+ resolve();
2547
+ }, reject);
2548
+ });
2549
+ }
2550
+ };
2551
+ }
2552
+ });
2553
+
2554
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js
2555
+ import { defaultResource } from "@opentelemetry/resources";
2556
+ var ForceFlushState, BasicTracerProvider;
2557
+ var init_BasicTracerProvider = __esm({
2558
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js"() {
2559
+ "use strict";
2560
+ init_esm2();
2561
+ init_Tracer();
2562
+ init_config();
2563
+ init_MultiSpanProcessor();
2564
+ init_utility();
2565
+ (function(ForceFlushState2) {
2566
+ ForceFlushState2[ForceFlushState2["resolved"] = 0] = "resolved";
2567
+ ForceFlushState2[ForceFlushState2["timeout"] = 1] = "timeout";
2568
+ ForceFlushState2[ForceFlushState2["error"] = 2] = "error";
2569
+ ForceFlushState2[ForceFlushState2["unresolved"] = 3] = "unresolved";
2570
+ })(ForceFlushState || (ForceFlushState = {}));
2571
+ BasicTracerProvider = class {
2572
+ constructor(config = {}) {
2573
+ __publicField(this, "_config");
2574
+ __publicField(this, "_tracers", /* @__PURE__ */ new Map());
2575
+ __publicField(this, "_resource");
2576
+ __publicField(this, "_activeSpanProcessor");
2577
+ var _a, _b;
2578
+ const mergedConfig = merge({}, loadDefaultConfig(), reconfigureLimits(config));
2579
+ this._resource = (_a = mergedConfig.resource) != null ? _a : defaultResource();
2580
+ this._config = Object.assign({}, mergedConfig, {
2581
+ resource: this._resource
2582
+ });
2583
+ const spanProcessors = [];
2584
+ if ((_b = config.spanProcessors) == null ? void 0 : _b.length) {
2585
+ spanProcessors.push(...config.spanProcessors);
2586
+ }
2587
+ this._activeSpanProcessor = new MultiSpanProcessor(spanProcessors);
2588
+ }
2589
+ getTracer(name, version, options) {
2590
+ const key = `${name}@${version || ""}:${(options == null ? void 0 : options.schemaUrl) || ""}`;
2591
+ if (!this._tracers.has(key)) {
2592
+ this._tracers.set(key, new Tracer({ name, version, schemaUrl: options == null ? void 0 : options.schemaUrl }, this._config, this._resource, this._activeSpanProcessor));
2593
+ }
2594
+ return this._tracers.get(key);
2595
+ }
2596
+ forceFlush() {
2597
+ const timeout = this._config.forceFlushTimeoutMillis;
2598
+ const promises = this._activeSpanProcessor["_spanProcessors"].map((spanProcessor) => {
2599
+ return new Promise((resolve) => {
2600
+ let state;
2601
+ const timeoutInterval = setTimeout(() => {
2602
+ resolve(new Error(`Span processor did not completed within timeout period of ${timeout} ms`));
2603
+ state = ForceFlushState.timeout;
2604
+ }, timeout);
2605
+ spanProcessor.forceFlush().then(() => {
2606
+ clearTimeout(timeoutInterval);
2607
+ if (state !== ForceFlushState.timeout) {
2608
+ state = ForceFlushState.resolved;
2609
+ resolve(state);
2610
+ }
2611
+ }).catch((error) => {
2612
+ clearTimeout(timeoutInterval);
2613
+ state = ForceFlushState.error;
2614
+ resolve(error);
2615
+ });
2616
+ });
2617
+ });
2618
+ return new Promise((resolve, reject) => {
2619
+ Promise.all(promises).then((results) => {
2620
+ const errors = results.filter((result) => result !== ForceFlushState.resolved);
2621
+ if (errors.length > 0) {
2622
+ reject(errors);
2623
+ } else {
2624
+ resolve();
2625
+ }
2626
+ }).catch((error) => reject([error]));
2627
+ });
2628
+ }
2629
+ shutdown() {
2630
+ return this._activeSpanProcessor.shutdown();
2631
+ }
2632
+ };
2633
+ }
2634
+ });
2635
+
2636
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/ConsoleSpanExporter.js
2637
+ var ConsoleSpanExporter;
2638
+ var init_ConsoleSpanExporter = __esm({
2639
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/ConsoleSpanExporter.js"() {
2640
+ "use strict";
2641
+ init_esm2();
2642
+ ConsoleSpanExporter = class {
2643
+ /**
2644
+ * Export spans.
2645
+ * @param spans
2646
+ * @param resultCallback
2647
+ */
2648
+ export(spans, resultCallback) {
2649
+ return this._sendSpans(spans, resultCallback);
2650
+ }
2651
+ /**
2652
+ * Shutdown the exporter.
2653
+ */
2654
+ shutdown() {
2655
+ this._sendSpans([]);
2656
+ return this.forceFlush();
2657
+ }
2658
+ /**
2659
+ * Exports any pending spans in exporter
2660
+ */
2661
+ forceFlush() {
2662
+ return Promise.resolve();
2663
+ }
2664
+ /**
2665
+ * converts span info into more readable format
2666
+ * @param span
2667
+ */
2668
+ _exportInfo(span) {
2669
+ var _a;
2670
+ return {
2671
+ resource: {
2672
+ attributes: span.resource.attributes
2673
+ },
2674
+ instrumentationScope: span.instrumentationScope,
2675
+ traceId: span.spanContext().traceId,
2676
+ parentSpanContext: span.parentSpanContext,
2677
+ traceState: (_a = span.spanContext().traceState) == null ? void 0 : _a.serialize(),
2678
+ name: span.name,
2679
+ id: span.spanContext().spanId,
2680
+ kind: span.kind,
2681
+ timestamp: hrTimeToMicroseconds(span.startTime),
2682
+ duration: hrTimeToMicroseconds(span.duration),
2683
+ attributes: span.attributes,
2684
+ status: span.status,
2685
+ events: span.events,
2686
+ links: span.links
2687
+ };
2688
+ }
2689
+ /**
2690
+ * Showing spans in console
2691
+ * @param spans
2692
+ * @param done
2693
+ */
2694
+ _sendSpans(spans, done) {
2695
+ for (const span of spans) {
2696
+ console.dir(this._exportInfo(span), { depth: 3 });
2697
+ }
2698
+ if (done) {
2699
+ return done({ code: ExportResultCode.SUCCESS });
2700
+ }
2701
+ }
2702
+ };
2703
+ }
2704
+ });
2705
+
2706
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/InMemorySpanExporter.js
2707
+ var InMemorySpanExporter;
2708
+ var init_InMemorySpanExporter = __esm({
2709
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/InMemorySpanExporter.js"() {
2710
+ "use strict";
2711
+ init_esm2();
2712
+ InMemorySpanExporter = class {
2713
+ constructor() {
2714
+ __publicField(this, "_finishedSpans", []);
2715
+ /**
2716
+ * Indicates if the exporter has been "shutdown."
2717
+ * When false, exported spans will not be stored in-memory.
2718
+ */
2719
+ __publicField(this, "_stopped", false);
2720
+ }
2721
+ export(spans, resultCallback) {
2722
+ if (this._stopped)
2723
+ return resultCallback({
2724
+ code: ExportResultCode.FAILED,
2725
+ error: new Error("Exporter has been stopped")
2726
+ });
2727
+ this._finishedSpans.push(...spans);
2728
+ setTimeout(() => resultCallback({ code: ExportResultCode.SUCCESS }), 0);
2729
+ }
2730
+ shutdown() {
2731
+ this._stopped = true;
2732
+ this._finishedSpans = [];
2733
+ return this.forceFlush();
2734
+ }
2735
+ /**
2736
+ * Exports any pending spans in the exporter
2737
+ */
2738
+ forceFlush() {
2739
+ return Promise.resolve();
2740
+ }
2741
+ reset() {
2742
+ this._finishedSpans = [];
2743
+ }
2744
+ getFinishedSpans() {
2745
+ return this._finishedSpans;
2746
+ }
2747
+ };
2748
+ }
2749
+ });
2750
+
2751
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/SimpleSpanProcessor.js
2752
+ import { TraceFlags as TraceFlags6 } from "@opentelemetry/api";
2753
+ var SimpleSpanProcessor;
2754
+ var init_SimpleSpanProcessor = __esm({
2755
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/SimpleSpanProcessor.js"() {
2756
+ "use strict";
2757
+ init_esm2();
2758
+ SimpleSpanProcessor = class {
2759
+ constructor(_exporter) {
2760
+ __publicField(this, "_exporter");
2761
+ __publicField(this, "_shutdownOnce");
2762
+ __publicField(this, "_pendingExports");
2763
+ this._exporter = _exporter;
2764
+ this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
2765
+ this._pendingExports = /* @__PURE__ */ new Set();
2766
+ }
2767
+ async forceFlush() {
2768
+ await Promise.all(Array.from(this._pendingExports));
2769
+ if (this._exporter.forceFlush) {
2770
+ await this._exporter.forceFlush();
2771
+ }
2772
+ }
2773
+ onStart(_span, _parentContext) {
2774
+ }
2775
+ onEnd(span) {
2776
+ if (this._shutdownOnce.isCalled) {
2777
+ return;
2778
+ }
2779
+ if ((span.spanContext().traceFlags & TraceFlags6.SAMPLED) === 0) {
2780
+ return;
2781
+ }
2782
+ const pendingExport = this._doExport(span).catch((err) => globalErrorHandler(err));
2783
+ this._pendingExports.add(pendingExport);
2784
+ pendingExport.finally(() => this._pendingExports.delete(pendingExport));
2785
+ }
2786
+ async _doExport(span) {
2787
+ var _a, _b, _c;
2788
+ if (span.resource.asyncAttributesPending) {
2789
+ await ((_b = (_a = span.resource).waitForAsyncAttributes) == null ? void 0 : _b.call(_a));
2790
+ }
2791
+ const result = await internal._export(this._exporter, [span]);
2792
+ if (result.code !== ExportResultCode.SUCCESS) {
2793
+ throw (_c = result.error) != null ? _c : new Error(`SimpleSpanProcessor: span export failed (status ${result})`);
2794
+ }
2795
+ }
2796
+ shutdown() {
2797
+ return this._shutdownOnce.call();
2798
+ }
2799
+ _shutdown() {
2800
+ return this._exporter.shutdown();
2801
+ }
2802
+ };
2803
+ }
2804
+ });
2805
+
2806
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/NoopSpanProcessor.js
2807
+ var NoopSpanProcessor;
2808
+ var init_NoopSpanProcessor = __esm({
2809
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/NoopSpanProcessor.js"() {
2810
+ "use strict";
2811
+ NoopSpanProcessor = class {
2812
+ onStart(_span, _context) {
2813
+ }
2814
+ onEnd(_span) {
2815
+ }
2816
+ shutdown() {
2817
+ return Promise.resolve();
2818
+ }
2819
+ forceFlush() {
2820
+ return Promise.resolve();
2821
+ }
2822
+ };
2823
+ }
2824
+ });
2825
+
2826
+ // ../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js
2827
+ var esm_exports2 = {};
2828
+ __export(esm_exports2, {
2829
+ AlwaysOffSampler: () => AlwaysOffSampler,
2830
+ AlwaysOnSampler: () => AlwaysOnSampler,
2831
+ BasicTracerProvider: () => BasicTracerProvider,
2832
+ BatchSpanProcessor: () => BatchSpanProcessor,
2833
+ ConsoleSpanExporter: () => ConsoleSpanExporter,
2834
+ InMemorySpanExporter: () => InMemorySpanExporter,
2835
+ NoopSpanProcessor: () => NoopSpanProcessor,
2836
+ ParentBasedSampler: () => ParentBasedSampler,
2837
+ RandomIdGenerator: () => RandomIdGenerator,
2838
+ SamplingDecision: () => SamplingDecision,
2839
+ SimpleSpanProcessor: () => SimpleSpanProcessor,
2840
+ TraceIdRatioBasedSampler: () => TraceIdRatioBasedSampler
2841
+ });
2842
+ var init_esm3 = __esm({
2843
+ "../../node_modules/@opentelemetry/sdk-trace-node/node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js"() {
2844
+ "use strict";
2845
+ init_BasicTracerProvider();
2846
+ init_platform2();
2847
+ init_ConsoleSpanExporter();
2848
+ init_InMemorySpanExporter();
2849
+ init_SimpleSpanProcessor();
2850
+ init_NoopSpanProcessor();
2851
+ init_AlwaysOffSampler();
2852
+ init_AlwaysOnSampler();
2853
+ init_ParentBasedSampler();
2854
+ init_TraceIdRatioBasedSampler();
2855
+ init_Sampler();
2856
+ }
2857
+ });
2858
+
2859
+ // ../../node_modules/@opentelemetry/sdk-trace-node/build/src/NodeTracerProvider.js
2860
+ var require_NodeTracerProvider = __commonJS({
2861
+ "../../node_modules/@opentelemetry/sdk-trace-node/build/src/NodeTracerProvider.js"(exports) {
2862
+ "use strict";
2863
+ Object.defineProperty(exports, "__esModule", { value: true });
2864
+ exports.NodeTracerProvider = void 0;
2865
+ var context_async_hooks_1 = require_src();
2866
+ var sdk_trace_base_1 = (init_esm3(), __toCommonJS(esm_exports2));
2867
+ var api_1 = __require("@opentelemetry/api");
2868
+ var core_1 = (init_esm2(), __toCommonJS(esm_exports));
2869
+ function setupContextManager(contextManager) {
2870
+ if (contextManager === null) {
2871
+ return;
2872
+ }
2873
+ if (contextManager === void 0) {
2874
+ const defaultContextManager = new context_async_hooks_1.AsyncLocalStorageContextManager();
2875
+ defaultContextManager.enable();
2876
+ api_1.context.setGlobalContextManager(defaultContextManager);
2877
+ return;
2878
+ }
2879
+ contextManager.enable();
2880
+ api_1.context.setGlobalContextManager(contextManager);
2881
+ }
2882
+ function setupPropagator(propagator) {
2883
+ if (propagator === null) {
2884
+ return;
2885
+ }
2886
+ if (propagator === void 0) {
2887
+ api_1.propagation.setGlobalPropagator(new core_1.CompositePropagator({
2888
+ propagators: [
2889
+ new core_1.W3CTraceContextPropagator(),
2890
+ new core_1.W3CBaggagePropagator()
2891
+ ]
2892
+ }));
2893
+ return;
2894
+ }
2895
+ api_1.propagation.setGlobalPropagator(propagator);
2896
+ }
2897
+ var NodeTracerProvider = class extends sdk_trace_base_1.BasicTracerProvider {
2898
+ constructor(config = {}) {
2899
+ super(config);
2900
+ }
2901
+ /**
2902
+ * Register this TracerProvider for use with the OpenTelemetry API.
2903
+ * Undefined values may be replaced with defaults, and
2904
+ * null values will be skipped.
2905
+ *
2906
+ * @param config Configuration object for SDK registration
2907
+ */
2908
+ register(config = {}) {
2909
+ api_1.trace.setGlobalTracerProvider(this);
2910
+ setupContextManager(config.contextManager);
2911
+ setupPropagator(config.propagator);
2912
+ }
2913
+ };
2914
+ exports.NodeTracerProvider = NodeTracerProvider;
2915
+ }
2916
+ });
2917
+
2918
+ // ../../node_modules/@opentelemetry/sdk-trace-node/build/src/index.js
2919
+ var require_src2 = __commonJS({
2920
+ "../../node_modules/@opentelemetry/sdk-trace-node/build/src/index.js"(exports) {
2921
+ "use strict";
2922
+ Object.defineProperty(exports, "__esModule", { value: true });
2923
+ 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;
2924
+ var NodeTracerProvider_1 = require_NodeTracerProvider();
2925
+ Object.defineProperty(exports, "NodeTracerProvider", { enumerable: true, get: function() {
2926
+ return NodeTracerProvider_1.NodeTracerProvider;
2927
+ } });
2928
+ var sdk_trace_base_1 = (init_esm3(), __toCommonJS(esm_exports2));
2929
+ Object.defineProperty(exports, "AlwaysOffSampler", { enumerable: true, get: function() {
2930
+ return sdk_trace_base_1.AlwaysOffSampler;
2931
+ } });
2932
+ Object.defineProperty(exports, "AlwaysOnSampler", { enumerable: true, get: function() {
2933
+ return sdk_trace_base_1.AlwaysOnSampler;
2934
+ } });
2935
+ Object.defineProperty(exports, "BasicTracerProvider", { enumerable: true, get: function() {
2936
+ return sdk_trace_base_1.BasicTracerProvider;
2937
+ } });
2938
+ Object.defineProperty(exports, "BatchSpanProcessor", { enumerable: true, get: function() {
2939
+ return sdk_trace_base_1.BatchSpanProcessor;
2940
+ } });
2941
+ Object.defineProperty(exports, "ConsoleSpanExporter", { enumerable: true, get: function() {
2942
+ return sdk_trace_base_1.ConsoleSpanExporter;
2943
+ } });
2944
+ Object.defineProperty(exports, "InMemorySpanExporter", { enumerable: true, get: function() {
2945
+ return sdk_trace_base_1.InMemorySpanExporter;
2946
+ } });
2947
+ Object.defineProperty(exports, "NoopSpanProcessor", { enumerable: true, get: function() {
2948
+ return sdk_trace_base_1.NoopSpanProcessor;
2949
+ } });
2950
+ Object.defineProperty(exports, "ParentBasedSampler", { enumerable: true, get: function() {
2951
+ return sdk_trace_base_1.ParentBasedSampler;
2952
+ } });
2953
+ Object.defineProperty(exports, "RandomIdGenerator", { enumerable: true, get: function() {
2954
+ return sdk_trace_base_1.RandomIdGenerator;
2955
+ } });
2956
+ Object.defineProperty(exports, "SamplingDecision", { enumerable: true, get: function() {
2957
+ return sdk_trace_base_1.SamplingDecision;
2958
+ } });
2959
+ Object.defineProperty(exports, "SimpleSpanProcessor", { enumerable: true, get: function() {
2960
+ return sdk_trace_base_1.SimpleSpanProcessor;
2961
+ } });
2962
+ Object.defineProperty(exports, "TraceIdRatioBasedSampler", { enumerable: true, get: function() {
2963
+ return sdk_trace_base_1.TraceIdRatioBasedSampler;
2964
+ } });
2965
+ }
2966
+ });
2967
+
2968
+ // src/tracing/noOpSpan.ts
2969
+ import {
2970
+ TraceFlags
2971
+ } from "@opentelemetry/api";
2972
+ var INVALID_SPAN_CONTEXT = {
2973
+ traceId: "",
2974
+ spanId: "",
2975
+ traceFlags: TraceFlags.NONE,
2976
+ isRemote: false
2977
+ };
2978
+ var NoOpSpan = class {
2979
+ spanContext() {
2980
+ return INVALID_SPAN_CONTEXT;
2981
+ }
2982
+ setAttribute(_key, _value) {
2983
+ return this;
2984
+ }
2985
+ setAttributes(_attributes) {
2986
+ return this;
2987
+ }
2988
+ addEvent(_name, _attributesOrStartTime, _startTime) {
2989
+ return this;
2990
+ }
2991
+ addLink(_link) {
2992
+ return this;
2993
+ }
2994
+ addLinks(_links) {
2995
+ return this;
2996
+ }
2997
+ setStatus(_status) {
2998
+ return this;
2999
+ }
3000
+ updateName(_name) {
3001
+ return this;
3002
+ }
3003
+ end(_endTime) {
3004
+ }
3005
+ recordException(_exception, _time) {
3006
+ }
3007
+ isRecording() {
3008
+ return false;
3009
+ }
3010
+ };
3011
+ var NO_OP_SPAN = new NoOpSpan();
3012
+
3013
+ // src/tracing/nonLiveInteraction.ts
3014
+ var NonLiveInteraction = class {
3015
+ constructor(context4, traceId, analytics) {
3016
+ this.context = context4;
3017
+ this.analytics = analytics;
3018
+ }
3019
+ withSpan(_params, fn, thisArg, ...args) {
3020
+ var _a;
3021
+ if ((_a = this.analytics) == null ? void 0 : _a.debugLogs) {
3022
+ console.log("[raindrop] using withSpan in nonLiveInteraction");
3023
+ }
3024
+ try {
3025
+ return Promise.resolve(fn.apply(thisArg, args));
3026
+ } catch (error) {
3027
+ return Promise.reject(error);
3028
+ }
3029
+ }
3030
+ withTool(_params, fn, thisArg, ...args) {
3031
+ var _a;
3032
+ if ((_a = this.analytics) == null ? void 0 : _a.debugLogs) {
3033
+ console.log("[raindrop] using withTool in nonLiveInteraction");
3034
+ }
3035
+ try {
3036
+ return Promise.resolve(fn.apply(thisArg, args));
3037
+ } catch (error) {
3038
+ return Promise.reject(error);
3039
+ }
3040
+ }
3041
+ startSpan(_params) {
3042
+ return NO_OP_SPAN;
3043
+ }
3044
+ setProperties(_properties) {
3045
+ var _a;
3046
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
3047
+ eventId: this.context.eventId,
3048
+ properties: _properties
3049
+ });
3050
+ }
3051
+ setProperty(_key, _value) {
3052
+ var _a;
3053
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
3054
+ eventId: this.context.eventId,
3055
+ properties: {
3056
+ [_key]: _value
3057
+ }
3058
+ });
3059
+ }
3060
+ addAttachments(_attachments) {
3061
+ var _a;
3062
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
3063
+ eventId: this.context.eventId,
3064
+ attachments: _attachments
3065
+ });
3066
+ }
3067
+ setInput(_input) {
3068
+ var _a;
3069
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
3070
+ eventId: this.context.eventId,
3071
+ input: _input
3072
+ });
3073
+ }
3074
+ finish(resultEvent) {
3075
+ var _a;
3076
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
3077
+ ...resultEvent,
3078
+ eventId: this.context.eventId,
3079
+ isPending: false
3080
+ });
3081
+ }
3082
+ };
3083
+
3084
+ // src/tracing/tracer-core.ts
3085
+ var import_sdk_trace_node = __toESM(require_src2());
3086
+
3087
+ // src/tracing/nonLiveTracer.ts
3088
+ var NoOpTracer = class {
3089
+ withSpan(_params, fn, thisArg, ...args) {
3090
+ try {
3091
+ return Promise.resolve(fn.apply(thisArg, args));
3092
+ } catch (error) {
3093
+ return Promise.reject(error);
3094
+ }
3095
+ }
3096
+ };
3097
+
3098
+ // src/tracing/tracer-core.ts
3099
+ var getGlobalRegistry = () => {
3100
+ if (typeof globalThis !== "undefined") {
3101
+ globalThis.__RAINDROP_TRACING_REGISTRY__ = globalThis.__RAINDROP_TRACING_REGISTRY__ || {
3102
+ hasRealImplementation: false,
3103
+ realImplementation: null
3104
+ };
3105
+ return globalThis.__RAINDROP_TRACING_REGISTRY__;
3106
+ } else if (typeof window !== "undefined") {
3107
+ window.__RAINDROP_TRACING_REGISTRY__ = window.__RAINDROP_TRACING_REGISTRY__ || {
3108
+ hasRealImplementation: false,
3109
+ realImplementation: null
3110
+ };
3111
+ return window.__RAINDROP_TRACING_REGISTRY__;
3112
+ } else if (typeof global !== "undefined") {
3113
+ global.__RAINDROP_TRACING_REGISTRY__ = global.__RAINDROP_TRACING_REGISTRY__ || {
3114
+ hasRealImplementation: false,
3115
+ realImplementation: null
3116
+ };
3117
+ return global.__RAINDROP_TRACING_REGISTRY__;
3118
+ }
3119
+ return {
3120
+ hasRealImplementation: false,
3121
+ realImplementation: null
3122
+ };
3123
+ };
3124
+ var createTracing = (analytics, _apiUrl, _writeKey, _options, isDebug = false) => ({
3125
+ createSpanProcessor(processorOptions) {
3126
+ return new import_sdk_trace_node.NoopSpanProcessor();
3127
+ },
3128
+ begin(traceContext) {
3129
+ if (isDebug) {
3130
+ console.log("not using traces");
3131
+ }
3132
+ if (!traceContext.eventId) {
3133
+ traceContext.eventId = crypto.randomUUID();
3134
+ }
3135
+ analytics._trackAiPartial({
3136
+ ...traceContext
3137
+ });
3138
+ return new NonLiveInteraction(
3139
+ traceContext,
3140
+ void 0,
3141
+ // No traceId in stub
3142
+ analytics
3143
+ );
3144
+ },
3145
+ getActiveInteraction(eventId) {
3146
+ return new NonLiveInteraction({ eventId }, void 0, analytics);
3147
+ },
3148
+ tracer(globalProperties) {
3149
+ return new NoOpTracer();
3150
+ },
3151
+ async close() {
3152
+ }
3153
+ });
3154
+ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
3155
+ const registry = getGlobalRegistry();
3156
+ if (registry.hasRealImplementation && registry.realImplementation) {
3157
+ if (isDebug) {
3158
+ console.log("[raindrop] Using real tracing implementation");
3159
+ }
3160
+ return registry.realImplementation(analytics, apiUrl, writeKey, options, isDebug);
3161
+ }
3162
+ if (isDebug) {
3163
+ console.log("[raindrop] Using stub implementation");
3164
+ }
3165
+ return createTracing(analytics, apiUrl, writeKey, options, isDebug);
3166
+ };
3167
+ var _setImplementation = (impl) => {
3168
+ const registry = getGlobalRegistry();
3169
+ registry.realImplementation = impl;
3170
+ registry.hasRealImplementation = true;
3171
+ if (typeof process !== "undefined" && process.env.RAINDROP_DEBUG === "true") {
3172
+ console.log("[raindrop] Set real implementation in global registry");
3173
+ }
3174
+ };
3175
+
3176
+ export {
3177
+ __require,
3178
+ __esm,
3179
+ __commonJS,
3180
+ __export,
3181
+ __toESM,
3182
+ __toCommonJS,
3183
+ __publicField,
3184
+ require_src2 as require_src,
3185
+ NonLiveInteraction,
3186
+ tracing,
3187
+ _setImplementation
3188
+ };