@pocket-tools/tracing 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,9 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
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
7
  var __export = (target, all) => {
11
8
  for (var name in all)
12
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -29,37 +26,32 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
26
  ));
30
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
28
 
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
- }
29
+ // src/index.ts
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ AdditionalInstrumentation: () => AdditionalInstrumentation,
33
+ nodeSDKBuilder: () => nodeSDKBuilder
38
34
  });
35
+ module.exports = __toCommonJS(src_exports);
39
36
 
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
- });
37
+ // src/tracing.ts
38
+ var import_process = __toESM(require("process"));
39
+ var import_sdk_node = require("@opentelemetry/sdk-node");
40
+ var import_instrumentation_graphql = require("@opentelemetry/instrumentation-graphql");
41
+ var import_instrumentation_aws_sdk = require("@opentelemetry/instrumentation-aws-sdk");
42
+ var import_id_generator_aws_xray = require("@opentelemetry/id-generator-aws-xray");
43
+ var import_propagator_aws_xray = require("@opentelemetry/propagator-aws-xray");
44
+ var import_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
45
+ var import_instrumentation_dataloader = require("@opentelemetry/instrumentation-dataloader");
46
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
- });
47
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js
48
+ var _globalThis = typeof globalThis === "object" ? globalThis : global;
53
49
 
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
- });
50
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/version.js
51
+ var VERSION = "1.4.1";
61
52
 
62
- // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
53
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/internal/semver.js
54
+ var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
63
55
  function _makeCompatibilityCheck(ownVersion) {
64
56
  var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
65
57
  var rejectedVersions = /* @__PURE__ */ new Set();
@@ -123,22 +115,18 @@ function _makeCompatibilityCheck(ownVersion) {
123
115
  return _reject(globalVersion);
124
116
  };
125
117
  }
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
- });
118
+ var isCompatible = _makeCompatibilityCheck(VERSION);
134
119
 
