@pocket-tools/tracing 0.0.0-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1809 @@
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 __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js
33
+ var _globalThis;
34
+ var init_globalThis = __esm({
35
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js"() {
36
+ _globalThis = typeof globalThis === "object" ? globalThis : global;
37
+ }
38
+ });
39
+
40
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/platform/node/index.js
41
+ var init_node = __esm({
42
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/platform/node/index.js"() {
43
+ init_globalThis();
44
+ }
45
+ });
46
+
47
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/platform/index.js
48
+ var init_platform = __esm({
49
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/platform/index.js"() {
50
+ init_node();
51
+ }
52
+ });
53
+
54
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/version.js
55
+ var VERSION;
56
+ var init_version = __esm({
57
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/version.js"() {
58
+ VERSION = "1.8.0";
59
+ }
60
+ });
61
+
62
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
63
+ function _makeCompatibilityCheck(ownVersion) {
64
+ var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
65
+ var rejectedVersions = /* @__PURE__ */ new Set();
66
+ var myVersionMatch = ownVersion.match(re);
67
+ if (!myVersionMatch) {
68
+ return function() {
69
+ return false;
70
+ };
71
+ }
72
+ var ownVersionParsed = {
73
+ major: +myVersionMatch[1],
74
+ minor: +myVersionMatch[2],
75
+ patch: +myVersionMatch[3],
76
+ prerelease: myVersionMatch[4]
77
+ };
78
+ if (ownVersionParsed.prerelease != null) {
79
+ return function isExactmatch(globalVersion) {
80
+ return globalVersion === ownVersion;
81
+ };
82
+ }
83
+ function _reject(v) {
84
+ rejectedVersions.add(v);
85
+ return false;
86
+ }
87
+ function _accept(v) {
88
+ acceptedVersions.add(v);
89
+ return true;
90
+ }
91
+ return function isCompatible2(globalVersion) {
92
+ if (acceptedVersions.has(globalVersion)) {
93
+ return true;
94
+ }
95
+ if (rejectedVersions.has(globalVersion)) {
96
+ return false;
97
+ }
98
+ var globalVersionMatch = globalVersion.match(re);
99
+ if (!globalVersionMatch) {
100
+ return _reject(globalVersion);
101
+ }
102
+ var globalVersionParsed = {
103
+ major: +globalVersionMatch[1],
104
+ minor: +globalVersionMatch[2],
105
+ patch: +globalVersionMatch[3],
106
+ prerelease: globalVersionMatch[4]
107
+ };
108
+ if (globalVersionParsed.prerelease != null) {
109
+ return _reject(globalVersion);
110
+ }
111
+ if (ownVersionParsed.major !== globalVersionParsed.major) {
112
+ return _reject(globalVersion);
113
+ }
114
+ if (ownVersionParsed.major === 0) {
115
+ if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
116
+ return _accept(globalVersion);
117
+ }
118
+ return _reject(globalVersion);
119
+ }
120
+ if (ownVersionParsed.minor <= globalVersionParsed.minor) {
121
+ return _accept(globalVersion);
122
+ }
123
+ return _reject(globalVersion);
124
+ };
125
+ }
126
+ var re, isCompatible;
127
+ var init_semver = __esm({
128
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js"() {
129
+ init_version();
130
+ re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
131
+ isCompatible = _makeCompatibilityCheck(VERSION);
132
+ }
133
+ });
134
+
135
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
136
+ function registerGlobal(type, instance, diag2, allowOverride) {
137
+ var _a2;
138
+ if (allowOverride === void 0) {
139
+ allowOverride = false;
140
+ }
141
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a2 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a2 !== void 0 ? _a2 : {
142
+ version: VERSION
143
+ };
144
+ if (!allowOverride && api[type]) {
145
+ var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
146
+ diag2.error(err.stack || err.message);
147
+ return false;
148
+ }
149
+ if (api.version !== VERSION) {
150
+ var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
151
+ diag2.error(err.stack || err.message);
152
+ return false;
153
+ }
154
+ api[type] = instance;
155
+ diag2.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
156
+ return true;
157
+ }
158
+ function getGlobal(type) {
159
+ var _a2, _b;
160
+ var globalVersion = (_a2 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a2 === void 0 ? void 0 : _a2.version;
161
+ if (!globalVersion || !isCompatible(globalVersion)) {
162
+ return;
163
+ }
164
+ return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
165
+ }
166
+ function unregisterGlobal(type, diag2) {
167
+ diag2.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
168
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
169
+ if (api) {
170
+ delete api[type];
171
+ }
172
+ }
173
+ var major, GLOBAL_OPENTELEMETRY_API_KEY, _global;
174
+ var init_global_utils = __esm({
175
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js"() {
176
+ init_platform();
177
+ init_version();
178
+ init_semver();
179
+ major = VERSION.split(".")[0];
180
+ GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
181
+ _global = _globalThis;
182
+ }
183
+ });
184
+
185
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
186
+ function logProxy(funcName, namespace, args) {
187
+ var logger = getGlobal("diag");
188
+ if (!logger) {
189
+ return;
190
+ }
191
+ args.unshift(namespace);
192
+ return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
193
+ }
194
+ var __read, __spreadArray, DiagComponentLogger;
195
+ var init_ComponentLogger = __esm({
196
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js"() {
197
+ init_global_utils();
198
+ __read = function(o, n) {
199
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
200
+ if (!m)
201
+ return o;
202
+ var i = m.call(o), r, ar = [], e;
203
+ try {
204
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
205
+ ar.push(r.value);
206
+ } catch (error) {
207
+ e = { error };
208
+ } finally {
209
+ try {
210
+ if (r && !r.done && (m = i["return"]))
211
+ m.call(i);
212
+ } finally {
213
+ if (e)
214
+ throw e.error;
215
+ }
216
+ }
217
+ return ar;
218
+ };
219
+ __spreadArray = function(to, from, pack) {
220
+ if (pack || arguments.length === 2)
221
+ for (var i = 0, l = from.length, ar; i < l; i++) {
222
+ if (ar || !(i in from)) {
223
+ if (!ar)
224
+ ar = Array.prototype.slice.call(from, 0, i);
225
+ ar[i] = from[i];
226
+ }
227
+ }
228
+ return to.concat(ar || Array.prototype.slice.call(from));
229
+ };
230
+ DiagComponentLogger = /** @class */
231
+ function() {
232
+ function DiagComponentLogger2(props) {
233
+ this._namespace = props.namespace || "DiagComponentLogger";
234
+ }
235
+ DiagComponentLogger2.prototype.debug = function() {
236
+ var args = [];
237
+ for (var _i = 0; _i < arguments.length; _i++) {
238
+ args[_i] = arguments[_i];
239
+ }
240
+ return logProxy("debug", this._namespace, args);
241
+ };
242
+ DiagComponentLogger2.prototype.error = function() {
243
+ var args = [];
244
+ for (var _i = 0; _i < arguments.length; _i++) {
245
+ args[_i] = arguments[_i];
246
+ }
247
+ return logProxy("error", this._namespace, args);
248
+ };
249
+ DiagComponentLogger2.prototype.info = function() {
250
+ var args = [];
251
+ for (var _i = 0; _i < arguments.length; _i++) {
252
+ args[_i] = arguments[_i];
253
+ }
254
+ return logProxy("info", this._namespace, args);
255
+ };
256
+ DiagComponentLogger2.prototype.warn = function() {
257
+ var args = [];
258
+ for (var _i = 0; _i < arguments.length; _i++) {
259
+ args[_i] = arguments[_i];
260
+ }
261
+ return logProxy("warn", this._namespace, args);
262
+ };
263
+ DiagComponentLogger2.prototype.verbose = function() {
264
+ var args = [];
265
+ for (var _i = 0; _i < arguments.length; _i++) {
266
+ args[_i] = arguments[_i];
267
+ }
268
+ return logProxy("verbose", this._namespace, args);
269
+ };
270
+ return DiagComponentLogger2;
271
+ }();
272
+ }
273
+ });
274
+
275
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
276
+ var DiagLogLevel;
277
+ var init_types = __esm({
278
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/types.js"() {
279
+ (function(DiagLogLevel2) {
280
+ DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
281
+ DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
282
+ DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
283
+ DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
284
+ DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
285
+ DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
286
+ DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
287
+ })(DiagLogLevel || (DiagLogLevel = {}));
288
+ }
289
+ });
290
+
291
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
292
+ function createLogLevelDiagLogger(maxLevel, logger) {
293
+ if (maxLevel < DiagLogLevel.NONE) {
294
+ maxLevel = DiagLogLevel.NONE;
295
+ } else if (maxLevel > DiagLogLevel.ALL) {
296
+ maxLevel = DiagLogLevel.ALL;
297
+ }
298
+ logger = logger || {};
299
+ function _filterFunc(funcName, theLevel) {
300
+ var theFunc = logger[funcName];
301
+ if (typeof theFunc === "function" && maxLevel >= theLevel) {
302
+ return theFunc.bind(logger);
303
+ }
304
+ return function() {
305
+ };
306
+ }
307
+ return {
308
+ error: _filterFunc("error", DiagLogLevel.ERROR),
309
+ warn: _filterFunc("warn", DiagLogLevel.WARN),
310
+ info: _filterFunc("info", DiagLogLevel.INFO),
311
+ debug: _filterFunc("debug", DiagLogLevel.DEBUG),
312
+ verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
313
+ };
314
+ }
315
+ var init_logLevelLogger = __esm({
316
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js"() {
317
+ init_types();
318
+ }
319
+ });
320
+
321
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/api/diag.js
322
+ var __read2, __spreadArray2, API_NAME, DiagAPI;
323
+ var init_diag = __esm({
324
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/api/diag.js"() {
325
+ init_ComponentLogger();
326
+ init_logLevelLogger();
327
+ init_types();
328
+ init_global_utils();
329
+ __read2 = function(o, n) {
330
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
331
+ if (!m)
332
+ return o;
333
+ var i = m.call(o), r, ar = [], e;
334
+ try {
335
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
336
+ ar.push(r.value);
337
+ } catch (error) {
338
+ e = { error };
339
+ } finally {
340
+ try {
341
+ if (r && !r.done && (m = i["return"]))
342
+ m.call(i);
343
+ } finally {
344
+ if (e)
345
+ throw e.error;
346
+ }
347
+ }
348
+ return ar;
349
+ };
350
+ __spreadArray2 = function(to, from, pack) {
351
+ if (pack || arguments.length === 2)
352
+ for (var i = 0, l = from.length, ar; i < l; i++) {
353
+ if (ar || !(i in from)) {
354
+ if (!ar)
355
+ ar = Array.prototype.slice.call(from, 0, i);
356
+ ar[i] = from[i];
357
+ }
358
+ }
359
+ return to.concat(ar || Array.prototype.slice.call(from));
360
+ };
361
+ API_NAME = "diag";
362
+ DiagAPI = /** @class */
363
+ function() {
364
+ function DiagAPI2() {
365
+ function _logProxy(funcName) {
366
+ return function() {
367
+ var args = [];
368
+ for (var _i = 0; _i < arguments.length; _i++) {
369
+ args[_i] = arguments[_i];
370
+ }
371
+ var logger = getGlobal("diag");
372
+ if (!logger)
373
+ return;
374
+ return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
375
+ };
376
+ }
377
+ var self = this;
378
+ var setLogger = function(logger, optionsOrLogLevel) {
379
+ var _a2, _b, _c;
380
+ if (optionsOrLogLevel === void 0) {
381
+ optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
382
+ }
383
+ if (logger === self) {
384
+ var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
385
+ self.error((_a2 = err.stack) !== null && _a2 !== void 0 ? _a2 : err.message);
386
+ return false;
387
+ }
388
+ if (typeof optionsOrLogLevel === "number") {
389
+ optionsOrLogLevel = {
390
+ logLevel: optionsOrLogLevel
391
+ };
392
+ }
393
+ var oldLogger = getGlobal("diag");
394
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
395
+ if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
396
+ var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
397
+ oldLogger.warn("Current logger will be overwritten from " + stack);
398
+ newLogger.warn("Current logger will overwrite one already registered from " + stack);
399
+ }
400
+ return registerGlobal("diag", newLogger, self, true);
401
+ };
402
+ self.setLogger = setLogger;
403
+ self.disable = function() {
404
+ unregisterGlobal(API_NAME, self);
405
+ };
406
+ self.createComponentLogger = function(options) {
407
+ return new DiagComponentLogger(options);
408
+ };
409
+ self.verbose = _logProxy("verbose");
410
+ self.debug = _logProxy("debug");
411
+ self.info = _logProxy("info");
412
+ self.warn = _logProxy("warn");
413
+ self.error = _logProxy("error");
414
+ }
415
+ DiagAPI2.instance = function() {
416
+ if (!this._instance) {
417
+ this._instance = new DiagAPI2();
418
+ }
419
+ return this._instance;
420
+ };
421
+ return DiagAPI2;
422
+ }();
423
+ }
424
+ });
425
+
426
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/context/context.js
427
+ function createContextKey(description) {
428
+ return Symbol.for(description);
429
+ }
430
+ var BaseContext, ROOT_CONTEXT;
431
+ var init_context = __esm({
432
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/context/context.js"() {
433
+ BaseContext = /** @class */
434
+ /* @__PURE__ */ function() {
435
+ function BaseContext2(parentContext) {
436
+ var self = this;
437
+ self._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
438
+ self.getValue = function(key) {
439
+ return self._currentContext.get(key);
440
+ };
441
+ self.setValue = function(key, value) {
442
+ var context2 = new BaseContext2(self._currentContext);
443
+ context2._currentContext.set(key, value);
444
+ return context2;
445
+ };
446
+ self.deleteValue = function(key) {
447
+ var context2 = new BaseContext2(self._currentContext);
448
+ context2._currentContext.delete(key);
449
+ return context2;
450
+ };
451
+ }
452
+ return BaseContext2;
453
+ }();
454
+ ROOT_CONTEXT = new BaseContext();
455
+ }
456
+ });
457
+
458
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/consoleLogger.js
459
+ var consoleMap, DiagConsoleLogger;
460
+ var init_consoleLogger = __esm({
461
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/consoleLogger.js"() {
462
+ consoleMap = [
463
+ { n: "error", c: "error" },
464
+ { n: "warn", c: "warn" },
465
+ { n: "info", c: "info" },
466
+ { n: "debug", c: "debug" },
467
+ { n: "verbose", c: "trace" }
468
+ ];
469
+ DiagConsoleLogger = /** @class */
470
+ /* @__PURE__ */ function() {
471
+ function DiagConsoleLogger2() {
472
+ function _consoleFunc(funcName) {
473
+ return function() {
474
+ var args = [];
475
+ for (var _i = 0; _i < arguments.length; _i++) {
476
+ args[_i] = arguments[_i];
477
+ }
478
+ if (console) {
479
+ var theFunc = console[funcName];
480
+ if (typeof theFunc !== "function") {
481
+ theFunc = console.log;
482
+ }
483
+ if (typeof theFunc === "function") {
484
+ return theFunc.apply(console, args);
485
+ }
486
+ }
487
+ };
488
+ }
489
+ for (var i = 0; i < consoleMap.length; i++) {
490
+ this[consoleMap[i].n] = _consoleFunc(consoleMap[i].c);
491
+ }
492
+ }
493
+ return DiagConsoleLogger2;
494
+ }();
495
+ }
496
+ });
497
+
498
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
499
+ var __read3, __spreadArray3, NoopContextManager;
500
+ var init_NoopContextManager = __esm({
501
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js"() {
502
+ init_context();
503
+ __read3 = function(o, n) {
504
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
505
+ if (!m)
506
+ return o;
507
+ var i = m.call(o), r, ar = [], e;
508
+ try {
509
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
510
+ ar.push(r.value);
511
+ } catch (error) {
512
+ e = { error };
513
+ } finally {
514
+ try {
515
+ if (r && !r.done && (m = i["return"]))
516
+ m.call(i);
517
+ } finally {
518
+ if (e)
519
+ throw e.error;
520
+ }
521
+ }
522
+ return ar;
523
+ };
524
+ __spreadArray3 = function(to, from, pack) {
525
+ if (pack || arguments.length === 2)
526
+ for (var i = 0, l = from.length, ar; i < l; i++) {
527
+ if (ar || !(i in from)) {
528
+ if (!ar)
529
+ ar = Array.prototype.slice.call(from, 0, i);
530
+ ar[i] = from[i];
531
+ }
532
+ }
533
+ return to.concat(ar || Array.prototype.slice.call(from));
534
+ };
535
+ NoopContextManager = /** @class */
536
+ function() {
537
+ function NoopContextManager2() {
538
+ }
539
+ NoopContextManager2.prototype.active = function() {
540
+ return ROOT_CONTEXT;
541
+ };
542
+ NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
543
+ var args = [];
544
+ for (var _i = 3; _i < arguments.length; _i++) {
545
+ args[_i - 3] = arguments[_i];
546
+ }
547
+ return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
548
+ };
549
+ NoopContextManager2.prototype.bind = function(_context, target) {
550
+ return target;
551
+ };
552
+ NoopContextManager2.prototype.enable = function() {
553
+ return this;
554
+ };
555
+ NoopContextManager2.prototype.disable = function() {
556
+ return this;
557
+ };
558
+ return NoopContextManager2;
559
+ }();
560
+ }
561
+ });
562
+
563
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/api/context.js
564
+ var __read4, __spreadArray4, API_NAME2, NOOP_CONTEXT_MANAGER, ContextAPI;
565
+ var init_context2 = __esm({
566
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/api/context.js"() {
567
+ init_NoopContextManager();
568
+ init_global_utils();
569
+ init_diag();
570
+ __read4 = function(o, n) {
571
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
572
+ if (!m)
573
+ return o;
574
+ var i = m.call(o), r, ar = [], e;
575
+ try {
576
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
577
+ ar.push(r.value);
578
+ } catch (error) {
579
+ e = { error };
580
+ } finally {
581
+ try {
582
+ if (r && !r.done && (m = i["return"]))
583
+ m.call(i);
584
+ } finally {
585
+ if (e)
586
+ throw e.error;
587
+ }
588
+ }
589
+ return ar;
590
+ };
591
+ __spreadArray4 = function(to, from, pack) {
592
+ if (pack || arguments.length === 2)
593
+ for (var i = 0, l = from.length, ar; i < l; i++) {
594
+ if (ar || !(i in from)) {
595
+ if (!ar)
596
+ ar = Array.prototype.slice.call(from, 0, i);
597
+ ar[i] = from[i];
598
+ }
599
+ }
600
+ return to.concat(ar || Array.prototype.slice.call(from));
601
+ };
602
+ API_NAME2 = "context";
603
+ NOOP_CONTEXT_MANAGER = new NoopContextManager();
604
+ ContextAPI = /** @class */
605
+ function() {
606
+ function ContextAPI2() {
607
+ }
608
+ ContextAPI2.getInstance = function() {
609
+ if (!this._instance) {
610
+ this._instance = new ContextAPI2();
611
+ }
612
+ return this._instance;
613
+ };
614
+ ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
615
+ return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
616
+ };
617
+ ContextAPI2.prototype.active = function() {
618
+ return this._getContextManager().active();
619
+ };
620
+ ContextAPI2.prototype.with = function(context2, fn, thisArg) {
621
+ var _a2;
622
+ var args = [];
623
+ for (var _i = 3; _i < arguments.length; _i++) {
624
+ args[_i - 3] = arguments[_i];
625
+ }
626
+ return (_a2 = this._getContextManager()).with.apply(_a2, __spreadArray4([context2, fn, thisArg], __read4(args), false));
627
+ };
628
+ ContextAPI2.prototype.bind = function(context2, target) {
629
+ return this._getContextManager().bind(context2, target);
630
+ };
631
+ ContextAPI2.prototype._getContextManager = function() {
632
+ return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
633
+ };
634
+ ContextAPI2.prototype.disable = function() {
635
+ this._getContextManager().disable();
636
+ unregisterGlobal(API_NAME2, DiagAPI.instance());
637
+ };
638
+ return ContextAPI2;
639
+ }();
640
+ }
641
+ });
642
+
643
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
644
+ var TraceFlags;
645
+ var init_trace_flags = __esm({
646
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js"() {
647
+ (function(TraceFlags2) {
648
+ TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
649
+ TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
650
+ })(TraceFlags || (TraceFlags = {}));
651
+ }
652
+ });
653
+
654
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/context-api.js
655
+ var context;
656
+ var init_context_api = __esm({
657
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/context-api.js"() {
658
+ init_context2();
659
+ context = ContextAPI.getInstance();
660
+ }
661
+ });
662
+
663
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag-api.js
664
+ var diag;
665
+ var init_diag_api = __esm({
666
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag-api.js"() {
667
+ init_diag();
668
+ diag = DiagAPI.instance();
669
+ }
670
+ });
671
+
672
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/index.js
673
+ var init_esm = __esm({
674
+ "../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/index.js"() {
675
+ init_context();
676
+ init_consoleLogger();
677
+ init_types();
678
+ init_trace_flags();
679
+ init_context_api();
680
+ init_diag_api();
681
+ }
682
+ });
683
+
684
+ // src/index.ts
685
+ var src_exports = {};
686
+ __export(src_exports, {
687
+ nodeSDKBuilder: () => nodeSDKBuilder
688
+ });
689
+ module.exports = __toCommonJS(src_exports);
690
+
691
+ // src/tracing.ts
692
+ var import_process = __toESM(require("process"));
693
+ var import_sdk_node = require("@opentelemetry/sdk-node");
694
+ var import_instrumentation_graphql = require("@opentelemetry/instrumentation-graphql");
695
+ var import_instrumentation_aws_sdk = require("@opentelemetry/instrumentation-aws-sdk");
696
+ var import_id_generator_aws_xray = require("@opentelemetry/id-generator-aws-xray");
697
+ var import_propagator_aws_xray = require("@opentelemetry/propagator-aws-xray");
698
+
699
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js
700
+ init_esm();
701
+ var SUPPRESS_TRACING_KEY = createContextKey("OpenTelemetry SDK Context Key SUPPRESS_TRACING");
702
+ function suppressTracing(context2) {
703
+ return context2.setValue(SUPPRESS_TRACING_KEY, true);
704
+ }
705
+
706
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js
707
+ init_esm();
708
+ function loggingErrorHandler() {
709
+ return function(ex) {
710
+ diag.error(stringifyException(ex));
711
+ };
712
+ }
713
+ function stringifyException(ex) {
714
+ if (typeof ex === "string") {
715
+ return ex;
716
+ } else {
717
+ return JSON.stringify(flattenException(ex));
718
+ }
719
+ }
720
+ function flattenException(ex) {
721
+ var result = {};
722
+ var current = ex;
723
+ while (current !== null) {
724
+ Object.getOwnPropertyNames(current).forEach(function(propertyName) {
725
+ if (result[propertyName])
726
+ return;
727
+ var value = current[propertyName];
728
+ if (value) {
729
+ result[propertyName] = String(value);
730
+ }
731
+ });
732
+ current = Object.getPrototypeOf(current);
733
+ }
734
+ return result;
735
+ }
736
+
737
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js
738
+ var delegateHandler = loggingErrorHandler();
739
+ function globalErrorHandler(ex) {
740
+ try {
741
+ delegateHandler(ex);
742
+ } catch (_a2) {
743
+ }
744
+ }
745
+
746
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/utils/environment.js
747
+ init_esm();
748
+
749
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/utils/sampling.js
750
+ var TracesSamplerValues;
751
+ (function(TracesSamplerValues2) {
752
+ TracesSamplerValues2["AlwaysOff"] = "always_off";
753
+ TracesSamplerValues2["AlwaysOn"] = "always_on";
754
+ TracesSamplerValues2["ParentBasedAlwaysOff"] = "parentbased_always_off";
755
+ TracesSamplerValues2["ParentBasedAlwaysOn"] = "parentbased_always_on";
756
+ TracesSamplerValues2["ParentBasedTraceIdRatio"] = "parentbased_traceidratio";
757
+ TracesSamplerValues2["TraceIdRatio"] = "traceidratio";
758
+ })(TracesSamplerValues || (TracesSamplerValues = {}));
759
+
760
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/utils/environment.js
761
+ var DEFAULT_LIST_SEPARATOR = ",";
762
+ var ENVIRONMENT_BOOLEAN_KEYS = ["OTEL_SDK_DISABLED"];
763
+ function isEnvVarABoolean(key) {
764
+ return ENVIRONMENT_BOOLEAN_KEYS.indexOf(key) > -1;
765
+ }
766
+ var ENVIRONMENT_NUMBERS_KEYS = [
767
+ "OTEL_BSP_EXPORT_TIMEOUT",
768
+ "OTEL_BSP_MAX_EXPORT_BATCH_SIZE",
769
+ "OTEL_BSP_MAX_QUEUE_SIZE",
770
+ "OTEL_BSP_SCHEDULE_DELAY",
771
+ "OTEL_BLRP_EXPORT_TIMEOUT",
772
+ "OTEL_BLRP_MAX_EXPORT_BATCH_SIZE",
773
+ "OTEL_BLRP_MAX_QUEUE_SIZE",
774
+ "OTEL_BLRP_SCHEDULE_DELAY",
775
+ "OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT",
776
+ "OTEL_ATTRIBUTE_COUNT_LIMIT",
777
+ "OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT",
778
+ "OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT",
779
+ "OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT",
780
+ "OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT",
781
+ "OTEL_SPAN_EVENT_COUNT_LIMIT",
782
+ "OTEL_SPAN_LINK_COUNT_LIMIT",
783
+ "OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT",
784
+ "OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT",
785
+ "OTEL_EXPORTER_OTLP_TIMEOUT",
786
+ "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT",
787
+ "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT",
788
+ "OTEL_EXPORTER_OTLP_LOGS_TIMEOUT",
789
+ "OTEL_EXPORTER_JAEGER_AGENT_PORT"
790
+ ];
791
+ function isEnvVarANumber(key) {
792
+ return ENVIRONMENT_NUMBERS_KEYS.indexOf(key) > -1;
793
+ }
794
+ var ENVIRONMENT_LISTS_KEYS = [
795
+ "OTEL_NO_PATCH_MODULES",
796
+ "OTEL_PROPAGATORS"
797
+ ];
798
+ function isEnvVarAList(key) {
799
+ return ENVIRONMENT_LISTS_KEYS.indexOf(key) > -1;
800
+ }
801
+ var DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT = Infinity;
802
+ var DEFAULT_ATTRIBUTE_COUNT_LIMIT = 128;
803
+ var DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT = 128;
804
+ var DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT = 128;
805
+ var DEFAULT_ENVIRONMENT = {
806
+ OTEL_SDK_DISABLED: false,
807
+ CONTAINER_NAME: "",
808
+ ECS_CONTAINER_METADATA_URI_V4: "",
809
+ ECS_CONTAINER_METADATA_URI: "",
810
+ HOSTNAME: "",
811
+ KUBERNETES_SERVICE_HOST: "",
812
+ NAMESPACE: "",
813
+ OTEL_BSP_EXPORT_TIMEOUT: 3e4,
814
+ OTEL_BSP_MAX_EXPORT_BATCH_SIZE: 512,
815
+ OTEL_BSP_MAX_QUEUE_SIZE: 2048,
816
+ OTEL_BSP_SCHEDULE_DELAY: 5e3,
817
+ OTEL_BLRP_EXPORT_TIMEOUT: 3e4,
818
+ OTEL_BLRP_MAX_EXPORT_BATCH_SIZE: 512,
819
+ OTEL_BLRP_MAX_QUEUE_SIZE: 2048,
820
+ OTEL_BLRP_SCHEDULE_DELAY: 5e3,
821
+ OTEL_EXPORTER_JAEGER_AGENT_HOST: "",
822
+ OTEL_EXPORTER_JAEGER_AGENT_PORT: 6832,
823
+ OTEL_EXPORTER_JAEGER_ENDPOINT: "",
824
+ OTEL_EXPORTER_JAEGER_PASSWORD: "",
825
+ OTEL_EXPORTER_JAEGER_USER: "",
826
+ OTEL_EXPORTER_OTLP_ENDPOINT: "",
827
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: "",
828
+ OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: "",
829
+ OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: "",
830
+ OTEL_EXPORTER_OTLP_HEADERS: "",
831
+ OTEL_EXPORTER_OTLP_TRACES_HEADERS: "",
832
+ OTEL_EXPORTER_OTLP_METRICS_HEADERS: "",
833
+ OTEL_EXPORTER_OTLP_LOGS_HEADERS: "",
834
+ OTEL_EXPORTER_OTLP_TIMEOUT: 1e4,
835
+ OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: 1e4,
836
+ OTEL_EXPORTER_OTLP_METRICS_TIMEOUT: 1e4,
837
+ OTEL_EXPORTER_OTLP_LOGS_TIMEOUT: 1e4,
838
+ OTEL_EXPORTER_ZIPKIN_ENDPOINT: "http://localhost:9411/api/v2/spans",
839
+ OTEL_LOG_LEVEL: DiagLogLevel.INFO,
840
+ OTEL_NO_PATCH_MODULES: [],
841
+ OTEL_PROPAGATORS: ["tracecontext", "baggage"],
842
+ OTEL_RESOURCE_ATTRIBUTES: "",
843
+ OTEL_SERVICE_NAME: "",
844
+ OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT: DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,
845
+ OTEL_ATTRIBUTE_COUNT_LIMIT: DEFAULT_ATTRIBUTE_COUNT_LIMIT,
846
+ OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT: DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,
847
+ OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT: DEFAULT_ATTRIBUTE_COUNT_LIMIT,
848
+ OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT: DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,
849
+ OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT: DEFAULT_ATTRIBUTE_COUNT_LIMIT,
850
+ OTEL_SPAN_EVENT_COUNT_LIMIT: 128,
851
+ OTEL_SPAN_LINK_COUNT_LIMIT: 128,
852
+ OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT: DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT,
853
+ OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT: DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT,
854
+ OTEL_TRACES_EXPORTER: "",
855
+ OTEL_TRACES_SAMPLER: TracesSamplerValues.ParentBasedAlwaysOn,
856
+ OTEL_TRACES_SAMPLER_ARG: "",
857
+ OTEL_LOGS_EXPORTER: "",
858
+ OTEL_EXPORTER_OTLP_INSECURE: "",
859
+ OTEL_EXPORTER_OTLP_TRACES_INSECURE: "",
860
+ OTEL_EXPORTER_OTLP_METRICS_INSECURE: "",
861
+ OTEL_EXPORTER_OTLP_LOGS_INSECURE: "",
862
+ OTEL_EXPORTER_OTLP_CERTIFICATE: "",
863
+ OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE: "",
864
+ OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE: "",
865
+ OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE: "",
866
+ OTEL_EXPORTER_OTLP_COMPRESSION: "",
867
+ OTEL_EXPORTER_OTLP_TRACES_COMPRESSION: "",
868
+ OTEL_EXPORTER_OTLP_METRICS_COMPRESSION: "",
869
+ OTEL_EXPORTER_OTLP_LOGS_COMPRESSION: "",
870
+ OTEL_EXPORTER_OTLP_CLIENT_KEY: "",
871
+ OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY: "",
872
+ OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY: "",
873
+ OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY: "",
874
+ OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: "",
875
+ OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE: "",
876
+ OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE: "",
877
+ OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE: "",
878
+ OTEL_EXPORTER_OTLP_PROTOCOL: "http/protobuf",
879
+ OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "http/protobuf",
880
+ OTEL_EXPORTER_OTLP_METRICS_PROTOCOL: "http/protobuf",
881
+ OTEL_EXPORTER_OTLP_LOGS_PROTOCOL: "http/protobuf",
882
+ OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "cumulative"
883
+ };
884
+ function parseBoolean(key, environment, values) {
885
+ if (typeof values[key] === "undefined") {
886
+ return;
887
+ }
888
+ var value = String(values[key]);
889
+ environment[key] = value.toLowerCase() === "true";
890
+ }
891
+ function parseNumber(name, environment, values, min, max) {
892
+ if (min === void 0) {
893
+ min = -Infinity;
894
+ }
895
+ if (max === void 0) {
896
+ max = Infinity;
897
+ }
898
+ if (typeof values[name] !== "undefined") {
899
+ var value = Number(values[name]);
900
+ if (!isNaN(value)) {
901
+ if (value < min) {
902
+ environment[name] = min;
903
+ } else if (value > max) {
904
+ environment[name] = max;
905
+ } else {
906
+ environment[name] = value;
907
+ }
908
+ }
909
+ }
910
+ }
911
+ function parseStringList(name, output, input, separator) {
912
+ if (separator === void 0) {
913
+ separator = DEFAULT_LIST_SEPARATOR;
914
+ }
915
+ var givenValue = input[name];
916
+ if (typeof givenValue === "string") {
917
+ output[name] = givenValue.split(separator).map(function(v) {
918
+ return v.trim();
919
+ });
920
+ }
921
+ }
922
+ var logLevelMap = {
923
+ ALL: DiagLogLevel.ALL,
924
+ VERBOSE: DiagLogLevel.VERBOSE,
925
+ DEBUG: DiagLogLevel.DEBUG,
926
+ INFO: DiagLogLevel.INFO,
927
+ WARN: DiagLogLevel.WARN,
928
+ ERROR: DiagLogLevel.ERROR,
929
+ NONE: DiagLogLevel.NONE
930
+ };
931
+ function setLogLevelFromEnv(key, environment, values) {
932
+ var value = values[key];
933
+ if (typeof value === "string") {
934
+ var theLevel = logLevelMap[value.toUpperCase()];
935
+ if (theLevel != null) {
936
+ environment[key] = theLevel;
937
+ }
938
+ }
939
+ }
940
+ function parseEnvironment(values) {
941
+ var environment = {};
942
+ for (var env in DEFAULT_ENVIRONMENT) {
943
+ var key = env;
944
+ switch (key) {
945
+ case "OTEL_LOG_LEVEL":
946
+ setLogLevelFromEnv(key, environment, values);
947
+ break;
948
+ default:
949
+ if (isEnvVarABoolean(key)) {
950
+ parseBoolean(key, environment, values);
951
+ } else if (isEnvVarANumber(key)) {
952
+ parseNumber(key, environment, values);
953
+ } else if (isEnvVarAList(key)) {
954
+ parseStringList(key, environment, values);
955
+ } else {
956
+ var value = values[key];
957
+ if (typeof value !== "undefined" && value !== null) {
958
+ environment[key] = String(value);
959
+ }
960
+ }
961
+ }
962
+ }
963
+ return environment;
964
+ }
965
+
966
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js
967
+ function getEnv() {
968
+ var processEnv = parseEnvironment(process.env);
969
+ return Object.assign({}, DEFAULT_ENVIRONMENT, processEnv);
970
+ }
971
+
972
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/version.js
973
+ var VERSION2 = "1.23.0";
974
+
975
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.23.0/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js
976
+ // @__NO_SIDE_EFFECTS__
977
+ function createConstMap(values) {
978
+ var res = {};
979
+ var len = values.length;
980
+ for (var lp = 0; lp < len; lp++) {
981
+ var val = values[lp];
982
+ if (val) {
983
+ res[String(val).toUpperCase().replace(/[-.]/g, "_")] = val;
984
+ }
985
+ }
986
+ return res;
987
+ }
988
+
989
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.23.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
990
+ var TMP_CLOUD_PROVIDER = "cloud.provider";
991
+ var TMP_CLOUD_ACCOUNT_ID = "cloud.account.id";
992
+ var TMP_CLOUD_REGION = "cloud.region";
993
+ var TMP_CLOUD_AVAILABILITY_ZONE = "cloud.availability_zone";
994
+ var TMP_CLOUD_PLATFORM = "cloud.platform";
995
+ var TMP_AWS_ECS_CONTAINER_ARN = "aws.ecs.container.arn";
996
+ var TMP_AWS_ECS_CLUSTER_ARN = "aws.ecs.cluster.arn";
997
+ var TMP_AWS_ECS_LAUNCHTYPE = "aws.ecs.launchtype";
998
+ var TMP_AWS_ECS_TASK_ARN = "aws.ecs.task.arn";
999
+ var TMP_AWS_ECS_TASK_FAMILY = "aws.ecs.task.family";
1000
+ var TMP_AWS_ECS_TASK_REVISION = "aws.ecs.task.revision";
1001
+ var TMP_AWS_EKS_CLUSTER_ARN = "aws.eks.cluster.arn";
1002
+ var TMP_AWS_LOG_GROUP_NAMES = "aws.log.group.names";
1003
+ var TMP_AWS_LOG_GROUP_ARNS = "aws.log.group.arns";
1004
+ var TMP_AWS_LOG_STREAM_NAMES = "aws.log.stream.names";
1005
+ var TMP_AWS_LOG_STREAM_ARNS = "aws.log.stream.arns";
1006
+ var TMP_CONTAINER_NAME = "container.name";
1007
+ var TMP_CONTAINER_ID = "container.id";
1008
+ var TMP_CONTAINER_RUNTIME = "container.runtime";
1009
+ var TMP_CONTAINER_IMAGE_NAME = "container.image.name";
1010
+ var TMP_CONTAINER_IMAGE_TAG = "container.image.tag";
1011
+ var TMP_DEPLOYMENT_ENVIRONMENT = "deployment.environment";
1012
+ var TMP_DEVICE_ID = "device.id";
1013
+ var TMP_DEVICE_MODEL_IDENTIFIER = "device.model.identifier";
1014
+ var TMP_DEVICE_MODEL_NAME = "device.model.name";
1015
+ var TMP_FAAS_NAME = "faas.name";
1016
+ var TMP_FAAS_ID = "faas.id";
1017
+ var TMP_FAAS_VERSION = "faas.version";
1018
+ var TMP_FAAS_INSTANCE = "faas.instance";
1019
+ var TMP_FAAS_MAX_MEMORY = "faas.max_memory";
1020
+ var TMP_HOST_ID = "host.id";
1021
+ var TMP_HOST_NAME = "host.name";
1022
+ var TMP_HOST_TYPE = "host.type";
1023
+ var TMP_HOST_ARCH = "host.arch";
1024
+ var TMP_HOST_IMAGE_NAME = "host.image.name";
1025
+ var TMP_HOST_IMAGE_ID = "host.image.id";
1026
+ var TMP_HOST_IMAGE_VERSION = "host.image.version";
1027
+ var TMP_K8S_CLUSTER_NAME = "k8s.cluster.name";
1028
+ var TMP_K8S_NODE_NAME = "k8s.node.name";
1029
+ var TMP_K8S_NODE_UID = "k8s.node.uid";
1030
+ var TMP_K8S_NAMESPACE_NAME = "k8s.namespace.name";
1031
+ var TMP_K8S_POD_UID = "k8s.pod.uid";
1032
+ var TMP_K8S_POD_NAME = "k8s.pod.name";
1033
+ var TMP_K8S_CONTAINER_NAME = "k8s.container.name";
1034
+ var TMP_K8S_REPLICASET_UID = "k8s.replicaset.uid";
1035
+ var TMP_K8S_REPLICASET_NAME = "k8s.replicaset.name";
1036
+ var TMP_K8S_DEPLOYMENT_UID = "k8s.deployment.uid";
1037
+ var TMP_K8S_DEPLOYMENT_NAME = "k8s.deployment.name";
1038
+ var TMP_K8S_STATEFULSET_UID = "k8s.statefulset.uid";
1039
+ var TMP_K8S_STATEFULSET_NAME = "k8s.statefulset.name";
1040
+ var TMP_K8S_DAEMONSET_UID = "k8s.daemonset.uid";
1041
+ var TMP_K8S_DAEMONSET_NAME = "k8s.daemonset.name";
1042
+ var TMP_K8S_JOB_UID = "k8s.job.uid";
1043
+ var TMP_K8S_JOB_NAME = "k8s.job.name";
1044
+ var TMP_K8S_CRONJOB_UID = "k8s.cronjob.uid";
1045
+ var TMP_K8S_CRONJOB_NAME = "k8s.cronjob.name";
1046
+ var TMP_OS_TYPE = "os.type";
1047
+ var TMP_OS_DESCRIPTION = "os.description";
1048
+ var TMP_OS_NAME = "os.name";
1049
+ var TMP_OS_VERSION = "os.version";
1050
+ var TMP_PROCESS_PID = "process.pid";
1051
+ var TMP_PROCESS_EXECUTABLE_NAME = "process.executable.name";
1052
+ var TMP_PROCESS_EXECUTABLE_PATH = "process.executable.path";
1053
+ var TMP_PROCESS_COMMAND = "process.command";
1054
+ var TMP_PROCESS_COMMAND_LINE = "process.command_line";
1055
+ var TMP_PROCESS_COMMAND_ARGS = "process.command_args";
1056
+ var TMP_PROCESS_OWNER = "process.owner";
1057
+ var TMP_PROCESS_RUNTIME_NAME = "process.runtime.name";
1058
+ var TMP_PROCESS_RUNTIME_VERSION = "process.runtime.version";
1059
+ var TMP_PROCESS_RUNTIME_DESCRIPTION = "process.runtime.description";
1060
+ var TMP_SERVICE_NAME = "service.name";
1061
+ var TMP_SERVICE_NAMESPACE = "service.namespace";
1062
+ var TMP_SERVICE_INSTANCE_ID = "service.instance.id";
1063
+ var TMP_SERVICE_VERSION = "service.version";
1064
+ var TMP_TELEMETRY_SDK_NAME = "telemetry.sdk.name";
1065
+ var TMP_TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language";
1066
+ var TMP_TELEMETRY_SDK_VERSION = "telemetry.sdk.version";
1067
+ var TMP_TELEMETRY_AUTO_VERSION = "telemetry.auto.version";
1068
+ var TMP_WEBENGINE_NAME = "webengine.name";
1069
+ var TMP_WEBENGINE_VERSION = "webengine.version";
1070
+ var TMP_WEBENGINE_DESCRIPTION = "webengine.description";
1071
+ var SemanticResourceAttributes = /* @__PURE__ */ createConstMap([
1072
+ TMP_CLOUD_PROVIDER,
1073
+ TMP_CLOUD_ACCOUNT_ID,
1074
+ TMP_CLOUD_REGION,
1075
+ TMP_CLOUD_AVAILABILITY_ZONE,
1076
+ TMP_CLOUD_PLATFORM,
1077
+ TMP_AWS_ECS_CONTAINER_ARN,
1078
+ TMP_AWS_ECS_CLUSTER_ARN,
1079
+ TMP_AWS_ECS_LAUNCHTYPE,
1080
+ TMP_AWS_ECS_TASK_ARN,
1081
+ TMP_AWS_ECS_TASK_FAMILY,
1082
+ TMP_AWS_ECS_TASK_REVISION,
1083
+ TMP_AWS_EKS_CLUSTER_ARN,
1084
+ TMP_AWS_LOG_GROUP_NAMES,
1085
+ TMP_AWS_LOG_GROUP_ARNS,
1086
+ TMP_AWS_LOG_STREAM_NAMES,
1087
+ TMP_AWS_LOG_STREAM_ARNS,
1088
+ TMP_CONTAINER_NAME,
1089
+ TMP_CONTAINER_ID,
1090
+ TMP_CONTAINER_RUNTIME,
1091
+ TMP_CONTAINER_IMAGE_NAME,
1092
+ TMP_CONTAINER_IMAGE_TAG,
1093
+ TMP_DEPLOYMENT_ENVIRONMENT,
1094
+ TMP_DEVICE_ID,
1095
+ TMP_DEVICE_MODEL_IDENTIFIER,
1096
+ TMP_DEVICE_MODEL_NAME,
1097
+ TMP_FAAS_NAME,
1098
+ TMP_FAAS_ID,
1099
+ TMP_FAAS_VERSION,
1100
+ TMP_FAAS_INSTANCE,
1101
+ TMP_FAAS_MAX_MEMORY,
1102
+ TMP_HOST_ID,
1103
+ TMP_HOST_NAME,
1104
+ TMP_HOST_TYPE,
1105
+ TMP_HOST_ARCH,
1106
+ TMP_HOST_IMAGE_NAME,
1107
+ TMP_HOST_IMAGE_ID,
1108
+ TMP_HOST_IMAGE_VERSION,
1109
+ TMP_K8S_CLUSTER_NAME,
1110
+ TMP_K8S_NODE_NAME,
1111
+ TMP_K8S_NODE_UID,
1112
+ TMP_K8S_NAMESPACE_NAME,
1113
+ TMP_K8S_POD_UID,
1114
+ TMP_K8S_POD_NAME,
1115
+ TMP_K8S_CONTAINER_NAME,
1116
+ TMP_K8S_REPLICASET_UID,
1117
+ TMP_K8S_REPLICASET_NAME,
1118
+ TMP_K8S_DEPLOYMENT_UID,
1119
+ TMP_K8S_DEPLOYMENT_NAME,
1120
+ TMP_K8S_STATEFULSET_UID,
1121
+ TMP_K8S_STATEFULSET_NAME,
1122
+ TMP_K8S_DAEMONSET_UID,
1123
+ TMP_K8S_DAEMONSET_NAME,
1124
+ TMP_K8S_JOB_UID,
1125
+ TMP_K8S_JOB_NAME,
1126
+ TMP_K8S_CRONJOB_UID,
1127
+ TMP_K8S_CRONJOB_NAME,
1128
+ TMP_OS_TYPE,
1129
+ TMP_OS_DESCRIPTION,
1130
+ TMP_OS_NAME,
1131
+ TMP_OS_VERSION,
1132
+ TMP_PROCESS_PID,
1133
+ TMP_PROCESS_EXECUTABLE_NAME,
1134
+ TMP_PROCESS_EXECUTABLE_PATH,
1135
+ TMP_PROCESS_COMMAND,
1136
+ TMP_PROCESS_COMMAND_LINE,
1137
+ TMP_PROCESS_COMMAND_ARGS,
1138
+ TMP_PROCESS_OWNER,
1139
+ TMP_PROCESS_RUNTIME_NAME,
1140
+ TMP_PROCESS_RUNTIME_VERSION,
1141
+ TMP_PROCESS_RUNTIME_DESCRIPTION,
1142
+ TMP_SERVICE_NAME,
1143
+ TMP_SERVICE_NAMESPACE,
1144
+ TMP_SERVICE_INSTANCE_ID,
1145
+ TMP_SERVICE_VERSION,
1146
+ TMP_TELEMETRY_SDK_NAME,
1147
+ TMP_TELEMETRY_SDK_LANGUAGE,
1148
+ TMP_TELEMETRY_SDK_VERSION,
1149
+ TMP_TELEMETRY_AUTO_VERSION,
1150
+ TMP_WEBENGINE_NAME,
1151
+ TMP_WEBENGINE_VERSION,
1152
+ TMP_WEBENGINE_DESCRIPTION
1153
+ ]);
1154
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_CPP = "cpp";
1155
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_DOTNET = "dotnet";
1156
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_ERLANG = "erlang";
1157
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_GO = "go";
1158
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_JAVA = "java";
1159
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_NODEJS = "nodejs";
1160
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_PHP = "php";
1161
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_PYTHON = "python";
1162
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_RUBY = "ruby";
1163
+ var TMP_TELEMETRYSDKLANGUAGEVALUES_WEBJS = "webjs";
1164
+ var TelemetrySdkLanguageValues = /* @__PURE__ */ createConstMap([
1165
+ TMP_TELEMETRYSDKLANGUAGEVALUES_CPP,
1166
+ TMP_TELEMETRYSDKLANGUAGEVALUES_DOTNET,
1167
+ TMP_TELEMETRYSDKLANGUAGEVALUES_ERLANG,
1168
+ TMP_TELEMETRYSDKLANGUAGEVALUES_GO,
1169
+ TMP_TELEMETRYSDKLANGUAGEVALUES_JAVA,
1170
+ TMP_TELEMETRYSDKLANGUAGEVALUES_NODEJS,
1171
+ TMP_TELEMETRYSDKLANGUAGEVALUES_PHP,
1172
+ TMP_TELEMETRYSDKLANGUAGEVALUES_PYTHON,
1173
+ TMP_TELEMETRYSDKLANGUAGEVALUES_RUBY,
1174
+ TMP_TELEMETRYSDKLANGUAGEVALUES_WEBJS
1175
+ ]);
1176
+
1177
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
1178
+ var _a;
1179
+ var SDK_INFO = (_a = {}, _a[SemanticResourceAttributes.TELEMETRY_SDK_NAME] = "opentelemetry", _a[SemanticResourceAttributes.PROCESS_RUNTIME_NAME] = "node", _a[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE] = TelemetrySdkLanguageValues.NODEJS, _a[SemanticResourceAttributes.TELEMETRY_SDK_VERSION] = VERSION2, _a);
1180
+
1181
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/platform/node/timer-util.js
1182
+ function unrefTimer(timer) {
1183
+ timer.unref();
1184
+ }
1185
+
1186
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/ExportResult.js
1187
+ var ExportResultCode;
1188
+ (function(ExportResultCode2) {
1189
+ ExportResultCode2[ExportResultCode2["SUCCESS"] = 0] = "SUCCESS";
1190
+ ExportResultCode2[ExportResultCode2["FAILED"] = 1] = "FAILED";
1191
+ })(ExportResultCode || (ExportResultCode = {}));
1192
+
1193
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/utils/promise.js
1194
+ var Deferred = (
1195
+ /** @class */
1196
+ function() {
1197
+ function Deferred2() {
1198
+ var _this = this;
1199
+ this._promise = new Promise(function(resolve, reject) {
1200
+ _this._resolve = resolve;
1201
+ _this._reject = reject;
1202
+ });
1203
+ }
1204
+ Object.defineProperty(Deferred2.prototype, "promise", {
1205
+ get: function() {
1206
+ return this._promise;
1207
+ },
1208
+ enumerable: false,
1209
+ configurable: true
1210
+ });
1211
+ Deferred2.prototype.resolve = function(val) {
1212
+ this._resolve(val);
1213
+ };
1214
+ Deferred2.prototype.reject = function(err) {
1215
+ this._reject(err);
1216
+ };
1217
+ return Deferred2;
1218
+ }()
1219
+ );
1220
+
1221
+ // ../../node_modules/.pnpm/@opentelemetry+core@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/core/build/esm/utils/callback.js
1222
+ var __read5 = function(o, n) {
1223
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
1224
+ if (!m)
1225
+ return o;
1226
+ var i = m.call(o), r, ar = [], e;
1227
+ try {
1228
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
1229
+ ar.push(r.value);
1230
+ } catch (error) {
1231
+ e = { error };
1232
+ } finally {
1233
+ try {
1234
+ if (r && !r.done && (m = i["return"]))
1235
+ m.call(i);
1236
+ } finally {
1237
+ if (e)
1238
+ throw e.error;
1239
+ }
1240
+ }
1241
+ return ar;
1242
+ };
1243
+ var __spreadArray5 = function(to, from, pack) {
1244
+ if (pack || arguments.length === 2)
1245
+ for (var i = 0, l = from.length, ar; i < l; i++) {
1246
+ if (ar || !(i in from)) {
1247
+ if (!ar)
1248
+ ar = Array.prototype.slice.call(from, 0, i);
1249
+ ar[i] = from[i];
1250
+ }
1251
+ }
1252
+ return to.concat(ar || Array.prototype.slice.call(from));
1253
+ };
1254
+ var BindOnceFuture = (
1255
+ /** @class */
1256
+ function() {
1257
+ function BindOnceFuture2(_callback, _that) {
1258
+ this._callback = _callback;
1259
+ this._that = _that;
1260
+ this._isCalled = false;
1261
+ this._deferred = new Deferred();
1262
+ }
1263
+ Object.defineProperty(BindOnceFuture2.prototype, "isCalled", {
1264
+ get: function() {
1265
+ return this._isCalled;
1266
+ },
1267
+ enumerable: false,
1268
+ configurable: true
1269
+ });
1270
+ Object.defineProperty(BindOnceFuture2.prototype, "promise", {
1271
+ get: function() {
1272
+ return this._deferred.promise;
1273
+ },
1274
+ enumerable: false,
1275
+ configurable: true
1276
+ });
1277
+ BindOnceFuture2.prototype.call = function() {
1278
+ var _a2;
1279
+ var _this = this;
1280
+ var args = [];
1281
+ for (var _i = 0; _i < arguments.length; _i++) {
1282
+ args[_i] = arguments[_i];
1283
+ }
1284
+ if (!this._isCalled) {
1285
+ this._isCalled = true;
1286
+ try {
1287
+ Promise.resolve((_a2 = this._callback).call.apply(_a2, __spreadArray5([this._that], __read5(args), false))).then(function(val) {
1288
+ return _this._deferred.resolve(val);
1289
+ }, function(err) {
1290
+ return _this._deferred.reject(err);
1291
+ });
1292
+ } catch (err) {
1293
+ this._deferred.reject(err);
1294
+ }
1295
+ }
1296
+ return this._deferred.promise;
1297
+ };
1298
+ return BindOnceFuture2;
1299
+ }()
1300
+ );
1301
+
1302
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js
1303
+ init_esm();
1304
+ var BatchSpanProcessorBase = (
1305
+ /** @class */
1306
+ function() {
1307
+ function BatchSpanProcessorBase2(_exporter, config) {
1308
+ this._exporter = _exporter;
1309
+ this._isExporting = false;
1310
+ this._finishedSpans = [];
1311
+ this._droppedSpansCount = 0;
1312
+ var env = getEnv();
1313
+ this._maxExportBatchSize = typeof (config === null || config === void 0 ? void 0 : config.maxExportBatchSize) === "number" ? config.maxExportBatchSize : env.OTEL_BSP_MAX_EXPORT_BATCH_SIZE;
1314
+ this._maxQueueSize = typeof (config === null || config === void 0 ? void 0 : config.maxQueueSize) === "number" ? config.maxQueueSize : env.OTEL_BSP_MAX_QUEUE_SIZE;
1315
+ this._scheduledDelayMillis = typeof (config === null || config === void 0 ? void 0 : config.scheduledDelayMillis) === "number" ? config.scheduledDelayMillis : env.OTEL_BSP_SCHEDULE_DELAY;
1316
+ this._exportTimeoutMillis = typeof (config === null || config === void 0 ? void 0 : config.exportTimeoutMillis) === "number" ? config.exportTimeoutMillis : env.OTEL_BSP_EXPORT_TIMEOUT;
1317
+ this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
1318
+ if (this._maxExportBatchSize > this._maxQueueSize) {
1319
+ diag.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize");
1320
+ this._maxExportBatchSize = this._maxQueueSize;
1321
+ }
1322
+ }
1323
+ BatchSpanProcessorBase2.prototype.forceFlush = function() {
1324
+ if (this._shutdownOnce.isCalled) {
1325
+ return this._shutdownOnce.promise;
1326
+ }
1327
+ return this._flushAll();
1328
+ };
1329
+ BatchSpanProcessorBase2.prototype.onStart = function(_span, _parentContext) {
1330
+ };
1331
+ BatchSpanProcessorBase2.prototype.onEnd = function(span) {
1332
+ if (this._shutdownOnce.isCalled) {
1333
+ return;
1334
+ }
1335
+ if ((span.spanContext().traceFlags & TraceFlags.SAMPLED) === 0) {
1336
+ return;
1337
+ }
1338
+ this._addToBuffer(span);
1339
+ };
1340
+ BatchSpanProcessorBase2.prototype.shutdown = function() {
1341
+ return this._shutdownOnce.call();
1342
+ };
1343
+ BatchSpanProcessorBase2.prototype._shutdown = function() {
1344
+ var _this = this;
1345
+ return Promise.resolve().then(function() {
1346
+ return _this.onShutdown();
1347
+ }).then(function() {
1348
+ return _this._flushAll();
1349
+ }).then(function() {
1350
+ return _this._exporter.shutdown();
1351
+ });
1352
+ };
1353
+ BatchSpanProcessorBase2.prototype._addToBuffer = function(span) {
1354
+ if (this._finishedSpans.length >= this._maxQueueSize) {
1355
+ if (this._droppedSpansCount === 0) {
1356
+ diag.debug("maxQueueSize reached, dropping spans");
1357
+ }
1358
+ this._droppedSpansCount++;
1359
+ return;
1360
+ }
1361
+ if (this._droppedSpansCount > 0) {
1362
+ diag.warn("Dropped " + this._droppedSpansCount + " spans because maxQueueSize reached");
1363
+ this._droppedSpansCount = 0;
1364
+ }
1365
+ this._finishedSpans.push(span);
1366
+ this._maybeStartTimer();
1367
+ };
1368
+ BatchSpanProcessorBase2.prototype._flushAll = function() {
1369
+ var _this = this;
1370
+ return new Promise(function(resolve, reject) {
1371
+ var promises = [];
1372
+ var count = Math.ceil(_this._finishedSpans.length / _this._maxExportBatchSize);
1373
+ for (var i = 0, j = count; i < j; i++) {
1374
+ promises.push(_this._flushOneBatch());
1375
+ }
1376
+ Promise.all(promises).then(function() {
1377
+ resolve();
1378
+ }).catch(reject);
1379
+ });
1380
+ };
1381
+ BatchSpanProcessorBase2.prototype._flushOneBatch = function() {
1382
+ var _this = this;
1383
+ this._clearTimer();
1384
+ if (this._finishedSpans.length === 0) {
1385
+ return Promise.resolve();
1386
+ }
1387
+ return new Promise(function(resolve, reject) {
1388
+ var timer = setTimeout(function() {
1389
+ reject(new Error("Timeout"));
1390
+ }, _this._exportTimeoutMillis);
1391
+ context.with(suppressTracing(context.active()), function() {
1392
+ var spans;
1393
+ if (_this._finishedSpans.length <= _this._maxExportBatchSize) {
1394
+ spans = _this._finishedSpans;
1395
+ _this._finishedSpans = [];
1396
+ } else {
1397
+ spans = _this._finishedSpans.splice(0, _this._maxExportBatchSize);
1398
+ }
1399
+ var doExport = function() {
1400
+ return _this._exporter.export(spans, function(result) {
1401
+ var _a2;
1402
+ clearTimeout(timer);
1403
+ if (result.code === ExportResultCode.SUCCESS) {
1404
+ resolve();
1405
+ } else {
1406
+ reject((_a2 = result.error) !== null && _a2 !== void 0 ? _a2 : new Error("BatchSpanProcessor: span export failed"));
1407
+ }
1408
+ });
1409
+ };
1410
+ var pendingResources = null;
1411
+ for (var i = 0, len = spans.length; i < len; i++) {
1412
+ var span = spans[i];
1413
+ if (span.resource.asyncAttributesPending && span.resource.waitForAsyncAttributes) {
1414
+ pendingResources !== null && pendingResources !== void 0 ? pendingResources : pendingResources = [];
1415
+ pendingResources.push(span.resource.waitForAsyncAttributes());
1416
+ }
1417
+ }
1418
+ if (pendingResources === null) {
1419
+ doExport();
1420
+ } else {
1421
+ Promise.all(pendingResources).then(doExport, function(err) {
1422
+ globalErrorHandler(err);
1423
+ reject(err);
1424
+ });
1425
+ }
1426
+ });
1427
+ });
1428
+ };
1429
+ BatchSpanProcessorBase2.prototype._maybeStartTimer = function() {
1430
+ var _this = this;
1431
+ if (this._isExporting)
1432
+ return;
1433
+ var flush = function() {
1434
+ _this._isExporting = true;
1435
+ _this._flushOneBatch().finally(function() {
1436
+ _this._isExporting = false;
1437
+ if (_this._finishedSpans.length > 0) {
1438
+ _this._clearTimer();
1439
+ _this._maybeStartTimer();
1440
+ }
1441
+ }).catch(function(e) {
1442
+ _this._isExporting = false;
1443
+ globalErrorHandler(e);
1444
+ });
1445
+ };
1446
+ if (this._finishedSpans.length >= this._maxExportBatchSize) {
1447
+ return flush();
1448
+ }
1449
+ if (this._timer !== void 0)
1450
+ return;
1451
+ this._timer = setTimeout(function() {
1452
+ return flush();
1453
+ }, this._scheduledDelayMillis);
1454
+ unrefTimer(this._timer);
1455
+ };
1456
+ BatchSpanProcessorBase2.prototype._clearTimer = function() {
1457
+ if (this._timer !== void 0) {
1458
+ clearTimeout(this._timer);
1459
+ this._timer = void 0;
1460
+ }
1461
+ };
1462
+ return BatchSpanProcessorBase2;
1463
+ }()
1464
+ );
1465
+
1466
+ // ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js
1467
+ var __extends = /* @__PURE__ */ function() {
1468
+ var extendStatics = function(d, b) {
1469
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
1470
+ d2.__proto__ = b2;
1471
+ } || function(d2, b2) {
1472
+ for (var p in b2)
1473
+ if (Object.prototype.hasOwnProperty.call(b2, p))
1474
+ d2[p] = b2[p];
1475
+ };
1476
+ return extendStatics(d, b);
1477
+ };
1478
+ return function(d, b) {
1479
+ if (typeof b !== "function" && b !== null)
1480
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1481
+ extendStatics(d, b);
1482
+ function __() {
1483
+ this.constructor = d;
1484
+ }
1485
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1486
+ };
1487
+ }();
1488
+ var BatchSpanProcessor = (
1489
+ /** @class */
1490
+ function(_super) {
1491
+ __extends(BatchSpanProcessor2, _super);
1492
+ function BatchSpanProcessor2() {
1493
+ return _super !== null && _super.apply(this, arguments) || this;
1494
+ }
1495
+ BatchSpanProcessor2.prototype.onShutdown = function() {
1496
+ };
1497
+ return BatchSpanProcessor2;
1498
+ }(BatchSpanProcessorBase)
1499
+ );
1500
+
1501
+ // ../../node_modules/.pnpm/@opentelemetry+resources@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/resources/build/esm/Resource.js
1502
+ init_esm();
1503
+
1504
+ // ../../node_modules/.pnpm/@opentelemetry+resources@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/resources/build/esm/platform/node/default-service-name.js
1505
+ function defaultServiceName() {
1506
+ return "unknown_service:" + process.argv0;
1507
+ }
1508
+
1509
+ // ../../node_modules/.pnpm/@opentelemetry+resources@1.23.0_@opentelemetry+api@1.8.0/node_modules/@opentelemetry/resources/build/esm/Resource.js
1510
+ var __assign = function() {
1511
+ __assign = Object.assign || function(t) {
1512
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1513
+ s = arguments[i];
1514
+ for (var p in s)
1515
+ if (Object.prototype.hasOwnProperty.call(s, p))
1516
+ t[p] = s[p];
1517
+ }
1518
+ return t;
1519
+ };
1520
+ return __assign.apply(this, arguments);
1521
+ };
1522
+ var __awaiter = function(thisArg, _arguments, P, generator) {
1523
+ function adopt(value) {
1524
+ return value instanceof P ? value : new P(function(resolve) {
1525
+ resolve(value);
1526
+ });
1527
+ }
1528
+ return new (P || (P = Promise))(function(resolve, reject) {
1529
+ function fulfilled(value) {
1530
+ try {
1531
+ step(generator.next(value));
1532
+ } catch (e) {
1533
+ reject(e);
1534
+ }
1535
+ }
1536
+ function rejected(value) {
1537
+ try {
1538
+ step(generator["throw"](value));
1539
+ } catch (e) {
1540
+ reject(e);
1541
+ }
1542
+ }
1543
+ function step(result) {
1544
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1545
+ }
1546
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1547
+ });
1548
+ };
1549
+ var __generator = function(thisArg, body) {
1550
+ var _ = { label: 0, sent: function() {
1551
+ if (t[0] & 1)
1552
+ throw t[1];
1553
+ return t[1];
1554
+ }, trys: [], ops: [] }, f, y, t, g;
1555
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1556
+ return this;
1557
+ }), g;
1558
+ function verb(n) {
1559
+ return function(v) {
1560
+ return step([n, v]);
1561
+ };
1562
+ }
1563
+ function step(op) {
1564
+ if (f)
1565
+ throw new TypeError("Generator is already executing.");
1566
+ while (_)
1567
+ try {
1568
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
1569
+ return t;
1570
+ if (y = 0, t)
1571
+ op = [op[0] & 2, t.value];
1572
+ switch (op[0]) {
1573
+ case 0:
1574
+ case 1:
1575
+ t = op;
1576
+ break;
1577
+ case 4:
1578
+ _.label++;
1579
+ return { value: op[1], done: false };
1580
+ case 5:
1581
+ _.label++;
1582
+ y = op[1];
1583
+ op = [0];
1584
+ continue;
1585
+ case 7:
1586
+ op = _.ops.pop();
1587
+ _.trys.pop();
1588
+ continue;
1589
+ default:
1590
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1591
+ _ = 0;
1592
+ continue;
1593
+ }
1594
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1595
+ _.label = op[1];
1596
+ break;
1597
+ }
1598
+ if (op[0] === 6 && _.label < t[1]) {
1599
+ _.label = t[1];
1600
+ t = op;
1601
+ break;
1602
+ }
1603
+ if (t && _.label < t[2]) {
1604
+ _.label = t[2];
1605
+ _.ops.push(op);
1606
+ break;
1607
+ }
1608
+ if (t[2])
1609
+ _.ops.pop();
1610
+ _.trys.pop();
1611
+ continue;
1612
+ }
1613
+ op = body.call(thisArg, _);
1614
+ } catch (e) {
1615
+ op = [6, e];
1616
+ y = 0;
1617
+ } finally {
1618
+ f = t = 0;
1619
+ }
1620
+ if (op[0] & 5)
1621
+ throw op[1];
1622
+ return { value: op[0] ? op[1] : void 0, done: true };
1623
+ }
1624
+ };
1625
+ var __read6 = function(o, n) {
1626
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
1627
+ if (!m)
1628
+ return o;
1629
+ var i = m.call(o), r, ar = [], e;
1630
+ try {
1631
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
1632
+ ar.push(r.value);
1633
+ } catch (error) {
1634
+ e = { error };
1635
+ } finally {
1636
+ try {
1637
+ if (r && !r.done && (m = i["return"]))
1638
+ m.call(i);
1639
+ } finally {
1640
+ if (e)
1641
+ throw e.error;
1642
+ }
1643
+ }
1644
+ return ar;
1645
+ };
1646
+ var Resource = (
1647
+ /** @class */
1648
+ function() {
1649
+ function Resource2(attributes, asyncAttributesPromise) {
1650
+ var _this = this;
1651
+ var _a2;
1652
+ this._attributes = attributes;
1653
+ this.asyncAttributesPending = asyncAttributesPromise != null;
1654
+ this._syncAttributes = (_a2 = this._attributes) !== null && _a2 !== void 0 ? _a2 : {};
1655
+ this._asyncAttributesPromise = asyncAttributesPromise === null || asyncAttributesPromise === void 0 ? void 0 : asyncAttributesPromise.then(function(asyncAttributes) {
1656
+ _this._attributes = Object.assign({}, _this._attributes, asyncAttributes);
1657
+ _this.asyncAttributesPending = false;
1658
+ return asyncAttributes;
1659
+ }, function(err) {
1660
+ diag.debug("a resource's async attributes promise rejected: %s", err);
1661
+ _this.asyncAttributesPending = false;
1662
+ return {};
1663
+ });
1664
+ }
1665
+ Resource2.empty = function() {
1666
+ return Resource2.EMPTY;
1667
+ };
1668
+ Resource2.default = function() {
1669
+ var _a2;
1670
+ return new Resource2((_a2 = {}, _a2[SemanticResourceAttributes.SERVICE_NAME] = defaultServiceName(), _a2[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE] = SDK_INFO[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE], _a2[SemanticResourceAttributes.TELEMETRY_SDK_NAME] = SDK_INFO[SemanticResourceAttributes.TELEMETRY_SDK_NAME], _a2[SemanticResourceAttributes.TELEMETRY_SDK_VERSION] = SDK_INFO[SemanticResourceAttributes.TELEMETRY_SDK_VERSION], _a2));
1671
+ };
1672
+ Object.defineProperty(Resource2.prototype, "attributes", {
1673
+ get: function() {
1674
+ var _a2;
1675
+ if (this.asyncAttributesPending) {
1676
+ diag.error("Accessing resource attributes before async attributes settled");
1677
+ }
1678
+ return (_a2 = this._attributes) !== null && _a2 !== void 0 ? _a2 : {};
1679
+ },
1680
+ enumerable: false,
1681
+ configurable: true
1682
+ });
1683
+ Resource2.prototype.waitForAsyncAttributes = function() {
1684
+ return __awaiter(this, void 0, void 0, function() {
1685
+ return __generator(this, function(_a2) {
1686
+ switch (_a2.label) {
1687
+ case 0:
1688
+ if (!this.asyncAttributesPending)
1689
+ return [3, 2];
1690
+ return [4, this._asyncAttributesPromise];
1691
+ case 1:
1692
+ _a2.sent();
1693
+ _a2.label = 2;
1694
+ case 2:
1695
+ return [
1696
+ 2
1697
+ /*return*/
1698
+ ];
1699
+ }
1700
+ });
1701
+ });
1702
+ };
1703
+ Resource2.prototype.merge = function(other) {
1704
+ var _this = this;
1705
+ var _a2;
1706
+ if (!other)
1707
+ return this;
1708
+ var mergedSyncAttributes = __assign(__assign({}, this._syncAttributes), (_a2 = other._syncAttributes) !== null && _a2 !== void 0 ? _a2 : other.attributes);
1709
+ if (!this._asyncAttributesPromise && !other._asyncAttributesPromise) {
1710
+ return new Resource2(mergedSyncAttributes);
1711
+ }
1712
+ var mergedAttributesPromise = Promise.all([
1713
+ this._asyncAttributesPromise,
1714
+ other._asyncAttributesPromise
1715
+ ]).then(function(_a3) {
1716
+ var _b;
1717
+ var _c = __read6(_a3, 2), thisAsyncAttributes = _c[0], otherAsyncAttributes = _c[1];
1718
+ return __assign(__assign(__assign(__assign({}, _this._syncAttributes), thisAsyncAttributes), (_b = other._syncAttributes) !== null && _b !== void 0 ? _b : other.attributes), otherAsyncAttributes);
1719
+ });
1720
+ return new Resource2(mergedSyncAttributes, mergedAttributesPromise);
1721
+ };
1722
+ Resource2.EMPTY = new Resource2({});
1723
+ return Resource2;
1724
+ }()
1725
+ );
1726
+
1727
+ // src/tracing.ts
1728
+ var import_instrumentation_dataloader = require("@opentelemetry/instrumentation-dataloader");
1729
+ init_esm();
1730
+ var import_instrumentation_express = require("@opentelemetry/instrumentation-express");
1731
+ var import_instrumentation_http = require("@opentelemetry/instrumentation-http");
1732
+ var import_instrumentation_knex = require("@opentelemetry/instrumentation-knex");
1733
+ var import_instrumentation_mysql2 = require("@opentelemetry/instrumentation-mysql2");
1734
+ var import_instrumentation_net = require("@opentelemetry/instrumentation-net");
1735
+ var import_exporter_trace_otlp_grpc = require("@opentelemetry/exporter-trace-otlp-grpc");
1736
+ var import_sdk_trace_node = require("@opentelemetry/sdk-trace-node");
1737
+ var import_ExpressLayerType = require("@opentelemetry/instrumentation-express/build/src/enums/ExpressLayerType");
1738
+ var tracingDefaults = {
1739
+ serviceName: "unknown",
1740
+ release: "unknown",
1741
+ samplingRatio: 0.2,
1742
+ graphQLDepth: 8,
1743
+ grpcDefaultPort: 4317,
1744
+ httpDefaultPort: 4318,
1745
+ host: "otlpcollector",
1746
+ logger: new DiagConsoleLogger()
1747
+ };
1748
+ async function nodeSDKBuilder(config) {
1749
+ config = { ...tracingDefaults, ...config };
1750
+ diag.setLogger(config.logger, DiagLogLevel.WARN);
1751
+ const _resource = Resource.default().merge(
1752
+ new Resource({
1753
+ [SemanticResourceAttributes.SERVICE_NAME]: config.serviceName,
1754
+ [SemanticResourceAttributes.SERVICE_VERSION]: config.release
1755
+ })
1756
+ );
1757
+ const _traceExporter = new import_exporter_trace_otlp_grpc.OTLPTraceExporter({
1758
+ //collector url
1759
+ url: `http://${config.host}:${config.grpcDefaultPort}`
1760
+ });
1761
+ const _spanProcessor = new BatchSpanProcessor(_traceExporter, {
1762
+ // only force 100ms between 2 batch exports.
1763
+ // Default is 5000ms which is 5 seconds and causes us to lose spans
1764
+ scheduledDelayMillis: 100
1765
+ });
1766
+ const _idGenerator = new import_id_generator_aws_xray.AWSXRayIdGenerator();
1767
+ const sdk = new import_sdk_node.NodeSDK({
1768
+ textMapPropagator: new import_propagator_aws_xray.AWSXRayPropagator(),
1769
+ instrumentations: [
1770
+ new import_instrumentation_aws_sdk.AwsInstrumentation({
1771
+ suppressInternalInstrumentation: true
1772
+ }),
1773
+ new import_instrumentation_dataloader.DataloaderInstrumentation({}),
1774
+ new import_instrumentation_express.ExpressInstrumentation({
1775
+ ignoreLayersType: [import_ExpressLayerType.ExpressLayerType.MIDDLEWARE]
1776
+ }),
1777
+ new import_instrumentation_graphql.GraphQLInstrumentation({
1778
+ // optional params
1779
+ depth: config.graphQLDepth,
1780
+ //query depth
1781
+ allowValues: true
1782
+ }),
1783
+ new import_instrumentation_http.HttpInstrumentation({
1784
+ ignoreIncomingPaths: ["/.well-known/apollo/server-health"]
1785
+ }),
1786
+ new import_instrumentation_knex.KnexInstrumentation({}),
1787
+ new import_instrumentation_mysql2.MySQL2Instrumentation({}),
1788
+ new import_instrumentation_net.NetInstrumentation({})
1789
+ ],
1790
+ resource: _resource,
1791
+ spanProcessor: _spanProcessor,
1792
+ traceExporter: _traceExporter,
1793
+ idGenerator: _idGenerator,
1794
+ sampler: new import_sdk_trace_node.ParentBasedSampler({
1795
+ //set at 20% sampling rate
1796
+ root: new import_sdk_trace_node.TraceIdRatioBasedSampler(config.samplingRatio)
1797
+ })
1798
+ });
1799
+ await sdk.start();
1800
+ import_process.default.on("SIGTERM", () => {
1801
+ sdk.shutdown().then(() => diag.info("Tracing and Metrics terminated")).catch(
1802
+ (error) => diag.error("Error terminating tracing and metrics", error)
1803
+ ).finally(() => import_process.default.exit(0));
1804
+ });
1805
+ }
1806
+ // Annotate the CommonJS export names for ESM import in node:
1807
+ 0 && (module.exports = {
1808
+ nodeSDKBuilder
1809
+ });