135
- // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
120
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
121
+ var major = VERSION.split(".")[0];
122
+ var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
123
+ var _global = _globalThis;
136
124
  function registerGlobal(type, instance, diag2, allowOverride) {
137
- var _a2;
125
+ var _a;
138
126
  if (allowOverride === void 0) {
139
127
  allowOverride = false;
140
128
  }
141
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a2 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a2 !== void 0 ? _a2 : {
129
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
142
130
  version: VERSION
143
131
  };
144
132
  if (!allowOverride && api[type]) {
@@ -156,8 +144,8 @@ function registerGlobal(type, instance, diag2, allowOverride) {
156
144
  return true;
157
145
  }
158
146
  function getGlobal(type) {
159
- var _a2, _b;
160
- var globalVersion = (_a2 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a2 === void 0 ? void 0 : _a2.version;
147
+ var _a, _b;
148
+ var globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
161
149
  if (!globalVersion || !isCompatible(globalVersion)) {
162
150
  return;
163
151
  }
@@ -170,19 +158,84 @@ function unregisterGlobal(type, diag2) {
170
158
  delete api[type];
171
159
  }
172
160
  }
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
161
 
185
- // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
162
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
163
+ var __read = function(o, n) {
164
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
165
+ if (!m)
166
+ return o;
167
+ var i = m.call(o), r, ar = [], e;
168
+ try {
169
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
170
+ ar.push(r.value);
171
+ } catch (error) {
172
+ e = { error };
173
+ } finally {
174
+ try {
175
+ if (r && !r.done && (m = i["return"]))
176
+ m.call(i);
177
+ } finally {
178
+ if (e)
179
+ throw e.error;
180
+ }
181
+ }
182
+ return ar;
183
+ };
184
+ var __spreadArray = function(to, from, pack) {
185
+ if (pack || arguments.length === 2)
186
+ for (var i = 0, l = from.length, ar; i < l; i++) {
187
+ if (ar || !(i in from)) {
188
+ if (!ar)
189
+ ar = Array.prototype.slice.call(from, 0, i);
190
+ ar[i] = from[i];
191
+ }
192
+ }
193
+ return to.concat(ar || Array.prototype.slice.call(from));
194
+ };
195
+ var DiagComponentLogger = (
196
+ /** @class */
197
+ function() {
198
+ function DiagComponentLogger2(props) {
199
+ this._namespace = props.namespace || "DiagComponentLogger";
200
+ }
201
+ DiagComponentLogger2.prototype.debug = function() {
202
+ var args = [];
203
+ for (var _i = 0; _i < arguments.length; _i++) {
204
+ args[_i] = arguments[_i];
205
+ }
206
+ return logProxy("debug", this._namespace, args);
207
+ };
208
+ DiagComponentLogger2.prototype.error = function() {
209
+ var args = [];
210
+ for (var _i = 0; _i < arguments.length; _i++) {
211
+ args[_i] = arguments[_i];
212
+ }
213
+ return logProxy("error", this._namespace, args);
214
+ };
215
+ DiagComponentLogger2.prototype.info = function() {
216
+ var args = [];
217
+ for (var _i = 0; _i < arguments.length; _i++) {
218
+ args[_i] = arguments[_i];
219
+ }
220
+ return logProxy("info", this._namespace, args);
221
+ };
222
+ DiagComponentLogger2.prototype.warn = function() {
223
+ var args = [];
224
+ for (var _i = 0; _i < arguments.length; _i++) {
225
+ args[_i] = arguments[_i];
226
+ }
227
+ return logProxy("warn", this._namespace, args);
228
+ };
229
+ DiagComponentLogger2.prototype.verbose = function() {
230
+ var args = [];
231
+ for (var _i = 0; _i < arguments.length; _i++) {
232
+ args[_i] = arguments[_i];
233
+ }
234
+ return logProxy("verbose", this._namespace, args);
235
+ };
236
+ return DiagComponentLogger2;
237
+ }()
238
+ );
186
239
  function logProxy(funcName, namespace, args) {
187
240
  var logger = getGlobal("diag");
188
241
  if (!logger) {
@@ -191,104 +244,20 @@ function logProxy(funcName, namespace, args) {
191
244
  args.unshift(namespace);
192
245
  return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
193
246
  }
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
247
 
275
- // ../../node_modules/.pnpm/@opentelemetry+api@1.8.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
248
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/diag/types.js
276
249
  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
250
+ (function(DiagLogLevel2) {
251
+ DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
252
+ DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
253
+ DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
254
+ DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
255
+ DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
256
+ DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
257
+ DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
258
+ })(DiagLogLevel || (DiagLogLevel = {}));
259
+
260
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
292
261
  function createLogLevelDiagLogger(maxLevel, logger) {
293
262
  if (maxLevel < DiagLogLevel.NONE) {
294
263
  maxLevel = DiagLogLevel.NONE;
@@ -312,667 +281,156 @@ function createLogLevelDiagLogger(maxLevel, logger) {
312
281
  verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
313
282
  };
314
283
  }
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
284
 
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
- }
285
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/api/diag.js
286
+ var __read2 = function(o, n) {
287
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
288
+ if (!m)
289
+ return o;
290
+ var i = m.call(o), r, ar = [], e;
291
+ try {
292
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
293
+ ar.push(r.value);
294
+ } catch (error) {
295
+ e = { error };
296
+ } finally {
297
+ try {
298
+ if (r && !r.done && (m = i["return"]))
299
+ m.call(i);
300
+ } finally {
301
+ if (e)
302
+ throw e.error;
303
+ }
304
+ }
305
+ return ar;
306
+ };
307
+ var __spreadArray2 = function(to, from, pack) {
308
+ if (pack || arguments.length === 2)
309
+ for (var i = 0, l = from.length, ar; i < l; i++) {
310
+ if (ar || !(i in from)) {
311
+ if (!ar)
312
+ ar = Array.prototype.slice.call(from, 0, i);
313
+ ar[i] = from[i];
347
314
  }
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);
315
+ }
316
+ return to.concat(ar || Array.prototype.slice.call(from));
317
+ };
318
+ var API_NAME = "diag";
319
+ var DiagAPI = (
320
+ /** @class */
321
+ function() {
322
+ function DiagAPI2() {
323
+ function _logProxy(funcName) {
324
+ return function() {
325
+ var args = [];
326
+ for (var _i = 0; _i < arguments.length; _i++) {
327
+ args[_i] = arguments[_i];
399
328
  }
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;
329
+ var logger = getGlobal("diag");
330
+ if (!logger)
331
+ return;
332
+ return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
450
333
  };
451
334
  }
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
- };
335
+ var self = this;
336
+ var setLogger = function(logger, optionsOrLogLevel) {
337
+ var _a, _b, _c;
338
+ if (optionsOrLogLevel === void 0) {
339
+ optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
488
340
  }
489
- for (var i = 0; i < consoleMap.length; i++) {
490
- this[consoleMap[i].n] = _consoleFunc(consoleMap[i].c);
341
+ if (logger === self) {
342
+ var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
343
+ self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
344
+ return false;
491
345
  }
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
- }
346
+ if (typeof optionsOrLogLevel === "number") {
347
+ optionsOrLogLevel = {
348
+ logLevel: optionsOrLogLevel
349
+ };
532
350
  }
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];
351
+ var oldLogger = getGlobal("diag");
352
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
353
+ if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
354
+ var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
355
+ oldLogger.warn("Current logger will be overwritten from " + stack);
356
+ newLogger.warn("Current logger will overwrite one already registered from " + stack);
546
357
  }
547
- return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
548
- };
549
- NoopContextManager2.prototype.bind = function(_context, target) {
550
- return target;
358
+ return registerGlobal("diag", newLogger, self, true);
551
359
  };
552
- NoopContextManager2.prototype.enable = function() {
553
- return this;
360
+ self.setLogger = setLogger;
361
+ self.disable = function() {
362
+ unregisterGlobal(API_NAME, self);
554
363
  };
555
- NoopContextManager2.prototype.disable = function() {
556
- return this;
364
+ self.createComponentLogger = function(options) {
365
+ return new DiagComponentLogger(options);
557
366
  };
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
- }
367
+ self.verbose = _logProxy("verbose");
368
+ self.debug = _logProxy("debug");
369
+ self.info = _logProxy("info");
370
+ self.warn = _logProxy("warn");
371
+ self.error = _logProxy("error");
372
+ }
373
+ DiagAPI2.instance = function() {
374
+ if (!this._instance) {
375
+ this._instance = new DiagAPI2();
588
376
  }
589
- return ar;
377
+ return this._instance;
590
378
  };
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 = {}));
379
+ return DiagAPI2;
380
+ }()
381
+ );
759
382
 
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"
383
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/diag/consoleLogger.js
384
+ var consoleMap = [
385
+ { n: "error", c: "error" },
386
+ { n: "warn", c: "warn" },
387
+ { n: "info", c: "info" },
388
+ { n: "debug", c: "debug" },
389
+ { n: "verbose", c: "trace" }
797
390
  ];
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);
391
+ var DiagConsoleLogger = (
392
+ /** @class */
393
+ /* @__PURE__ */ function() {
394
+ function DiagConsoleLogger2() {
395
+ function _consoleFunc(funcName) {
396
+ return function() {
397
+ var args = [];
398
+ for (var _i = 0; _i < arguments.length; _i++) {
399
+ args[_i] = arguments[_i];
959
400
  }
960
- }
401
+ if (console) {
402
+ var theFunc = console[funcName];
403
+ if (typeof theFunc !== "function") {
404
+ theFunc = console.log;
405
+ }
406
+ if (typeof theFunc === "function") {
407
+ return theFunc.apply(console, args);
408
+ }
409
+ }
410
+ };
411
+ }
412
+ for (var i = 0; i < consoleMap.length; i++) {
413
+ this[consoleMap[i].n] = _consoleFunc(consoleMap[i].c);
414
+ }
961
415
  }
962
- }
963
- return environment;
964
- }
416
+ return DiagConsoleLogger2;
417
+ }()
418
+ );
965
419
 
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
- }
420
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.4.1/node_modules/@opentelemetry/api/build/esm/diag-api.js
421
+ var diag = DiagAPI.instance();
971
422
 
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";
423
+ // src/tracing.ts
424
+ var import_instrumentation_express = require("@opentelemetry/instrumentation-express");
425
+ var import_instrumentation_http = require("@opentelemetry/instrumentation-http");
426
+ var import_instrumentation_knex = require("@opentelemetry/instrumentation-knex");
427
+ var import_instrumentation_mysql2 = require("@opentelemetry/instrumentation-mysql2");
428
+ var import_instrumentation_net = require("@opentelemetry/instrumentation-net");
429
+ var import_exporter_trace_otlp_grpc = require("@opentelemetry/exporter-trace-otlp-grpc");
430
+ var import_instrumentation = require("@prisma/instrumentation");
431
+ var import_resources = require("@opentelemetry/resources");
974
432
 
975
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.23.0/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js
433
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.24.0/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js
976
434
  // @__NO_SIDE_EFFECTS__
977
435
  function createConstMap(values) {
978
436
  var res = {};
@@ -986,7 +444,7 @@ function createConstMap(values) {
986
444
  return res;
987
445
  }
988
446
 
989
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.23.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
447
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.24.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
990
448
  var TMP_CLOUD_PROVIDER = "cloud.provider";
991
449
  var TMP_CLOUD_ACCOUNT_ID = "cloud.account.id";
992
450
  var TMP_CLOUD_REGION = "cloud.region";
@@ -1151,590 +609,19 @@ var SemanticResourceAttributes = /* @__PURE__ */ createConstMap([
1151
609
  TMP_WEBENGINE_VERSION,
1152
610
  TMP_WEBENGINE_DESCRIPTION
1153
611
  ]);
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
612
 
1727
613
  // 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
614
  var import_sdk_trace_node = require("@opentelemetry/sdk-trace-node");
1737
615
  var import_ExpressLayerType = require("@opentelemetry/instrumentation-express/build/src/enums/ExpressLayerType");
616
+ var AdditionalInstrumentation = /* @__PURE__ */ ((AdditionalInstrumentation2) => {
617
+ AdditionalInstrumentation2["KNEX"] = "KNEX";
618
+ AdditionalInstrumentation2["PRISMA"] = "PRISMA";
619
+ return AdditionalInstrumentation2;
620
+ })(AdditionalInstrumentation || {});
621
+ var additionalInstrumentationConstructors = {
622
+ KNEX: import_instrumentation_knex.KnexInstrumentation,
623
+ PRISMA: import_instrumentation.PrismaInstrumentation
624
+ };
1738
625
  var tracingDefaults = {
1739
626
  serviceName: "unknown",
1740
627
  release: "unknown",
@@ -1748,8 +635,8 @@ var tracingDefaults = {
1748
635
  async function nodeSDKBuilder(config) {
1749
636
  config = { ...tracingDefaults, ...config };
1750
637
  diag.setLogger(config.logger, DiagLogLevel.WARN);
1751
- const _resource = Resource.default().merge(
1752
- new Resource({
638
+ const _resource = import_resources.Resource.default().merge(
639
+ new import_resources.Resource({
1753
640
  [SemanticResourceAttributes.SERVICE_NAME]: config.serviceName,
1754
641
  [SemanticResourceAttributes.SERVICE_VERSION]: config.release
1755
642
  })
@@ -1758,35 +645,40 @@ async function nodeSDKBuilder(config) {
1758
645
  //collector url
1759
646
  url: `http://${config.host}:${config.grpcDefaultPort}`
1760
647
  });
1761
- const _spanProcessor = new BatchSpanProcessor(_traceExporter, {
648
+ const _spanProcessor = new import_sdk_trace_base.BatchSpanProcessor(_traceExporter, {
1762
649
  // only force 100ms between 2 batch exports.
1763
650
  // Default is 5000ms which is 5 seconds and causes us to lose spans
1764
651
  scheduledDelayMillis: 100
1765
652
  });
1766
653
  const _idGenerator = new import_id_generator_aws_xray.AWSXRayIdGenerator();
654
+ let instrumentations = [
655
+ new import_instrumentation_aws_sdk.AwsInstrumentation({
656
+ suppressInternalInstrumentation: true
657
+ }),
658
+ new import_instrumentation_dataloader.DataloaderInstrumentation({}),
659
+ new import_instrumentation_express.ExpressInstrumentation({
660
+ ignoreLayersType: [import_ExpressLayerType.ExpressLayerType.MIDDLEWARE]
661
+ }),
662
+ new import_instrumentation_graphql.GraphQLInstrumentation({
663
+ // optional params
664
+ depth: config.graphQLDepth,
665
+ //query depth
666
+ allowValues: true
667
+ }),
668
+ new import_instrumentation_http.HttpInstrumentation({
669
+ ignoreIncomingPaths: ["/.well-known/apollo/server-health"]
670
+ }),
671
+ new import_instrumentation_mysql2.MySQL2Instrumentation({}),
672
+ new import_instrumentation_net.NetInstrumentation({})
673
+ ];
674
+ config.additionalInstrumentations.forEach((instrumentation) => {
675
+ instrumentations.push(
676
+ new additionalInstrumentationConstructors[instrumentation]()
677
+ );
678
+ });
1767
679
  const sdk = new import_sdk_node.NodeSDK({
1768
680
  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
- ],
681
+ instrumentations,
1790
682
  resource: _resource,
1791
683
  spanProcessor: _spanProcessor,
1792
684
  traceExporter: _traceExporter,
@@ -1805,5 +697,6 @@ async function nodeSDKBuilder(config) {
1805
697
  }
1806
698
  // Annotate the CommonJS export names for ESM import in node:
1807
699
  0 && (module.exports = {
700
+ AdditionalInstrumentation,
1808
701
  nodeSDKBuilder
1809
702
  });