netra-sdk 1.12.1 → 1.12.2

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
@@ -19,35 +19,95 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
19
19
  throw Error('Dynamic require of "' + x + '" is not supported');
20
20
  });
21
21
 
22
- // src/logger.ts
22
+ // src/netraLogger.ts
23
23
  var PREFIX = "[Netra]";
24
- var Logger = class {
24
+ var NetraLogger = class {
25
+ /**
26
+ * Turn debug output on or off for every module. Called once by Netra.init().
27
+ *
28
+ * @param enabled - `true` to print debug/info/warn/error/log output.
29
+ * @returns Nothing.
30
+ */
25
31
  static setDebugMode(enabled) {
26
32
  this._debugMode = enabled;
27
33
  }
28
- static get isDebug() {
29
- return this._debugMode || ["1", "true"].includes((process.env.NETRA_DEBUG ?? "").toLowerCase());
30
- }
34
+ /**
35
+ * Whether level methods currently print.
36
+ *
37
+ * `NETRA_DEBUG` is read on every call, so setting it at runtime takes effect
38
+ * immediately.
39
+ *
40
+ * @returns `true` if `setDebugMode(true)` was called or `NETRA_DEBUG` is "1"
41
+ * or "true" (any case); otherwise `false`.
42
+ */
31
43
  static isDebugMode() {
32
- return this.isDebug;
44
+ return this._debugMode || ["1", "true"].includes((process.env.NETRA_DEBUG ?? "").toLowerCase());
33
45
  }
46
+ /**
47
+ * Print through console.debug, in debug mode only.
48
+ *
49
+ * @param args - Values to print after the "[Netra]" prefix, as console.debug would.
50
+ * @returns Nothing.
51
+ */
34
52
  static debug(...args) {
35
- if (this.isDebug) console.debug(PREFIX, ...args);
53
+ if (this.isDebugMode()) console.debug(PREFIX, ...args);
36
54
  }
55
+ /**
56
+ * Print through console.info, in debug mode only.
57
+ *
58
+ * @param args - Values to print after the "[Netra]" prefix, as console.info would.
59
+ * @returns Nothing.
60
+ */
37
61
  static info(...args) {
38
- if (this.isDebug) console.info(PREFIX, ...args);
62
+ if (this.isDebugMode()) console.info(PREFIX, ...args);
39
63
  }
64
+ /**
65
+ * Print through console.warn, in debug mode only.
66
+ *
67
+ * @param args - Values to print after the "[Netra]" prefix, as console.warn would.
68
+ * @returns Nothing.
69
+ */
40
70
  static warn(...args) {
41
- if (this.isDebug) console.warn(PREFIX, ...args);
71
+ if (this.isDebugMode()) console.warn(PREFIX, ...args);
42
72
  }
73
+ /**
74
+ * Print through console.error, in debug mode only. For a failure the
75
+ * developer must see regardless of debug mode, use `notice("error", ...)`.
76
+ *
77
+ * @param args - Values to print after the "[Netra]" prefix, as console.error would.
78
+ * @returns Nothing.
79
+ */
43
80
  static error(...args) {
44
- console.error(PREFIX, ...args);
81
+ if (this.isDebugMode()) console.error(PREFIX, ...args);
45
82
  }
83
+ /**
84
+ * Print through console.log, in debug mode only.
85
+ *
86
+ * @param args - Values to print after the "[Netra]" prefix, as console.log would.
87
+ * @returns Nothing.
88
+ */
46
89
  static log(...args) {
47
- if (this.isDebug) console.log(PREFIX, ...args);
90
+ if (this.isDebugMode()) console.log(PREFIX, ...args);
91
+ }
92
+ /**
93
+ * Report a problem the developer has to fix. Printed whether or not debug
94
+ * mode is on; repeats are not collapsed.
95
+ *
96
+ * @param level - "warn" (console.warn) for something to fix, "error"
97
+ * (console.error) for a failure such as a rejected API call.
98
+ * @param args - Values to print after the "[Netra]" prefix. Errors and
99
+ * objects are passed to the console as-is, not stringified.
100
+ * @returns Nothing.
101
+ */
102
+ static notice(level, ...args) {
103
+ if (level === "error") {
104
+ console.error(PREFIX, ...args);
105
+ return;
106
+ }
107
+ console.warn(PREFIX, ...args);
48
108
  }
49
109
  };
50
- Logger._debugMode = false;
110
+ NetraLogger._debugMode = false;
51
111
 
52
112
  // src/utils/api-path.ts
53
113
  function apiPath(strings, ...values) {
@@ -66,7 +126,7 @@ function injectTraceContextHeaders(headers) {
66
126
  try {
67
127
  propagation.inject(context.active(), carrier);
68
128
  } catch {
69
- Logger.warn("netra: Failed to inject trace context headers");
129
+ NetraLogger.warn("netra: Failed to inject trace context headers");
70
130
  return headers;
71
131
  }
72
132
  return carrier;
@@ -99,7 +159,7 @@ var NetraHttpClient = class {
99
159
  this.initialized = false;
100
160
  const endpoint = config.otlpEndpoint?.trim() || "";
101
161
  if (!endpoint) {
102
- Logger.error(
162
+ NetraLogger.debug(
103
163
  "netra: NETRA_OTLP_ENDPOINT is required for API calls"
104
164
  );
105
165
  this.baseUrl = "";
@@ -134,7 +194,8 @@ var NetraHttpClient = class {
134
194
  }
135
195
  const parsed = parseFloat(envValue);
136
196
  if (isNaN(parsed)) {
137
- Logger.warn(
197
+ NetraLogger.notice(
198
+ "warn",
138
199
  `netra: Invalid ${envVar} value '${envValue}', using default ${defaultValue}`
139
200
  );
140
201
  return defaultValue;
@@ -153,13 +214,13 @@ var NetraHttpClient = class {
153
214
  try {
154
215
  return apiPath(strings, ...values);
155
216
  } catch (error) {
156
- Logger.error(`netra: ${error instanceof Error ? error.message : error}`);
217
+ NetraLogger.notice("error", `netra: ${error instanceof Error ? error.message : error}`);
157
218
  return null;
158
219
  }
159
220
  }
160
221
  async get(path, params) {
161
222
  if (!this.initialized) {
162
- Logger.error("netra: HTTP client is not initialized");
223
+ NetraLogger.notice("error", "netra: HTTP client is not initialized");
163
224
  return { data: {}, status: 0, ok: false };
164
225
  }
165
226
  if (path === null) {
@@ -192,13 +253,13 @@ var NetraHttpClient = class {
192
253
  ok: response.ok
193
254
  };
194
255
  } catch (error) {
195
- Logger.error(`netra: GET ${path} failed:`, error);
256
+ NetraLogger.notice("error", `netra: GET ${path} failed:`, error);
196
257
  return { data: {}, status: 0, ok: false };
197
258
  }
198
259
  }
199
260
  async post(path, body) {
200
261
  if (!this.initialized) {
201
- Logger.error("netra: HTTP client is not initialized");
262
+ NetraLogger.notice("error", "netra: HTTP client is not initialized");
202
263
  return { data: {}, status: 0, ok: false };
203
264
  }
204
265
  if (path === null) {
@@ -225,7 +286,7 @@ var NetraHttpClient = class {
225
286
  ok: response.ok
226
287
  };
227
288
  } catch (error) {
228
- Logger.error(`netra: POST ${path} failed:`, error);
289
+ NetraLogger.notice("error", `netra: POST ${path} failed:`, error);
229
290
  return { data: {}, status: 0, ok: false };
230
291
  }
231
292
  }
@@ -252,7 +313,8 @@ var UsageHttpClient = class extends NetraHttpClient {
252
313
  }
253
314
  async getSessionUsage(sessionId, startTime, endTime) {
254
315
  if (!this.isInitialized()) {
255
- Logger.error(
316
+ NetraLogger.notice(
317
+ "error",
256
318
  `netra.usage: Usage client is not initialized; cannot fetch session usage '${sessionId}'`
257
319
  );
258
320
  return {};
@@ -265,7 +327,8 @@ var UsageHttpClient = class extends NetraHttpClient {
265
327
  }
266
328
  async getTenantUsage(tenantId, startTime, endTime) {
267
329
  if (!this.isInitialized()) {
268
- Logger.error(
330
+ NetraLogger.notice(
331
+ "error",
269
332
  `netra.usage: Usage client is not initialized; cannot fetch tenant usage '${tenantId}'`
270
333
  );
271
334
  return {};
@@ -278,7 +341,7 @@ var UsageHttpClient = class extends NetraHttpClient {
278
341
  }
279
342
  async listTraces(params) {
280
343
  if (!this.isInitialized()) {
281
- Logger.error("netra.usage: Usage client is not initialized; cannot list traces");
344
+ NetraLogger.notice("error", "netra.usage: Usage client is not initialized; cannot list traces");
282
345
  return {};
283
346
  }
284
347
  const payload = {};
@@ -316,7 +379,8 @@ var UsageHttpClient = class extends NetraHttpClient {
316
379
  }
317
380
  async listSpansByTraceId(params) {
318
381
  if (!this.isInitialized()) {
319
- Logger.error(
382
+ NetraLogger.notice(
383
+ "error",
320
384
  `netra.usage: Usage client is not initialized; cannot list spans for trace '${params.traceId}'`
321
385
  );
322
386
  return {};
@@ -349,11 +413,12 @@ var Usage = class {
349
413
  */
350
414
  async getSessionUsage(sessionId, startTime, endTime) {
351
415
  if (!sessionId) {
352
- Logger.error("netra.usage: session_id is required to fetch session usage");
416
+ NetraLogger.notice("error", "netra.usage: session_id is required to fetch session usage");
353
417
  return null;
354
418
  }
355
419
  if (!startTime || !endTime) {
356
- Logger.error(
420
+ NetraLogger.notice(
421
+ "error",
357
422
  "netra.usage: start_time and end_time are required to fetch session usage"
358
423
  );
359
424
  return null;
@@ -379,11 +444,12 @@ var Usage = class {
379
444
  */
380
445
  async getTenantUsage(tenantId, startTime, endTime) {
381
446
  if (!tenantId) {
382
- Logger.error("netra.usage: tenant_id is required to fetch tenant usage");
447
+ NetraLogger.notice("error", "netra.usage: tenant_id is required to fetch tenant usage");
383
448
  return null;
384
449
  }
385
450
  if (!startTime || !endTime) {
386
- Logger.error(
451
+ NetraLogger.notice(
452
+ "error",
387
453
  "netra.usage: start_time and end_time are required to fetch tenant usage"
388
454
  );
389
455
  return null;
@@ -409,7 +475,7 @@ var Usage = class {
409
475
  */
410
476
  async listTraces(params) {
411
477
  if (!params.startTime || !params.endTime) {
412
- Logger.error("netra.usage: start_time and end_time are required to list traces");
478
+ NetraLogger.notice("error", "netra.usage: start_time and end_time are required to list traces");
413
479
  return null;
414
480
  }
415
481
  const result = await this.client.listTraces({
@@ -453,7 +519,7 @@ var Usage = class {
453
519
  */
454
520
  async listSpansByTraceId(params) {
455
521
  if (!params.traceId) {
456
- Logger.error("netra.usage: trace_id is required to list spans");
522
+ NetraLogger.notice("error", "netra.usage: trace_id is required to list spans");
457
523
  return null;
458
524
  }
459
525
  const result = await this.client.listSpansByTraceId({
@@ -491,7 +557,7 @@ var Usage = class {
491
557
  */
492
558
  async *iterTraces(params) {
493
559
  if (!params.startTime || !params.endTime) {
494
- Logger.error("netra.usage: start_time and end_time are required to iterate traces");
560
+ NetraLogger.notice("error", "netra.usage: start_time and end_time are required to iterate traces");
495
561
  return;
496
562
  }
497
563
  let currentCursor = params.cursor;
@@ -519,7 +585,7 @@ var Usage = class {
519
585
  */
520
586
  async *iterSpansByTraceId(params) {
521
587
  if (!params.traceId) {
522
- Logger.error("netra.usage: trace_id is required to iterate spans");
588
+ NetraLogger.notice("error", "netra.usage: trace_id is required to iterate spans");
523
589
  return;
524
590
  }
525
591
  let currentCursor = params.cursor;
@@ -617,9 +683,10 @@ var Usage = class {
617
683
  };
618
684
 
619
685
  // src/version.ts
620
- var SDK_VERSION = "1.12.1";
686
+ var SDK_VERSION = "1.12.2";
621
687
 
622
688
  // src/config.ts
689
+ var NETRA_API_KEY_HEADER = "x-api-key";
623
690
  var NetraInstruments = /* @__PURE__ */ ((NetraInstruments2) => {
624
691
  NetraInstruments2["ALL"] = "__all__";
625
692
  NetraInstruments2["OPENAI"] = "openai";
@@ -751,13 +818,25 @@ var _Config = class _Config {
751
818
  }
752
819
  return result;
753
820
  }
821
+ /**
822
+ * Warn when a Netra endpoint has no API key. The key counts as present when
823
+ * it is set via NETRA_API_KEY or already passed as an `x-api-key` header
824
+ * (through `headers` or NETRA_HEADERS); header names match case-insensitively.
825
+ */
754
826
  _validateApiKey() {
755
- if (this.otlpEndpoint && this.otlpEndpoint.toLowerCase().includes("getnetra") && !this.apiKey) {
756
- Logger.error(
757
- "Error: Missing Netra API key, go to netra dashboard to create one"
758
- );
759
- Logger.error("Set the NETRA_API_KEY environment variable to the key");
827
+ if (!this.otlpEndpoint || !this.otlpEndpoint.toLowerCase().includes("getnetra") || this.apiKey) {
828
+ return;
760
829
  }
830
+ const hasApiKeyHeader = Object.keys(this.headers).some(
831
+ (name) => name.toLowerCase() === NETRA_API_KEY_HEADER
832
+ );
833
+ if (hasApiKeyHeader) {
834
+ return;
835
+ }
836
+ NetraLogger.notice(
837
+ "error",
838
+ "NETRA_API_KEY is not set, so Netra will reject the traces this app sends. Fix: create an API key in the Netra dashboard and set NETRA_API_KEY to it."
839
+ );
761
840
  }
762
841
  _setupAuthentication() {
763
842
  if (!this.apiKey || !this.otlpEndpoint) {
@@ -791,7 +870,7 @@ var _Config = class _Config {
791
870
  try {
792
871
  return JSON.parse(envRa);
793
872
  } catch (e) {
794
- Logger.warn(`Failed to parse NETRA_RESOURCE_ATTRS: ${e}`);
873
+ NetraLogger.notice("warn", `Failed to parse NETRA_RESOURCE_ATTRS: ${e}`);
795
874
  return {};
796
875
  }
797
876
  }
@@ -984,7 +1063,7 @@ var _LocalFilteringSpanProcessor = class _LocalFilteringSpanProcessor {
984
1063
  this.evictIfNeeded();
985
1064
  }
986
1065
  } catch (e) {
987
- Logger.debug("LocalFilteringSpanProcessor.onStart error:", e);
1066
+ NetraLogger.debug("LocalFilteringSpanProcessor.onStart error:", e);
988
1067
  }
989
1068
  }
990
1069
  onEnd(_span) {
@@ -1047,22 +1126,22 @@ var _RootSpanProcessor = class _RootSpanProcessor {
1047
1126
  try {
1048
1127
  const active = trace.getActiveSpan();
1049
1128
  if (!active) {
1050
- Logger.warn(`setAttributeOnRootSpan: no active span`);
1129
+ NetraLogger.warn(`setAttributeOnRootSpan: no active span`);
1051
1130
  return;
1052
1131
  }
1053
1132
  const spanCtx = active.spanContext();
1054
1133
  if (!trace.isSpanContextValid(spanCtx)) {
1055
- Logger.warn(`setAttributeOnRootSpan: active span context is invalid`);
1134
+ NetraLogger.warn(`setAttributeOnRootSpan: active span context is invalid`);
1056
1135
  return;
1057
1136
  }
1058
1137
  const root = _RootSpanProcessor._rootSpans.get(spanCtx.traceId);
1059
1138
  if (!root) {
1060
- Logger.warn(`setAttributeOnRootSpan: no root span found for current trace`);
1139
+ NetraLogger.warn(`setAttributeOnRootSpan: no root span found for current trace`);
1061
1140
  return;
1062
1141
  }
1063
1142
  root.setAttribute(key, value);
1064
1143
  } catch (e) {
1065
- Logger.error(`setAttributeOnRootSpan: failed to set '${key}':`, e);
1144
+ NetraLogger.error(`setAttributeOnRootSpan: failed to set '${key}':`, e);
1066
1145
  }
1067
1146
  }
1068
1147
  onStart(span2, parentContext) {
@@ -1074,7 +1153,7 @@ var _RootSpanProcessor = class _RootSpanProcessor {
1074
1153
  _RootSpanProcessor._rootSpans.set(ctx.traceId, span2);
1075
1154
  }
1076
1155
  } catch (e) {
1077
- Logger.warn("RootSpanProcessor.onStart: unexpected error:", e);
1156
+ NetraLogger.warn("RootSpanProcessor.onStart: unexpected error:", e);
1078
1157
  }
1079
1158
  }
1080
1159
  onEnd(span2) {
@@ -1086,7 +1165,7 @@ var _RootSpanProcessor = class _RootSpanProcessor {
1086
1165
  _RootSpanProcessor._rootSpans.delete(ctx.traceId);
1087
1166
  }
1088
1167
  } catch (e) {
1089
- Logger.warn("RootSpanProcessor.onEnd: unexpected error:", e);
1168
+ NetraLogger.warn("RootSpanProcessor.onEnd: unexpected error:", e);
1090
1169
  }
1091
1170
  }
1092
1171
  shutdown() {
@@ -1197,7 +1276,7 @@ function tryRepairAndFit(json, cutLen, budget) {
1197
1276
  const result = JSON.stringify(parsed);
1198
1277
  if (result.length <= budget) return result;
1199
1278
  } catch {
1200
- Logger.debug("Failed to repair and fit JSON at cut length", {
1279
+ NetraLogger.debug("Failed to repair and fit JSON at cut length", {
1201
1280
  length: json.length,
1202
1281
  cutLength: cutLen
1203
1282
  });
@@ -1321,7 +1400,7 @@ var SessionManager = class _SessionManager {
1321
1400
  stack.push(span2);
1322
1401
  ctx.spansByName.set(name, stack);
1323
1402
  } catch (e) {
1324
- Logger.error(`Failed to register span '${name}':`, e);
1403
+ NetraLogger.error(`Failed to register span '${name}':`, e);
1325
1404
  }
1326
1405
  }
1327
1406
  static unregisterSpan(name, span2) {
@@ -1337,7 +1416,7 @@ var SessionManager = class _SessionManager {
1337
1416
  }
1338
1417
  if (stack.length === 0) ctx.spansByName.delete(name);
1339
1418
  } catch (e) {
1340
- Logger.error(`Failed to unregister span '${name}':`, e);
1419
+ NetraLogger.error(`Failed to unregister span '${name}':`, e);
1341
1420
  }
1342
1421
  }
1343
1422
  static getSpanByName(name) {
@@ -1413,10 +1492,10 @@ var SessionManager = class _SessionManager {
1413
1492
  if (span2?.isRecording()) {
1414
1493
  span2.setAttribute(key, typeof value === "string" ? value : safeStringify(value));
1415
1494
  } else {
1416
- Logger.warn(`setAttributeOnActiveSpan: no recording span for key '${key}'`);
1495
+ NetraLogger.warn(`setAttributeOnActiveSpan: no recording span for key '${key}'`);
1417
1496
  }
1418
1497
  } catch (e) {
1419
- Logger.error(`Failed to set attribute '${key}' on active span:`, e);
1498
+ NetraLogger.error(`Failed to set attribute '${key}' on active span:`, e);
1420
1499
  }
1421
1500
  }
1422
1501
  /**
@@ -1431,7 +1510,7 @@ var SessionManager = class _SessionManager {
1431
1510
  safeStringify(value)
1432
1511
  );
1433
1512
  } catch (e) {
1434
- Logger.error("setInput failed:", e);
1513
+ NetraLogger.error("setInput failed:", e);
1435
1514
  }
1436
1515
  }
1437
1516
  /**
@@ -1446,7 +1525,7 @@ var SessionManager = class _SessionManager {
1446
1525
  safeStringify(value)
1447
1526
  );
1448
1527
  } catch (e) {
1449
- Logger.error("setOutput failed:", e);
1528
+ NetraLogger.error("setOutput failed:", e);
1450
1529
  }
1451
1530
  }
1452
1531
  /**
@@ -1461,7 +1540,7 @@ var SessionManager = class _SessionManager {
1461
1540
  safeStringify(value)
1462
1541
  );
1463
1542
  } catch (e) {
1464
- Logger.error("setRootInput failed:", e);
1543
+ NetraLogger.error("setRootInput failed:", e);
1465
1544
  }
1466
1545
  }
1467
1546
  /**
@@ -1476,7 +1555,7 @@ var SessionManager = class _SessionManager {
1476
1555
  safeStringify(value)
1477
1556
  );
1478
1557
  } catch (e) {
1479
- Logger.error("setRootOutput failed:", e);
1558
+ NetraLogger.error("setRootOutput failed:", e);
1480
1559
  }
1481
1560
  }
1482
1561
  // Events and conversations
@@ -1498,7 +1577,7 @@ var SessionManager = class _SessionManager {
1498
1577
  );
1499
1578
  }
1500
1579
  } catch (e) {
1501
- Logger.error(`setCustomEvent '${name}' failed:`, e);
1580
+ NetraLogger.error(`setCustomEvent '${name}' failed:`, e);
1502
1581
  }
1503
1582
  }
1504
1583
  /**
@@ -1511,13 +1590,13 @@ var SessionManager = class _SessionManager {
1511
1590
  */
1512
1591
  static addConversation(conversationType, role, content) {
1513
1592
  if (!role || !content) {
1514
- Logger.error("addConversation: role and content must be provided");
1593
+ NetraLogger.notice("error", "addConversation: role and content must be provided");
1515
1594
  return;
1516
1595
  }
1517
1596
  try {
1518
1597
  const span2 = trace.getActiveSpan();
1519
1598
  if (!span2?.isRecording()) {
1520
- Logger.warn("addConversation: no active recording span");
1599
+ NetraLogger.warn("addConversation: no active recording span");
1521
1600
  return;
1522
1601
  }
1523
1602
  let existing = [];
@@ -1532,7 +1611,7 @@ var SessionManager = class _SessionManager {
1532
1611
  }
1533
1612
  }
1534
1613
  } catch (e) {
1535
- Logger.warn("addConversation: failed to parse existing conversation, starting fresh:", e);
1614
+ NetraLogger.warn("addConversation: failed to parse existing conversation, starting fresh:", e);
1536
1615
  }
1537
1616
  existing.push({
1538
1617
  type: conversationType,
@@ -1543,7 +1622,7 @@ var SessionManager = class _SessionManager {
1543
1622
  const payload = JSON.stringify(existing);
1544
1623
  span2.setAttribute("conversation", payload);
1545
1624
  } catch (e) {
1546
- Logger.error("addConversation failed:", e);
1625
+ NetraLogger.error("addConversation failed:", e);
1547
1626
  }
1548
1627
  }
1549
1628
  };
@@ -1719,7 +1798,8 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1719
1798
  */
1720
1799
  async getDataset(datasetId) {
1721
1800
  if (!this.isInitialized()) {
1722
- Logger.error(
1801
+ NetraLogger.notice(
1802
+ "error",
1723
1803
  `netra.evaluation: Evaluation client is not initialized; cannot fetch dataset '${datasetId}'`
1724
1804
  );
1725
1805
  return [];
@@ -1732,7 +1812,8 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1732
1812
  */
1733
1813
  async createRun(name, datasetId, evaluatorsConfig) {
1734
1814
  if (!this.isInitialized()) {
1735
- Logger.error(
1815
+ NetraLogger.notice(
1816
+ "error",
1736
1817
  `netra.evaluation: Evaluation client is not initialized; cannot create run for dataset '${datasetId}'`
1737
1818
  );
1738
1819
  return { success: false };
@@ -1753,7 +1834,8 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1753
1834
  */
1754
1835
  async createDataset(name, tags) {
1755
1836
  if (!this.isInitialized()) {
1756
- Logger.error(
1837
+ NetraLogger.notice(
1838
+ "error",
1757
1839
  "netra.evaluation: Evaluation client is not initialized; cannot create dataset"
1758
1840
  );
1759
1841
  return { success: false };
@@ -1773,7 +1855,8 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1773
1855
  */
1774
1856
  async addDatasetItem(datasetId, itemPayload) {
1775
1857
  if (!this.isInitialized()) {
1776
- Logger.error(
1858
+ NetraLogger.notice(
1859
+ "error",
1777
1860
  `netra.evaluation: Evaluation client is not initialized; cannot add item to dataset '${datasetId}'`
1778
1861
  );
1779
1862
  return { success: false };
@@ -1794,7 +1877,8 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1794
1877
  */
1795
1878
  async getRunResults(runId) {
1796
1879
  if (!this.isInitialized()) {
1797
- Logger.error(
1880
+ NetraLogger.notice(
1881
+ "error",
1798
1882
  "netra.evaluation: Evaluation client is not initialized; cannot fetch run"
1799
1883
  );
1800
1884
  return { success: false };
@@ -1803,18 +1887,20 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1803
1887
  const response = await this.get(this.path`/evaluations/run/${runId}`);
1804
1888
  if (!response.ok) {
1805
1889
  const errorMessage = response.data?.error?.message ?? "Unknown error";
1806
- Logger.error(
1890
+ NetraLogger.notice(
1891
+ "error",
1807
1892
  `netra.evaluation: Failed to fetch run results for run '${runId}': ${errorMessage}`
1808
1893
  );
1809
1894
  return null;
1810
1895
  }
1811
1896
  const data = this.extractData(response, null);
1812
1897
  if (data !== null) {
1813
- Logger.info("netra.evaluation: Run fetched successfully");
1898
+ NetraLogger.info("netra.evaluation: Run fetched successfully");
1814
1899
  }
1815
1900
  return data;
1816
1901
  } catch {
1817
- Logger.error(
1902
+ NetraLogger.notice(
1903
+ "error",
1818
1904
  `netra.evaluation: Failed to fetch run results for run '${runId}'`
1819
1905
  );
1820
1906
  return null;
@@ -1825,7 +1911,8 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1825
1911
  */
1826
1912
  async postRunItem(runId, payload) {
1827
1913
  if (!this.isInitialized()) {
1828
- Logger.error(
1914
+ NetraLogger.notice(
1915
+ "error",
1829
1916
  "netra.evaluation: Evaluation client is not initialized; cannot post run item"
1830
1917
  );
1831
1918
  return { success: false };
@@ -1848,7 +1935,8 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1848
1935
  */
1849
1936
  async submitLocalEvaluations(runId, testRunItemId, evaluatorResults) {
1850
1937
  if (!this.isInitialized()) {
1851
- Logger.error(
1938
+ NetraLogger.notice(
1939
+ "error",
1852
1940
  "netra.evaluation: Evaluation client is not initialized; cannot submit local evaluations"
1853
1941
  );
1854
1942
  return { success: false };
@@ -1868,7 +1956,8 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1868
1956
  */
1869
1957
  async postRunStatus(runId, status) {
1870
1958
  if (!this.isInitialized()) {
1871
- Logger.error(
1959
+ NetraLogger.notice(
1960
+ "error",
1872
1961
  "netra.evaluation: Evaluation client is not initialized; cannot post run status"
1873
1962
  );
1874
1963
  return { success: false };
@@ -1883,7 +1972,7 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1883
1972
  }
1884
1973
  const data = this.extractData(response, { success: false });
1885
1974
  if (data && typeof data === "object") {
1886
- Logger.info("netra.evaluation: Completed test run successfully");
1975
+ NetraLogger.info("netra.evaluation: Completed test run successfully");
1887
1976
  }
1888
1977
  return data;
1889
1978
  }
@@ -1892,7 +1981,8 @@ var EvaluationHttpClient = class extends NetraHttpClient {
1892
1981
  */
1893
1982
  async getSpanById(spanId) {
1894
1983
  if (!this.isInitialized()) {
1895
- Logger.error(
1984
+ NetraLogger.notice(
1985
+ "error",
1896
1986
  "netra.evaluation: Evaluation client is not initialized; cannot get span"
1897
1987
  );
1898
1988
  return null;
@@ -2027,15 +2117,15 @@ function buildItemPayload(ctx, status, includeOutput = false) {
2027
2117
  }
2028
2118
  function validateRunInputs(name, data, task2) {
2029
2119
  if (!name) {
2030
- Logger.error("netra.evaluation: run name is required");
2120
+ NetraLogger.notice("error", "netra.evaluation: run name is required");
2031
2121
  return false;
2032
2122
  }
2033
2123
  if (!data) {
2034
- Logger.error("netra.evaluation: data is required");
2124
+ NetraLogger.notice("error", "netra.evaluation: data is required");
2035
2125
  return false;
2036
2126
  }
2037
2127
  if (task2 == null) {
2038
- Logger.error("netra.evaluation: task function is required");
2128
+ NetraLogger.notice("error", "netra.evaluation: task function is required");
2039
2129
  return false;
2040
2130
  }
2041
2131
  return true;
@@ -2082,7 +2172,8 @@ var Evaluation = class {
2082
2172
  */
2083
2173
  async createDataset(name, tags) {
2084
2174
  if (!name) {
2085
- Logger.error(
2175
+ NetraLogger.notice(
2176
+ "error",
2086
2177
  "netra.evaluation: Failed to create dataset: dataset name is required"
2087
2178
  );
2088
2179
  return null;
@@ -2112,7 +2203,8 @@ var Evaluation = class {
2112
2203
  */
2113
2204
  async addDatasetItem(datasetId, item) {
2114
2205
  if (!item.input) {
2115
- Logger.error(
2206
+ NetraLogger.notice(
2207
+ "error",
2116
2208
  "netra.evaluation: Skipping dataset item without required 'input'"
2117
2209
  );
2118
2210
  return null;
@@ -2144,7 +2236,8 @@ var Evaluation = class {
2144
2236
  */
2145
2237
  async getDataset(datasetId) {
2146
2238
  if (!datasetId) {
2147
- Logger.error(
2239
+ NetraLogger.notice(
2240
+ "error",
2148
2241
  "netra.evaluation: Failed to get dataset: dataset id is required"
2149
2242
  );
2150
2243
  return null;
@@ -2158,10 +2251,16 @@ var Evaluation = class {
2158
2251
  const itemId = item?.id;
2159
2252
  const itemInput = item?.input;
2160
2253
  const itemDatasetId = item?.datasetId;
2161
- if (itemId == null || itemDatasetId == null || itemInput == null) {
2162
- Logger.warn(
2163
- "netra.evaluation: Skipping dataset item with missing required fields:",
2164
- item
2254
+ const itemLabel = itemId ?? "(no id)";
2255
+ const missingFields = [
2256
+ ["id", itemId],
2257
+ ["datasetId", itemDatasetId],
2258
+ ["input", itemInput]
2259
+ ].filter(([, value]) => value == null).map(([fieldName]) => fieldName);
2260
+ if (missingFields.length > 0) {
2261
+ NetraLogger.notice(
2262
+ "warn",
2263
+ `netra.evaluation: Skipping dataset item ${itemLabel}: missing required field(s): ${missingFields.join(", ")}`
2165
2264
  );
2166
2265
  continue;
2167
2266
  }
@@ -2173,7 +2272,11 @@ var Evaluation = class {
2173
2272
  expectedOutput: item?.expectedOutput ?? ""
2174
2273
  });
2175
2274
  } catch (exc) {
2176
- Logger.error("netra.evaluation: Failed to parse dataset item:", exc);
2275
+ NetraLogger.notice(
2276
+ "error",
2277
+ `netra.evaluation: Skipping dataset item ${itemLabel}: failed to parse:`,
2278
+ exc
2279
+ );
2177
2280
  }
2178
2281
  }
2179
2282
  return { items: datasetItems };
@@ -2187,7 +2290,8 @@ var Evaluation = class {
2187
2290
  */
2188
2291
  async createRun(name, datasetId, evaluatorsConfig) {
2189
2292
  if (!name) {
2190
- Logger.error(
2293
+ NetraLogger.notice(
2294
+ "error",
2191
2295
  "netra.evaluation: Failed to create run: run name is required"
2192
2296
  );
2193
2297
  return null;
@@ -2212,7 +2316,8 @@ var Evaluation = class {
2212
2316
  */
2213
2317
  async getRunResults(runId) {
2214
2318
  if (!runId) {
2215
- Logger.error(
2319
+ NetraLogger.notice(
2320
+ "error",
2216
2321
  "netra.evaluation: Failed to get run: run_id is required"
2217
2322
  );
2218
2323
  return null;
@@ -2255,10 +2360,10 @@ var Evaluation = class {
2255
2360
  evaluatorsConfig
2256
2361
  );
2257
2362
  if (!runId) {
2258
- Logger.error("netra.evaluation: Failed to create run");
2363
+ NetraLogger.notice("error", "netra.evaluation: Failed to create run");
2259
2364
  return null;
2260
2365
  }
2261
- Logger.info("netra.evaluation: Initiated test run");
2366
+ NetraLogger.info("netra.evaluation: Initiated test run");
2262
2367
  const semaphore = new Semaphore(Math.max(1, maxConcurrency));
2263
2368
  const results = [];
2264
2369
  const bgEvalTasks = [];
@@ -2277,7 +2382,7 @@ var Evaluation = class {
2277
2382
  bgEvalTasks
2278
2383
  );
2279
2384
  completedItems += 1;
2280
- Logger.info(
2385
+ NetraLogger.info(
2281
2386
  `netra.evaluation: ${completedItems}/${totalItems} items processed (status=${itemResult.status})`
2282
2387
  );
2283
2388
  } finally {
@@ -2569,7 +2674,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2569
2674
  */
2570
2675
  async queryData(scope, chartType, metrics, filter, dimension) {
2571
2676
  if (!this.isInitialized()) {
2572
- Logger.error(
2677
+ NetraLogger.notice(
2678
+ "error",
2573
2679
  "netra.dashboard: Dashboard client is not initialized; cannot execute query"
2574
2680
  );
2575
2681
  return null;
@@ -2612,7 +2718,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2612
2718
  const response = await this.post("/public/dashboard/query-data", payload);
2613
2719
  if (!response.ok) {
2614
2720
  const errorMessage = response.data?.error?.message ?? "Unknown error";
2615
- Logger.error(
2721
+ NetraLogger.notice(
2722
+ "error",
2616
2723
  `netra.dashboard: Failed to execute dashboard query: ${errorMessage}`
2617
2724
  );
2618
2725
  return null;
@@ -2636,7 +2743,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2636
2743
  */
2637
2744
  async getSessionStats(startTime, endTime, filters, limit, cursor, sortField, sortOrder) {
2638
2745
  if (!this.isInitialized()) {
2639
- Logger.error(
2746
+ NetraLogger.notice(
2747
+ "error",
2640
2748
  "netra.dashboard: Dashboard client is not initialized; cannot get session stats"
2641
2749
  );
2642
2750
  return null;
@@ -2673,7 +2781,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2673
2781
  const response = await this.post(url, payload);
2674
2782
  if (!response.ok) {
2675
2783
  const errorMessage = response.data?.error?.message ?? "Unknown error";
2676
- Logger.error(
2784
+ NetraLogger.notice(
2785
+ "error",
2677
2786
  `netra.dashboard: Failed to execute dashboard query: ${errorMessage}`
2678
2787
  );
2679
2788
  return null;
@@ -2681,7 +2790,7 @@ var DashboardHttpClient = class extends NetraHttpClient {
2681
2790
  return response.data;
2682
2791
  } catch (err) {
2683
2792
  const message = err?.response?.data?.error?.message ?? "";
2684
- Logger.error("netra.dashboard: Failed to fetch session stats:", message);
2793
+ NetraLogger.notice("error", "netra.dashboard: Failed to fetch session stats:", message);
2685
2794
  return null;
2686
2795
  }
2687
2796
  }
@@ -2699,7 +2808,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2699
2808
  */
2700
2809
  async getSessionSummary(startTime, endTime, filters) {
2701
2810
  if (!this.isInitialized()) {
2702
- Logger.error(
2811
+ NetraLogger.notice(
2812
+ "error",
2703
2813
  "netra.dashboard: Dashboard client is not initialized; cannot execute query"
2704
2814
  );
2705
2815
  return null;
@@ -2723,7 +2833,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2723
2833
  const response = await this.post(url, payload);
2724
2834
  if (!response.ok) {
2725
2835
  const errorMessage = response.data?.error?.message ?? "Unknown error";
2726
- Logger.error(
2836
+ NetraLogger.notice(
2837
+ "error",
2727
2838
  `netra.dashboard: Failed to execute dashboard query: ${errorMessage}`
2728
2839
  );
2729
2840
  return null;
@@ -2731,7 +2842,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2731
2842
  return response.data;
2732
2843
  } catch (err) {
2733
2844
  const message = err?.response?.data?.error?.message ?? "";
2734
- Logger.error(
2845
+ NetraLogger.notice(
2846
+ "error",
2735
2847
  "netra.dashboard: Failed to fetch session summary:",
2736
2848
  message
2737
2849
  );
@@ -2749,7 +2861,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2749
2861
  */
2750
2862
  async getSessionDetails(sessionId) {
2751
2863
  if (!this.isInitialized()) {
2752
- Logger.error(
2864
+ NetraLogger.notice(
2865
+ "error",
2753
2866
  "netra.dashboard: Dashboard client is not initialized; cannot get session details"
2754
2867
  );
2755
2868
  return null;
@@ -2759,7 +2872,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2759
2872
  const response = await this.get(url);
2760
2873
  if (!response.ok) {
2761
2874
  const errorMessage = response.data?.error?.message ?? "Unknown error";
2762
- Logger.error(
2875
+ NetraLogger.notice(
2876
+ "error",
2763
2877
  `netra.dashboard: Failed to fetch session details: ${errorMessage}`
2764
2878
  );
2765
2879
  return null;
@@ -2767,7 +2881,8 @@ var DashboardHttpClient = class extends NetraHttpClient {
2767
2881
  return response.data;
2768
2882
  } catch (err) {
2769
2883
  const message = err?.response?.data?.error?.message ?? "";
2770
- Logger.error(
2884
+ NetraLogger.notice(
2885
+ "error",
2771
2886
  "netra.dashboard: Failed to fetch session details:",
2772
2887
  message
2773
2888
  );
@@ -2914,7 +3029,8 @@ var Dashboard = class {
2914
3029
  }
2915
3030
  async getSessionStats(startTime, endTime, limit = 10, filters, cursor, sortField, sortOrder) {
2916
3031
  if (!startTime || !endTime) {
2917
- Logger.error(
3032
+ NetraLogger.notice(
3033
+ "error",
2918
3034
  "netra.dashboard: start_time and end_time are required to fetch session stats"
2919
3035
  );
2920
3036
  return null;
@@ -2948,7 +3064,8 @@ var Dashboard = class {
2948
3064
  }
2949
3065
  async *iterSessionStats(startTime, endTime, filters, sortField, sortOrder) {
2950
3066
  if (!startTime || !endTime) {
2951
- Logger.error(
3067
+ NetraLogger.notice(
3068
+ "error",
2952
3069
  "netra.dashboard: start_time and end_time are required to iterate session stats"
2953
3070
  );
2954
3071
  return;
@@ -2978,11 +3095,12 @@ var Dashboard = class {
2978
3095
  }
2979
3096
  async getSessionSummary(filter) {
2980
3097
  if (!this.isSessionFilterConfig(filter)) {
2981
- Logger.error("netra.dashboard: filter must be a SessionFilterConfig");
3098
+ NetraLogger.notice("error", "netra.dashboard: filter must be a SessionFilterConfig");
2982
3099
  return null;
2983
3100
  }
2984
3101
  if (!filter.startTime || !filter.endTime) {
2985
- Logger.error(
3102
+ NetraLogger.notice(
3103
+ "error",
2986
3104
  "netra.dashboard: start_time and end_time are required to fetch session summary"
2987
3105
  );
2988
3106
  return null;
@@ -2999,7 +3117,8 @@ var Dashboard = class {
2999
3117
  }
3000
3118
  async getSessionDetails(sessionId) {
3001
3119
  if (!sessionId) {
3002
- Logger.error(
3120
+ NetraLogger.notice(
3121
+ "error",
3003
3122
  "netra.dashboard: session_id is required to fetch session details"
3004
3123
  );
3005
3124
  return null;
@@ -3070,7 +3189,8 @@ var PromptsHttpClient = class extends NetraHttpClient {
3070
3189
  */
3071
3190
  async getPromptVersion(name, label) {
3072
3191
  if (!this.isInitialized()) {
3073
- Logger.error(
3192
+ NetraLogger.notice(
3193
+ "error",
3074
3194
  "netra.prompts: Prompts client is not initialized; cannot fetch prompt"
3075
3195
  );
3076
3196
  return null;
@@ -3083,13 +3203,13 @@ var PromptsHttpClient = class extends NetraHttpClient {
3083
3203
  const response = await this.post("/sdk/prompts/version", payload);
3084
3204
  if (!response.ok) {
3085
3205
  const errorMessage = response.data?.error?.message ?? "Unknown error";
3086
- Logger.error(`netra.prompts: Failed to fetch prompt: ${errorMessage}`);
3206
+ NetraLogger.notice("error", `netra.prompts: Failed to fetch prompt: ${errorMessage}`);
3087
3207
  return null;
3088
3208
  }
3089
3209
  return response.data;
3090
3210
  } catch (err) {
3091
3211
  const message = err?.response?.data?.error?.message ?? "";
3092
- Logger.error("netra.prompts: Failed to fetch prompt:", message);
3212
+ NetraLogger.notice("error", "netra.prompts: Failed to fetch prompt:", message);
3093
3213
  return null;
3094
3214
  }
3095
3215
  }
@@ -3119,7 +3239,7 @@ var Prompts = class {
3119
3239
  */
3120
3240
  async getPrompt(params) {
3121
3241
  if (!params || typeof params.name !== "string" || !params.name) {
3122
- Logger.error("netra.prompts: name is required to fetch a prompt");
3242
+ NetraLogger.notice("error", "netra.prompts: name is required to fetch a prompt");
3123
3243
  return null;
3124
3244
  }
3125
3245
  const label = params.label ?? "production";
@@ -3150,7 +3270,8 @@ var ModelsHttpClient = class extends NetraHttpClient {
3150
3270
  }
3151
3271
  async getModelPricing(name) {
3152
3272
  if (!this.isInitialized()) {
3153
- Logger.error(
3273
+ NetraLogger.notice(
3274
+ "error",
3154
3275
  "netra.models: Models client is not initialized; cannot fetch model pricing"
3155
3276
  );
3156
3277
  return null;
@@ -3160,14 +3281,15 @@ var ModelsHttpClient = class extends NetraHttpClient {
3160
3281
  const response = await this.get("/sdk/models", params);
3161
3282
  if (!response.ok) {
3162
3283
  const errorMessage = response.data?.error?.message ?? "Unknown error";
3163
- Logger.error(
3284
+ NetraLogger.notice(
3285
+ "error",
3164
3286
  `netra.models: Failed to fetch model pricing: ${errorMessage}`
3165
3287
  );
3166
3288
  return null;
3167
3289
  }
3168
3290
  const items = this.extractData(response, null);
3169
3291
  if (items !== null && !Array.isArray(items)) {
3170
- Logger.error(
3292
+ NetraLogger.error(
3171
3293
  "netra.models: Unexpected response format; expected an array"
3172
3294
  );
3173
3295
  return null;
@@ -3175,7 +3297,7 @@ var ModelsHttpClient = class extends NetraHttpClient {
3175
3297
  return items;
3176
3298
  } catch (err) {
3177
3299
  const message = err?.response?.data?.error?.message ?? err?.message ?? "";
3178
- Logger.error("netra.models: Failed to fetch model pricing:", message);
3300
+ NetraLogger.notice("error", "netra.models: Failed to fetch model pricing:", message);
3179
3301
  return null;
3180
3302
  }
3181
3303
  }
@@ -3267,14 +3389,14 @@ var InstrumentationSpanProcessor = class {
3267
3389
  return base;
3268
3390
  }
3269
3391
  } catch {
3270
- Logger.debug("InstrumentationSpanProcessor: Error extracting base name:", name);
3392
+ NetraLogger.debug("InstrumentationSpanProcessor: Error extracting base name:", name);
3271
3393
  }
3272
3394
  }
3273
3395
  return name;
3274
3396
  }
3275
3397
  }
3276
3398
  } catch {
3277
- Logger.debug("InstrumentationSpanProcessor: Error detecting instrumentation name");
3399
+ NetraLogger.debug("InstrumentationSpanProcessor: Error detecting instrumentation name");
3278
3400
  }
3279
3401
  return null;
3280
3402
  }
@@ -3285,7 +3407,7 @@ var InstrumentationSpanProcessor = class {
3285
3407
  span2.setAttribute(`${Config.LIBRARY_NAME}.instrumentation.name`, name);
3286
3408
  }
3287
3409
  } catch (e) {
3288
- Logger.error(
3410
+ NetraLogger.error(
3289
3411
  "InstrumentationSpanProcessor: Error on span start:",
3290
3412
  e
3291
3413
  );
@@ -3326,7 +3448,7 @@ var _LlmTraceIdentifierSpanProcessor = class _LlmTraceIdentifierSpanProcessor {
3326
3448
  if (!this._isLlmSpan(span2)) return;
3327
3449
  this._markRootSpan(traceId);
3328
3450
  } catch (e) {
3329
- Logger.warn("LlmTraceIdentifierSpanProcessor: error in onEnd:", e);
3451
+ NetraLogger.warn("LlmTraceIdentifierSpanProcessor: error in onEnd:", e);
3330
3452
  }
3331
3453
  }
3332
3454
  shutdown() {
@@ -3346,13 +3468,13 @@ var _LlmTraceIdentifierSpanProcessor = class _LlmTraceIdentifierSpanProcessor {
3346
3468
  this._markedTraces.add(traceId);
3347
3469
  if (!root) return;
3348
3470
  if (!root.isRecording()) {
3349
- Logger.warn(`LlmTraceIdentifierSpanProcessor: root span for trace ${traceId} is not recording`);
3471
+ NetraLogger.warn(`LlmTraceIdentifierSpanProcessor: root span for trace ${traceId} is not recording`);
3350
3472
  return;
3351
3473
  }
3352
3474
  try {
3353
3475
  root.setAttribute(this._rootMarkerKey, true);
3354
3476
  } catch (e) {
3355
- Logger.warn(`LlmTraceIdentifierSpanProcessor: failed to mark root span for trace ${traceId}:`, e);
3477
+ NetraLogger.warn(`LlmTraceIdentifierSpanProcessor: failed to mark root span for trace ${traceId}:`, e);
3356
3478
  }
3357
3479
  }
3358
3480
  };
@@ -3464,7 +3586,7 @@ var ScrubbingSpanProcessor = class {
3464
3586
  try {
3465
3587
  this.wrapSetAttribute(span2);
3466
3588
  } catch (e) {
3467
- Logger.error("ScrubbingSpanProcessor.onStart error:", e);
3589
+ NetraLogger.error("ScrubbingSpanProcessor.onStart error:", e);
3468
3590
  }
3469
3591
  }
3470
3592
  onEnd(_span) {
@@ -3501,7 +3623,7 @@ var SerializationSpanProcessor = class {
3501
3623
  try {
3502
3624
  this.wrapSetAttribute(span2);
3503
3625
  } catch (e) {
3504
- Logger.debug("SerializationSpanProcessor.onStart error:", e);
3626
+ NetraLogger.debug("SerializationSpanProcessor.onStart error:", e);
3505
3627
  }
3506
3628
  }
3507
3629
  onEnd(_span) {
@@ -3564,7 +3686,7 @@ function safeEnterWith(newContext) {
3564
3686
  contextManager.enterWith(newContext);
3565
3687
  return;
3566
3688
  }
3567
- Logger.warn("SessionSpanProcessor: enterWith not available on context manager; baggage will not propagate.");
3689
+ NetraLogger.warn("SessionSpanProcessor: enterWith not available on context manager; baggage will not propagate.");
3568
3690
  }
3569
3691
  var sessionValues = /* @__PURE__ */ new Map();
3570
3692
  function setSessionBaggage(key, value) {
@@ -3617,7 +3739,7 @@ var SessionSpanProcessor = class {
3617
3739
  span2.setAttribute(attrKey, attrValue);
3618
3740
  }
3619
3741
  } catch (e) {
3620
- Logger.error("SessionSpanProcessor: Error setting span attributes:", e);
3742
+ NetraLogger.error("SessionSpanProcessor: Error setting span attributes:", e);
3621
3743
  }
3622
3744
  }
3623
3745
  /**
@@ -3922,7 +4044,7 @@ var SpanIOProcessor = class {
3922
4044
  }
3923
4045
  this._wrapSetAttribute(span2);
3924
4046
  } catch (e) {
3925
- Logger.error("SpanIOProcessor.onStart failed:", e);
4047
+ NetraLogger.error("SpanIOProcessor.onStart failed:", e);
3926
4048
  }
3927
4049
  }
3928
4050
  onEnd(_span) {
@@ -4062,7 +4184,7 @@ var SpanIOProcessor = class {
4062
4184
  }
4063
4185
  return original(key, value);
4064
4186
  } catch (e) {
4065
- Logger.debug(`SpanIOProcessor: error processing key=${key}`, e);
4187
+ NetraLogger.debug(`SpanIOProcessor: error processing key=${key}`, e);
4066
4188
  try {
4067
4189
  return original(key, value);
4068
4190
  } catch {
@@ -4095,7 +4217,7 @@ function wrapAsyncIterable(source, callbacks) {
4095
4217
  try {
4096
4218
  callbacks.finalize(status);
4097
4219
  } catch (e) {
4098
- Logger.error("netra: finalize callback error", e);
4220
+ NetraLogger.error("netra: finalize callback error", e);
4099
4221
  }
4100
4222
  };
4101
4223
  return {
@@ -4106,7 +4228,7 @@ function wrapAsyncIterable(source, callbacks) {
4106
4228
  try {
4107
4229
  callbacks.onChunk?.(result.value);
4108
4230
  } catch (e) {
4109
- Logger.error("netra: onChunk callback error", e);
4231
+ NetraLogger.error("netra: onChunk callback error", e);
4110
4232
  }
4111
4233
  } else {
4112
4234
  safeFinalize("ok");
@@ -4116,7 +4238,7 @@ function wrapAsyncIterable(source, callbacks) {
4116
4238
  try {
4117
4239
  callbacks.onError(e);
4118
4240
  } catch {
4119
- Logger.error("netra: onError callback error", e);
4241
+ NetraLogger.error("netra: onError callback error", e);
4120
4242
  }
4121
4243
  safeFinalize("error");
4122
4244
  throw e;
@@ -4133,7 +4255,7 @@ function wrapAsyncIterable(source, callbacks) {
4133
4255
  try {
4134
4256
  callbacks.onError(e);
4135
4257
  } catch {
4136
- Logger.error("netra: onError callback error", e);
4258
+ NetraLogger.error("netra: onError callback error", e);
4137
4259
  }
4138
4260
  safeFinalize("error");
4139
4261
  throw e;
@@ -4151,7 +4273,7 @@ function wrapAsyncIterable(source, callbacks) {
4151
4273
  try {
4152
4274
  callbacks.onError(err);
4153
4275
  } catch {
4154
- Logger.error("netra: onError callback error", err);
4276
+ NetraLogger.error("netra: onError callback error", err);
4155
4277
  }
4156
4278
  safeFinalize("error");
4157
4279
  throw err;
@@ -4183,7 +4305,7 @@ function wrapPromise(promise, callbacks, options) {
4183
4305
  try {
4184
4306
  callbacks.finalize(status);
4185
4307
  } catch (e) {
4186
- Logger.error("netra: finalize callback error", e);
4308
+ NetraLogger.error("netra: finalize callback error", e);
4187
4309
  }
4188
4310
  }
4189
4311
  const instrumentedPromise = (async () => {
@@ -4195,7 +4317,7 @@ function wrapPromise(promise, callbacks, options) {
4195
4317
  try {
4196
4318
  callbacks.onSuccess?.(value);
4197
4319
  } catch (e) {
4198
- Logger.error("netra: onSuccess callback error", e);
4320
+ NetraLogger.error("netra: onSuccess callback error", e);
4199
4321
  }
4200
4322
  safeFinalize("ok");
4201
4323
  return value;
@@ -4203,7 +4325,7 @@ function wrapPromise(promise, callbacks, options) {
4203
4325
  try {
4204
4326
  callbacks.onError(error);
4205
4327
  } catch {
4206
- Logger.error("netra: onError callback error", error);
4328
+ NetraLogger.error("netra: onError callback error", error);
4207
4329
  }
4208
4330
  safeFinalize("error");
4209
4331
  throw error;
@@ -4242,12 +4364,12 @@ function wrapResponse(response, callbacks, options) {
4242
4364
  try {
4243
4365
  callbacks.onSuccess?.(response);
4244
4366
  } catch (e) {
4245
- Logger.error("netra: onSuccess callback error", e);
4367
+ NetraLogger.error("netra: onSuccess callback error", e);
4246
4368
  }
4247
4369
  try {
4248
4370
  callbacks.finalize("ok");
4249
4371
  } catch (e) {
4250
- Logger.error("netra: finalize callback error", e);
4372
+ NetraLogger.error("netra: finalize callback error", e);
4251
4373
  }
4252
4374
  return response;
4253
4375
  }
@@ -4533,7 +4655,7 @@ function writeCompletionAttributes(span2, messages) {
4533
4655
  );
4534
4656
  completionIdx++;
4535
4657
  } catch (error) {
4536
- Logger.error("Error parsing tool content:", error);
4658
+ NetraLogger.error("Error parsing tool content:", error);
4537
4659
  }
4538
4660
  } else {
4539
4661
  span2.setAttribute(
@@ -4751,7 +4873,7 @@ function processStreamChunk(completeResponse, chunk, span2) {
4751
4873
  try {
4752
4874
  finishedBlock.input = JSON.parse(finishedBlock.input);
4753
4875
  } catch {
4754
- Logger.warn(
4876
+ NetraLogger.warn(
4755
4877
  "netra.instrumentation.anthropic: Failed to parse tool use input"
4756
4878
  );
4757
4879
  }
@@ -4782,13 +4904,13 @@ function processStreamChunk(completeResponse, chunk, span2) {
4782
4904
  break;
4783
4905
  }
4784
4906
  }
4785
- if (Logger.isDebugMode()) {
4907
+ if (NetraLogger.isDebugMode()) {
4786
4908
  span2.addEvent("llm.content.completion.chunk", {
4787
4909
  "chunk.type": chunk.type
4788
4910
  });
4789
4911
  }
4790
4912
  } catch (e) {
4791
- Logger.error(
4913
+ NetraLogger.error(
4792
4914
  "netra.instrumentation.anthropic: processStreamChunk error",
4793
4915
  e
4794
4916
  );
@@ -4806,7 +4928,7 @@ function finalizeStreamSpan(span2, completeResponse, startTime, code) {
4806
4928
  span2.setAttribute("llm.response.duration", (endTime - startTime) / 1e3);
4807
4929
  span2.setStatus({ code });
4808
4930
  } catch (e) {
4809
- Logger.error(
4931
+ NetraLogger.error(
4810
4932
  "netra.instrumentation.anthropic: finalizeStreamSpan error",
4811
4933
  e
4812
4934
  );
@@ -4817,12 +4939,12 @@ function finalizeStreamSpan(span2, completeResponse, startTime, code) {
4817
4939
  function setRequestAttributes2(span2, kwargs, requestType) {
4818
4940
  try {
4819
4941
  if (!span2.isRecording()) {
4820
- Logger.log("Span is not recording");
4942
+ NetraLogger.log("Span is not recording");
4821
4943
  return;
4822
4944
  }
4823
4945
  setRequestAttributes(span2, kwargs, requestType, "anthropic");
4824
4946
  } catch (e) {
4825
- Logger.error(
4947
+ NetraLogger.error(
4826
4948
  "netra.instrumentation.anthropic: setRequestAttributes error",
4827
4949
  e
4828
4950
  );
@@ -4831,7 +4953,7 @@ function setRequestAttributes2(span2, kwargs, requestType) {
4831
4953
  function setResponseAttributes2(span2, response) {
4832
4954
  try {
4833
4955
  if (!span2.isRecording()) {
4834
- Logger.log("Span is not recording");
4956
+ NetraLogger.log("Span is not recording");
4835
4957
  return;
4836
4958
  }
4837
4959
  if (response?.type === "message_batch") {
@@ -4839,7 +4961,7 @@ function setResponseAttributes2(span2, response) {
4839
4961
  }
4840
4962
  setResponseAttributes(span2, response);
4841
4963
  } catch (e) {
4842
- Logger.error(
4964
+ NetraLogger.error(
4843
4965
  "netra.instrumentation.anthropic: setResponseAttributes error",
4844
4966
  e
4845
4967
  );
@@ -4978,7 +5100,7 @@ var MessageStreamWrapper = class {
4978
5100
  target.processEventData(event, args[0]);
4979
5101
  }
4980
5102
  } catch (e) {
4981
- Logger.error(
5103
+ NetraLogger.error(
4982
5104
  "netra.instrumentation.anthropic: event tracking error",
4983
5105
  e
4984
5106
  );
@@ -5070,7 +5192,7 @@ var MessageStreamWrapper = class {
5070
5192
  this.finalizeSpanOnce(SpanStatusCode.ERROR);
5071
5193
  });
5072
5194
  } catch (e) {
5073
- Logger.error(
5195
+ NetraLogger.error(
5074
5196
  "netra.instrumentation.anthropic: safety net listener registration failed",
5075
5197
  e
5076
5198
  );
@@ -5088,7 +5210,7 @@ var MessageStreamWrapper = class {
5088
5210
  }
5089
5211
  } catch (err) {
5090
5212
  errorOccurred = true;
5091
- Logger.error("netra.instrumentation.anthropic: Stream error", err);
5213
+ NetraLogger.error("netra.instrumentation.anthropic: Stream error", err);
5092
5214
  this.finalizeSpanOnce(SpanStatusCode.ERROR);
5093
5215
  throw err;
5094
5216
  } finally {
@@ -5158,7 +5280,7 @@ function anthropicWrapper(tracer, spanName, requestType) {
5158
5280
  const currentContext = context.active();
5159
5281
  const isStreaming = attributes.stream === true;
5160
5282
  const activeSpan = trace.getSpan(currentContext);
5161
- Logger.debug(
5283
+ NetraLogger.debug(
5162
5284
  `Anthropic invoke (${requestType}). Active TraceId: ${activeSpan?.spanContext().traceId}, SpanId: ${activeSpan?.spanContext().spanId}`
5163
5285
  );
5164
5286
  return tracer.startActiveSpan(
@@ -5190,7 +5312,7 @@ function anthropicWrapper(tracer, spanName, requestType) {
5190
5312
  withContext: (fn) => context.with(spanContext, fn),
5191
5313
  onChunk: (chunk) => processStreamChunk(completeResponse, chunk, span2),
5192
5314
  onError: (error) => {
5193
- Logger.error("netra.instrumentation.anthropic:", error);
5315
+ NetraLogger.error("netra.instrumentation.anthropic:", error);
5194
5316
  span2.setStatus({
5195
5317
  code: SpanStatusCode.ERROR,
5196
5318
  message: error instanceof Error ? error.message : String(error)
@@ -5226,7 +5348,7 @@ function anthropicWrapper(tracer, spanName, requestType) {
5226
5348
  { preserveOriginal: response }
5227
5349
  );
5228
5350
  } catch (error) {
5229
- Logger.error("netra.instrumentation.anthropic:", error);
5351
+ NetraLogger.error("netra.instrumentation.anthropic:", error);
5230
5352
  span2.setStatus({
5231
5353
  code: SpanStatusCode.ERROR,
5232
5354
  message: error instanceof Error ? error.message : String(error)
@@ -5479,7 +5601,7 @@ async function resolveAnthropic() {
5479
5601
  anthropicModule.Anthropic || anthropicModule.default || anthropicModule
5480
5602
  );
5481
5603
  } catch {
5482
- Logger.warn("Failed to resolve Anthropic ESM module");
5604
+ NetraLogger.warn("Failed to resolve Anthropic ESM module");
5483
5605
  }
5484
5606
  try {
5485
5607
  const req = createRequire(import.meta.url);
@@ -5489,7 +5611,7 @@ async function resolveAnthropic() {
5489
5611
  anthropicClasses.push(cjsClass);
5490
5612
  }
5491
5613
  } catch {
5492
- Logger.warn("Failed to resolve Anthropic CJS module");
5614
+ NetraLogger.warn("Failed to resolve Anthropic CJS module");
5493
5615
  }
5494
5616
  return anthropicClasses;
5495
5617
  }
@@ -5502,7 +5624,7 @@ var NetraAnthropicInstrumentor = class {
5502
5624
  }
5503
5625
  async instrument(options = {}) {
5504
5626
  if (isInstrumented) {
5505
- Logger.warn("Anthropic is already instrumented");
5627
+ NetraLogger.warn("Anthropic is already instrumented");
5506
5628
  return this;
5507
5629
  }
5508
5630
  const classes = await resolveAnthropic();
@@ -5518,7 +5640,7 @@ var NetraAnthropicInstrumentor = class {
5518
5640
  this.tracer = trace.getTracer(INSTRUMENTATION_NAME, __version__);
5519
5641
  }
5520
5642
  } catch (error) {
5521
- Logger.error(`Failed to initialize tracer: ${error}`);
5643
+ NetraLogger.error(`Failed to initialize tracer: ${error}`);
5522
5644
  return this;
5523
5645
  }
5524
5646
  classes.forEach((AnthropicSDK) => {
@@ -5531,7 +5653,7 @@ var NetraAnthropicInstrumentor = class {
5531
5653
  }
5532
5654
  uninstrument() {
5533
5655
  if (!isInstrumented) {
5534
- Logger.warn("Anthropic is not instrumented");
5656
+ NetraLogger.warn("Anthropic is not instrumented");
5535
5657
  return;
5536
5658
  }
5537
5659
  anthropicClasses.forEach((AnthropicSDK) => {
@@ -5547,13 +5669,13 @@ var NetraAnthropicInstrumentor = class {
5547
5669
  }
5548
5670
  _instrumentMessages(AnthropicSDK) {
5549
5671
  if (!this.tracer) {
5550
- Logger.warn("Anthropic instrumentation: No tracer available");
5672
+ NetraLogger.warn("Anthropic instrumentation: No tracer available");
5551
5673
  return;
5552
5674
  }
5553
5675
  try {
5554
5676
  const MessagesClass = AnthropicSDK.Messages;
5555
5677
  if (!MessagesClass?.prototype) {
5556
- Logger.error(
5678
+ NetraLogger.error(
5557
5679
  "Anthropic instrumentation: Could not find Messages class"
5558
5680
  );
5559
5681
  return;
@@ -5574,18 +5696,18 @@ var NetraAnthropicInstrumentor = class {
5574
5696
  );
5575
5697
  }
5576
5698
  } catch (error) {
5577
- Logger.error(`Failed to instrument messages: ${error}`);
5699
+ NetraLogger.error(`Failed to instrument messages: ${error}`);
5578
5700
  }
5579
5701
  }
5580
5702
  _instrumentBetaMessages(AnthropicSDK) {
5581
5703
  if (!this.tracer) {
5582
- Logger.warn("Anthropic instrumentation: No tracer available");
5704
+ NetraLogger.warn("Anthropic instrumentation: No tracer available");
5583
5705
  return;
5584
5706
  }
5585
5707
  try {
5586
5708
  const BetaMessagesClass = AnthropicSDK.Beta?.Messages;
5587
5709
  if (!BetaMessagesClass?.prototype) {
5588
- Logger.error(
5710
+ NetraLogger.error(
5589
5711
  "Anthropic instrumentation: Could not find Beta Messages class"
5590
5712
  );
5591
5713
  return;
@@ -5613,18 +5735,18 @@ var NetraAnthropicInstrumentor = class {
5613
5735
  );
5614
5736
  }
5615
5737
  } catch (error) {
5616
- Logger.error(`Failed to instrument beta: ${error}`);
5738
+ NetraLogger.error(`Failed to instrument beta: ${error}`);
5617
5739
  }
5618
5740
  }
5619
5741
  _instrumentBatchMessages(AnthropicSDK) {
5620
5742
  if (!this.tracer) {
5621
- Logger.warn("Anthropic instrumentation: No tracer available");
5743
+ NetraLogger.warn("Anthropic instrumentation: No tracer available");
5622
5744
  return;
5623
5745
  }
5624
5746
  try {
5625
5747
  const BatchMessageClass = AnthropicSDK.Messages?.Batches;
5626
5748
  if (!BatchMessageClass?.prototype) {
5627
- Logger.error("Anthropic instrumentation: Could not find Batches class");
5749
+ NetraLogger.error("Anthropic instrumentation: Could not find Batches class");
5628
5750
  return;
5629
5751
  }
5630
5752
  if (typeof BatchMessageClass.prototype.create === "function") {
@@ -5635,7 +5757,7 @@ var NetraAnthropicInstrumentor = class {
5635
5757
  );
5636
5758
  }
5637
5759
  } catch (error) {
5638
- Logger.error(`Failed to instrument batches: ${error}`);
5760
+ NetraLogger.error(`Failed to instrument batches: ${error}`);
5639
5761
  }
5640
5762
  }
5641
5763
  _uninstrumentMessages(AnthropicSDK) {
@@ -5645,7 +5767,7 @@ var NetraAnthropicInstrumentor = class {
5645
5767
  if (typeof proto.create === "function") shimmer.unwrap(proto, "create");
5646
5768
  if (typeof proto.stream === "function") shimmer.unwrap(proto, "stream");
5647
5769
  } catch (error) {
5648
- Logger.error(`Failed to uninstrument messages: ${error}`);
5770
+ NetraLogger.error(`Failed to uninstrument messages: ${error}`);
5649
5771
  }
5650
5772
  }
5651
5773
  _uninstrumentBetaMessages(AnthropicSDK) {
@@ -5657,7 +5779,7 @@ var NetraAnthropicInstrumentor = class {
5657
5779
  if (typeof proto.toolRunner === "function")
5658
5780
  shimmer.unwrap(proto, "toolRunner");
5659
5781
  } catch (error) {
5660
- Logger.error(`Failed to uninstrument beta: ${error}`);
5782
+ NetraLogger.error(`Failed to uninstrument beta: ${error}`);
5661
5783
  }
5662
5784
  }
5663
5785
  _uninstrumentBatchMessages(AnthropicSDK) {
@@ -5666,7 +5788,7 @@ var NetraAnthropicInstrumentor = class {
5666
5788
  if (!proto) return;
5667
5789
  if (typeof proto.create === "function") shimmer.unwrap(proto, "create");
5668
5790
  } catch (error) {
5669
- Logger.error(`Failed to uninstrument batches: ${error}`);
5791
+ NetraLogger.error(`Failed to uninstrument batches: ${error}`);
5670
5792
  }
5671
5793
  }
5672
5794
  };
@@ -5703,7 +5825,7 @@ var BaseInstrumentor = class {
5703
5825
  }
5704
5826
  async instrument(options = {}) {
5705
5827
  if (this._isInstrumented) {
5706
- Logger.warn(`${this.displayName} is already instrumented`);
5828
+ NetraLogger.warn(`${this.displayName} is already instrumented`);
5707
5829
  return this;
5708
5830
  }
5709
5831
  if (this._instrumentPromise) {
@@ -5720,20 +5842,20 @@ var BaseInstrumentor = class {
5720
5842
  this._generation++;
5721
5843
  this._instrumentPromise = null;
5722
5844
  if (!this._isInstrumented) {
5723
- Logger.warn(`${this.displayName} is not instrumented`);
5845
+ NetraLogger.warn(`${this.displayName} is not instrumented`);
5724
5846
  return;
5725
5847
  }
5726
5848
  for (const classes of this._resolvedClasses) {
5727
5849
  try {
5728
5850
  this.removePatches(classes);
5729
5851
  } catch (error) {
5730
- Logger.error(`${this.displayName}: failed to remove patches: ${error}`);
5852
+ NetraLogger.error(`${this.displayName}: failed to remove patches: ${error}`);
5731
5853
  }
5732
5854
  }
5733
5855
  try {
5734
5856
  this.onUninstrument();
5735
5857
  } catch (error) {
5736
- Logger.error(`${this.displayName}: onUninstrument failed: ${error}`);
5858
+ NetraLogger.error(`${this.displayName}: onUninstrument failed: ${error}`);
5737
5859
  } finally {
5738
5860
  this._resolvedClasses = [];
5739
5861
  this._isInstrumented = false;
@@ -5758,7 +5880,7 @@ var BaseInstrumentor = class {
5758
5880
  this.instrumentationVersion
5759
5881
  );
5760
5882
  } catch (error) {
5761
- Logger.error(`${this.displayName}: failed to initialize tracer: ${error}`);
5883
+ NetraLogger.error(`${this.displayName}: failed to initialize tracer: ${error}`);
5762
5884
  return this;
5763
5885
  }
5764
5886
  let anyWrapped = false;
@@ -5768,11 +5890,11 @@ var BaseInstrumentor = class {
5768
5890
  anyWrapped = true;
5769
5891
  }
5770
5892
  } catch (error) {
5771
- Logger.error(`${this.displayName}: patch failed: ${error}`);
5893
+ NetraLogger.error(`${this.displayName}: patch failed: ${error}`);
5772
5894
  try {
5773
5895
  this.removePatches(classes);
5774
5896
  } catch {
5775
- Logger.error(`${this.displayName}: failed to remove patches: ${error}`);
5897
+ NetraLogger.error(`${this.displayName}: failed to remove patches: ${error}`);
5776
5898
  }
5777
5899
  }
5778
5900
  }
@@ -5794,7 +5916,7 @@ var BaseInstrumentor = class {
5794
5916
  this._resolvedClasses.push(classes);
5795
5917
  }
5796
5918
  } catch {
5797
- Logger.debug(`${this.displayName}: ESM import not available`);
5919
+ NetraLogger.debug(`${this.displayName}: ESM import not available`);
5798
5920
  }
5799
5921
  try {
5800
5922
  const req = createRequire(import.meta.url);
@@ -5809,7 +5931,7 @@ var BaseInstrumentor = class {
5809
5931
  }
5810
5932
  }
5811
5933
  } catch {
5812
- Logger.debug(`${this.displayName}: CJS require not available`);
5934
+ NetraLogger.debug(`${this.displayName}: CJS require not available`);
5813
5935
  }
5814
5936
  return this._resolvedClasses;
5815
5937
  }
@@ -5879,7 +6001,7 @@ function setRequestAttributes3(span2, params, requestType) {
5879
6001
  writePromptAttributes(span2, messages);
5880
6002
  }
5881
6003
  } catch (e) {
5882
- Logger.error(`${LOG_PREFIX}: setRequestAttributes error`, e);
6004
+ NetraLogger.error(`${LOG_PREFIX}: setRequestAttributes error`, e);
5883
6005
  }
5884
6006
  }
5885
6007
  function extractModelName(model) {
@@ -5995,7 +6117,7 @@ function setResponseAttributes3(span2, response) {
5995
6117
  writeCompletionAttributes(span2, messages);
5996
6118
  }
5997
6119
  } catch (e) {
5998
- Logger.error(`${LOG_PREFIX}: setResponseAttributes error`, e);
6120
+ NetraLogger.error(`${LOG_PREFIX}: setResponseAttributes error`, e);
5999
6121
  }
6000
6122
  }
6001
6123
  function setUsageAttributes2(span2, response) {
@@ -6183,11 +6305,11 @@ function processStreamChunk2(accumulated, chunk, span2, startTime) {
6183
6305
  accumulated.candidates[0].finishReason = reason;
6184
6306
  }
6185
6307
  }
6186
- if (Logger.isDebugMode()) {
6308
+ if (NetraLogger.isDebugMode()) {
6187
6309
  span2.addEvent("llm.content.completion.chunk");
6188
6310
  }
6189
6311
  } catch (e) {
6190
- Logger.error(`${LOG_PREFIX}: processStreamChunk error`, e);
6312
+ NetraLogger.error(`${LOG_PREFIX}: processStreamChunk error`, e);
6191
6313
  }
6192
6314
  }
6193
6315
  function buildAccumulatedResponse(accumulated) {
@@ -6347,7 +6469,7 @@ function streamWrapperFactory(tracer, spanName, requestType) {
6347
6469
  (endTime - startTime) / 1e3
6348
6470
  );
6349
6471
  } catch (e) {
6350
- Logger.error(`${LOG_PREFIX2}: stream finalize error`, e);
6472
+ NetraLogger.error(`${LOG_PREFIX2}: stream finalize error`, e);
6351
6473
  }
6352
6474
  if (status === "ok") {
6353
6475
  span2.setStatus({ code: SpanStatusCode.OK });
@@ -6395,7 +6517,7 @@ var NetraGoogleGenAIInstrumentor = class extends BaseInstrumentor {
6395
6517
  applyPatches(classes, tracer) {
6396
6518
  const modelsProto = classes.Models?.prototype;
6397
6519
  if (!modelsProto) {
6398
- Logger.error("Google GenAI: Models.prototype not found");
6520
+ NetraLogger.error("Google GenAI: Models.prototype not found");
6399
6521
  return false;
6400
6522
  }
6401
6523
  let wrapped = false;
@@ -6890,7 +7012,7 @@ function googleGenerativeAIWrapper(tracer, spanName, requestType) {
6890
7012
  try {
6891
7013
  setRequestAttributes4(span2, kwargs, requestType, args[0]);
6892
7014
  } catch (e) {
6893
- Logger.error(`${LOG_PREFIX3}:`, e);
7015
+ NetraLogger.error(`${LOG_PREFIX3}:`, e);
6894
7016
  }
6895
7017
  const startTime = Date.now();
6896
7018
  const response = original.apply(this, args);
@@ -6911,7 +7033,7 @@ function googleGenerativeAIWrapper(tracer, spanName, requestType) {
6911
7033
  );
6912
7034
  }
6913
7035
  } catch (e) {
6914
- Logger.error(`${LOG_PREFIX3}:`, e);
7036
+ NetraLogger.error(`${LOG_PREFIX3}:`, e);
6915
7037
  }
6916
7038
  span2.setStatus({ code: SpanStatusCode.OK });
6917
7039
  span2.end();
@@ -6936,7 +7058,7 @@ function googleGenerativeAIWrapper(tracer, spanName, requestType) {
6936
7058
  (endTime - startTime) / 1e3
6937
7059
  );
6938
7060
  } catch (e) {
6939
- Logger.error(`${LOG_PREFIX3}:`, e);
7061
+ NetraLogger.error(`${LOG_PREFIX3}:`, e);
6940
7062
  }
6941
7063
  span2.setStatus({ code: SpanStatusCode.OK });
6942
7064
  span2.end();
@@ -6978,7 +7100,7 @@ function googleGenerativeAIStreamWrapper(tracer, spanName, requestType) {
6978
7100
  try {
6979
7101
  setRequestAttributes4(span2, kwargs, requestType, args[0]);
6980
7102
  } catch (e) {
6981
- Logger.error(`${LOG_PREFIX3}:`, e);
7103
+ NetraLogger.error(`${LOG_PREFIX3}:`, e);
6982
7104
  }
6983
7105
  const response = original.apply(this, args);
6984
7106
  if (!isPromise(response)) {
@@ -7002,7 +7124,7 @@ function googleGenerativeAIStreamWrapper(tracer, spanName, requestType) {
7002
7124
  duration
7003
7125
  );
7004
7126
  } catch (e) {
7005
- Logger.error(`${LOG_PREFIX3}:`, e);
7127
+ NetraLogger.error(`${LOG_PREFIX3}:`, e);
7006
7128
  }
7007
7129
  span2.setStatus({ code: SpanStatusCode.OK });
7008
7130
  span2.end();
@@ -7038,7 +7160,7 @@ function googleGenerativeAIStreamWrapper(tracer, spanName, requestType) {
7038
7160
  duration
7039
7161
  );
7040
7162
  } catch (e) {
7041
- Logger.error(`${LOG_PREFIX3}:`, e);
7163
+ NetraLogger.error(`${LOG_PREFIX3}:`, e);
7042
7164
  }
7043
7165
  span2.setStatus({ code: SpanStatusCode.OK });
7044
7166
  span2.end();
@@ -7143,7 +7265,7 @@ var NetraGoogleGenerativeAIInstrumentor = class extends BaseInstrumentor {
7143
7265
  applyPatches(classes, tracer) {
7144
7266
  const proto = classes.GenerativeModel?.prototype;
7145
7267
  if (!proto) {
7146
- Logger.error("Google Generative AI: GenerativeModel.prototype not found");
7268
+ NetraLogger.error("Google Generative AI: GenerativeModel.prototype not found");
7147
7269
  return false;
7148
7270
  }
7149
7271
  let wrapped = false;
@@ -7206,14 +7328,14 @@ var __version__4 = "1.0.0";
7206
7328
  // src/instrumentation/groq/utils.ts
7207
7329
  function setRequestAttributes5(span2, kwargs, requestType) {
7208
7330
  if (!span2.isRecording()) {
7209
- Logger.log("Span is not recording");
7331
+ NetraLogger.log("Span is not recording");
7210
7332
  return;
7211
7333
  }
7212
7334
  setRequestAttributes(span2, kwargs, requestType, "groq");
7213
7335
  }
7214
7336
  function setResponseAttributes5(span2, response) {
7215
7337
  if (!span2.isRecording()) {
7216
- Logger.log("Span is not recording");
7338
+ NetraLogger.log("Span is not recording");
7217
7339
  return;
7218
7340
  }
7219
7341
  setResponseAttributes(span2, response);
@@ -7249,7 +7371,7 @@ function groqWrapper(tracer, spanName, requestType) {
7249
7371
  const stream = await response;
7250
7372
  return new AsyncStreamingWrapper(span2, stream, startTime, kwargs);
7251
7373
  } catch (error) {
7252
- Logger.error("netra.instrumentation.groq:", error);
7374
+ NetraLogger.error("netra.instrumentation.groq:", error);
7253
7375
  span2.setStatus({
7254
7376
  code: SpanStatusCode.ERROR,
7255
7377
  message: error instanceof Error ? error.message : String(error)
@@ -7263,7 +7385,7 @@ function groqWrapper(tracer, spanName, requestType) {
7263
7385
  return new StreamingWrapper(span2, response, startTime, kwargs);
7264
7386
  }
7265
7387
  } catch (error) {
7266
- Logger.error("netra.instrumentation.groq:", error);
7388
+ NetraLogger.error("netra.instrumentation.groq:", error);
7267
7389
  span2.setStatus({
7268
7390
  code: SpanStatusCode.ERROR,
7269
7391
  message: error instanceof Error ? error.message : String(error)
@@ -7299,7 +7421,7 @@ function groqWrapper(tracer, spanName, requestType) {
7299
7421
  span2.end();
7300
7422
  return value;
7301
7423
  } catch (error) {
7302
- Logger.error("netra.instrumentation.groq:", error);
7424
+ NetraLogger.error("netra.instrumentation.groq:", error);
7303
7425
  span2.setStatus({
7304
7426
  code: SpanStatusCode.ERROR,
7305
7427
  message: error instanceof Error ? error.message : String(error)
@@ -7322,7 +7444,7 @@ function groqWrapper(tracer, spanName, requestType) {
7322
7444
  return response;
7323
7445
  }
7324
7446
  } catch (error) {
7325
- Logger.error("netra.instrumentation.groq:", error);
7447
+ NetraLogger.error("netra.instrumentation.groq:", error);
7326
7448
  span2.setStatus({
7327
7449
  code: SpanStatusCode.ERROR,
7328
7450
  message: error instanceof Error ? error.message : String(error)
@@ -7563,7 +7685,7 @@ async function resolveGroqAsync() {
7563
7685
  const groqModule = await import('groq-sdk');
7564
7686
  groqClasses.push(groqModule.Groq || groqModule.default || groqModule);
7565
7687
  } catch {
7566
- Logger.warn("Failed to resolve Groq ESM module");
7688
+ NetraLogger.warn("Failed to resolve Groq ESM module");
7567
7689
  }
7568
7690
  try {
7569
7691
  const req = createRequire(import.meta.url);
@@ -7573,7 +7695,7 @@ async function resolveGroqAsync() {
7573
7695
  groqClasses.push(cjsClass);
7574
7696
  }
7575
7697
  } catch {
7576
- Logger.warn("Failed to resolve Groq CJS module");
7698
+ NetraLogger.warn("Failed to resolve Groq CJS module");
7577
7699
  }
7578
7700
  return groqClasses;
7579
7701
  }
@@ -7593,7 +7715,7 @@ var NetraGroqInstrumentor = class {
7593
7715
  */
7594
7716
  async instrumentAsync(options = {}) {
7595
7717
  if (isInstrumented2) {
7596
- Logger.warn("Groq is already instrumented");
7718
+ NetraLogger.warn("Groq is already instrumented");
7597
7719
  return this;
7598
7720
  }
7599
7721
  const classes = await resolveGroqAsync();
@@ -7611,7 +7733,7 @@ var NetraGroqInstrumentor = class {
7611
7733
  this.tracer = trace.getTracer(INSTRUMENTATION_NAME2, __version__4);
7612
7734
  }
7613
7735
  } catch (error) {
7614
- Logger.error(`Failed to initialize tracer: ${error}`);
7736
+ NetraLogger.error(`Failed to initialize tracer: ${error}`);
7615
7737
  return this;
7616
7738
  }
7617
7739
  classes.forEach((Groq, index) => {
@@ -7626,13 +7748,13 @@ var NetraGroqInstrumentor = class {
7626
7748
  */
7627
7749
  instrument(options = {}) {
7628
7750
  if (isInstrumented2) {
7629
- Logger.warn("Groq is already instrumented");
7751
+ NetraLogger.warn("Groq is already instrumented");
7630
7752
  return this;
7631
7753
  }
7632
7754
  const classes = resolveGroq();
7633
7755
  if (classes.length === 0) {
7634
7756
  this.instrumentAsync(options).catch((e) => {
7635
- Logger.error("Failed to instrument Groq:", e);
7757
+ NetraLogger.error("Failed to instrument Groq:", e);
7636
7758
  });
7637
7759
  return this;
7638
7760
  }
@@ -7647,7 +7769,7 @@ var NetraGroqInstrumentor = class {
7647
7769
  this.tracer = trace.getTracer(INSTRUMENTATION_NAME2, __version__4);
7648
7770
  }
7649
7771
  } catch (error) {
7650
- Logger.error(`Failed to initialize tracer: ${error}`);
7772
+ NetraLogger.error(`Failed to initialize tracer: ${error}`);
7651
7773
  return this;
7652
7774
  }
7653
7775
  classes.forEach((Groq, index) => {
@@ -7658,7 +7780,7 @@ var NetraGroqInstrumentor = class {
7658
7780
  }
7659
7781
  uninstrument() {
7660
7782
  if (!isInstrumented2) {
7661
- Logger.warn("Groq is not instrumented");
7783
+ NetraLogger.warn("Groq is not instrumented");
7662
7784
  return;
7663
7785
  }
7664
7786
  const classes = resolveGroq();
@@ -7674,13 +7796,13 @@ var NetraGroqInstrumentor = class {
7674
7796
  }
7675
7797
  _instrumentChatCompletions(Groq, index) {
7676
7798
  if (!this.tracer) {
7677
- Logger.warn("Groq instrumentation: No tracer available");
7799
+ NetraLogger.warn("Groq instrumentation: No tracer available");
7678
7800
  return;
7679
7801
  }
7680
7802
  try {
7681
7803
  const CompletionsClass = Groq.Chat?.Completions;
7682
7804
  if (!CompletionsClass?.prototype?.create) {
7683
- Logger.error(
7805
+ NetraLogger.error(
7684
7806
  "Groq instrumentation: Could not find Groq chat completions class to instrument"
7685
7807
  );
7686
7808
  return;
@@ -7696,7 +7818,7 @@ var NetraGroqInstrumentor = class {
7696
7818
  return wrapper(wrappedFn, this, args, kwargs);
7697
7819
  };
7698
7820
  } catch (error) {
7699
- Logger.error(
7821
+ NetraLogger.error(
7700
7822
  `Groq instrumentation: Failed to instrument chat completions: ${error}`
7701
7823
  );
7702
7824
  }
@@ -7709,7 +7831,7 @@ var NetraGroqInstrumentor = class {
7709
7831
  CompletionsClass.prototype.create = originalCreate;
7710
7832
  }
7711
7833
  } catch (error) {
7712
- Logger.error(`Failed to uninstrument chat completions: ${error}`);
7834
+ NetraLogger.error(`Failed to uninstrument chat completions: ${error}`);
7713
7835
  }
7714
7836
  }
7715
7837
  };
@@ -7886,14 +8008,14 @@ async function loadLanggraphCallbackHandler() {
7886
8008
  try {
7887
8009
  Base = (await import('@langchain/core/callbacks/base')).BaseCallbackHandler;
7888
8010
  } catch {
7889
- Logger.debug("@langchain/core: ESM import not available");
8011
+ NetraLogger.debug("@langchain/core: ESM import not available");
7890
8012
  }
7891
8013
  if (!Base) {
7892
8014
  try {
7893
8015
  const req = createRequire(import.meta.url);
7894
8016
  Base = req("@langchain/core/callbacks/base").BaseCallbackHandler;
7895
8017
  } catch {
7896
- Logger.debug("@langchain/core: CJS require not available");
8018
+ NetraLogger.debug("@langchain/core: CJS require not available");
7897
8019
  }
7898
8020
  }
7899
8021
  if (!Base) {
@@ -7950,7 +8072,7 @@ function createCallbackHandlerClass(Base) {
7950
8072
  const nodeName = metadataNodeName || runNameValue || chainIdName || "Chain";
7951
8073
  const nodeType = chainIdName || "Unknown";
7952
8074
  const metadataKeys = metadata && typeof metadata === "object" ? Object.keys(metadata).join(",") : "n/a";
7953
- Logger.debug(
8075
+ NetraLogger.debug(
7954
8076
  `NetraLanggraph handleChainStart: runId=${runId} parentRunId=${parentRunId} nodeName=${nodeName} nodeType=${nodeType} runName=${runNameValue || "n/a"} metadataKeys=${metadataKeys}`
7955
8077
  );
7956
8078
  if (["__start__"].includes(nodeName.toLowerCase())) {
@@ -7959,7 +8081,7 @@ function createCallbackHandlerClass(Base) {
7959
8081
  const effectiveParentRunId = this.inferParentRunId(parentRunId);
7960
8082
  if (!parentRunId && effectiveParentRunId && effectiveParentRunId !== runId) {
7961
8083
  this.inferredParents.set(runId, effectiveParentRunId);
7962
- Logger.debug(`NetraLanggraph inferred parent: runId=${runId} parentRunId=${effectiveParentRunId}`);
8084
+ NetraLogger.debug(`NetraLanggraph inferred parent: runId=${runId} parentRunId=${effectiveParentRunId}`);
7963
8085
  }
7964
8086
  const parentSpan = this.getParentSpan(effectiveParentRunId);
7965
8087
  const ctx = trace.setSpan(context.active(), parentSpan);
@@ -7992,7 +8114,7 @@ function createCallbackHandlerClass(Base) {
7992
8114
  const effectiveParentRunId = parentRunId ?? this.inferParentRunId(parentRunId);
7993
8115
  {
7994
8116
  const llmId = llm.id?.[llm.id.length - 1] || "llm";
7995
- Logger.debug(`NetraLanggraph handleLLMStart: runId=${runId} parentRunId=${effectiveParentRunId} llmId=${llmId}`);
8117
+ NetraLogger.debug(`NetraLanggraph handleLLMStart: runId=${runId} parentRunId=${effectiveParentRunId} llmId=${llmId}`);
7996
8118
  }
7997
8119
  this.addNodeAttributes(runId, {
7998
8120
  llmIds: llm.id,
@@ -8046,7 +8168,7 @@ function createCallbackHandlerClass(Base) {
8046
8168
  const effectiveParentRunId = parentRunId ?? this.inferParentRunId(parentRunId);
8047
8169
  {
8048
8170
  const toolName = tool.id?.[tool.id.length - 1] || "tool";
8049
- Logger.debug(`NetraLanggraph handleToolStart: runId=${runId} parentRunId=${effectiveParentRunId} tool=${toolName}`);
8171
+ NetraLogger.debug(`NetraLanggraph handleToolStart: runId=${runId} parentRunId=${effectiveParentRunId} tool=${toolName}`);
8050
8172
  }
8051
8173
  this.addNodeAttributes(runId, {
8052
8174
  input: parsedInput,
@@ -8149,7 +8271,7 @@ var LanggraphWrapper = class {
8149
8271
  return await originalFunc.call(instance, input, config, ...rest);
8150
8272
  }
8151
8273
  const activeSpan = trace.getSpan(context.active());
8152
- Logger.debug(`LangGraph invoke start. Active TraceId: ${activeSpan?.spanContext().traceId}, SpanId: ${activeSpan?.spanContext().spanId}`);
8274
+ NetraLogger.debug(`LangGraph invoke start. Active TraceId: ${activeSpan?.spanContext().traceId}, SpanId: ${activeSpan?.spanContext().spanId}`);
8153
8275
  const span2 = this.tracer.startSpan(
8154
8276
  this.spanName,
8155
8277
  {
@@ -8157,14 +8279,14 @@ var LanggraphWrapper = class {
8157
8279
  },
8158
8280
  context.active()
8159
8281
  );
8160
- Logger.debug(`LangGraph span created. New TraceId: ${span2.spanContext().traceId}, SpanId: ${span2.spanContext().spanId}`);
8282
+ NetraLogger.debug(`LangGraph span created. New TraceId: ${span2.spanContext().traceId}, SpanId: ${span2.spanContext().spanId}`);
8161
8283
  const ctxWithSpan = trace.setSpan(context.active(), span2);
8162
8284
  const ctxWithFlag = ctxWithSpan.setValue(LANGGRAPH_INSTRUMENTATION_ACTIVE, true);
8163
8285
  enterWithContext(ctxWithFlag);
8164
8286
  return context.with(ctxWithFlag, async () => {
8165
8287
  {
8166
8288
  const innerSpan = trace.getSpan(context.active());
8167
- Logger.debug(`Inside LangGraph context. Active TraceId: ${innerSpan?.spanContext().traceId}, SpanId: ${innerSpan?.spanContext().spanId}`);
8289
+ NetraLogger.debug(`Inside LangGraph context. Active TraceId: ${innerSpan?.spanContext().traceId}, SpanId: ${innerSpan?.spanContext().spanId}`);
8168
8290
  }
8169
8291
  try {
8170
8292
  setGraphInputAttributes(span2, input);
@@ -8187,10 +8309,10 @@ var LanggraphWrapper = class {
8187
8309
  }
8188
8310
  async stream(originalFunc, instance, input, config, ...rest) {
8189
8311
  if (shouldSuppressInstrumentation() || context.active().getValue(LANGGRAPH_INSTRUMENTATION_ACTIVE)) {
8190
- Logger.debug("LangGraph stream skipped (inside instrumented call)");
8312
+ NetraLogger.debug("LangGraph stream skipped (inside instrumented call)");
8191
8313
  return await originalFunc.call(instance, input, config, ...rest);
8192
8314
  }
8193
- Logger.debug("LangGraph stream starting instrumentation");
8315
+ NetraLogger.debug("LangGraph stream starting instrumentation");
8194
8316
  const span2 = this.tracer.startSpan(
8195
8317
  this.spanName,
8196
8318
  {
@@ -8230,11 +8352,11 @@ function findModuleInCache(moduleName) {
8230
8352
  const cache = __require.cache;
8231
8353
  for (const key of Object.keys(cache)) {
8232
8354
  if (key.includes(moduleName.replace(/\//g, "/")) && !key.includes("netra-sdk")) {
8233
- Logger.debug(`Found module in require.cache: ${key}`);
8355
+ NetraLogger.debug(`Found module in require.cache: ${key}`);
8234
8356
  return cache[key]?.exports;
8235
8357
  }
8236
8358
  }
8237
- Logger.debug(
8359
+ NetraLogger.debug(
8238
8360
  `Module ${moduleName} not found in require.cache. Cache keys containing 'langgraph':`,
8239
8361
  Object.keys(cache).filter((k) => k.includes("langgraph"))
8240
8362
  );
@@ -8246,35 +8368,35 @@ async function resolveLanggraph() {
8246
8368
  try {
8247
8369
  let langgraphModule = findModuleInCache("@langchain/langgraph");
8248
8370
  if (langgraphModule) {
8249
- Logger.debug("Found @langchain/langgraph in require.cache (using app's module instance)");
8371
+ NetraLogger.debug("Found @langchain/langgraph in require.cache (using app's module instance)");
8250
8372
  } else {
8251
8373
  langgraphModule = await import('@langchain/langgraph');
8252
- Logger.debug("Loaded @langchain/langgraph via dynamic import");
8374
+ NetraLogger.debug("Loaded @langchain/langgraph via dynamic import");
8253
8375
  }
8254
- Logger.debug("LangGraph Module Exports:", Object.keys(langgraphModule));
8376
+ NetraLogger.debug("LangGraph Module Exports:", Object.keys(langgraphModule));
8255
8377
  LanggraphClass = langgraphModule.CompiledStateGraph ?? langgraphModule.StateGraph;
8256
- Logger.debug("Resolved LanggraphClass:", !!LanggraphClass);
8257
- Logger.debug("LanggraphClass name:", LanggraphClass?.name);
8258
- Logger.debug(
8378
+ NetraLogger.debug("Resolved LanggraphClass:", !!LanggraphClass);
8379
+ NetraLogger.debug("LanggraphClass name:", LanggraphClass?.name);
8380
+ NetraLogger.debug(
8259
8381
  "LanggraphClass.prototype keys:",
8260
8382
  LanggraphClass?.prototype ? Object.getOwnPropertyNames(LanggraphClass.prototype) : "no prototype"
8261
8383
  );
8262
- Logger.debug("Has invoke on prototype:", !!LanggraphClass?.prototype?.invoke);
8263
- Logger.debug("Has stream on prototype:", !!LanggraphClass?.prototype?.stream);
8264
- Logger.debug("Checking prototype chain for invoke location:");
8384
+ NetraLogger.debug("Has invoke on prototype:", !!LanggraphClass?.prototype?.invoke);
8385
+ NetraLogger.debug("Has stream on prototype:", !!LanggraphClass?.prototype?.stream);
8386
+ NetraLogger.debug("Checking prototype chain for invoke location:");
8265
8387
  let proto = LanggraphClass?.prototype;
8266
8388
  while (proto) {
8267
8389
  const hasOwn = Object.getOwnPropertyNames(proto).includes("invoke");
8268
- Logger.debug(` ${proto.constructor?.name}: hasOwnProperty('invoke')=${hasOwn}`);
8390
+ NetraLogger.debug(` ${proto.constructor?.name}: hasOwnProperty('invoke')=${hasOwn}`);
8269
8391
  if (hasOwn) {
8270
- Logger.debug(` -> invoke is defined on: ${proto.constructor?.name}`);
8392
+ NetraLogger.debug(` -> invoke is defined on: ${proto.constructor?.name}`);
8271
8393
  break;
8272
8394
  }
8273
8395
  proto = Object.getPrototypeOf(proto);
8274
8396
  }
8275
8397
  return LanggraphClass;
8276
8398
  } catch (e) {
8277
- Logger.error("Failed to resolve LangGraph:", e);
8399
+ NetraLogger.error("Failed to resolve LangGraph:", e);
8278
8400
  return null;
8279
8401
  }
8280
8402
  }
@@ -8290,23 +8412,23 @@ var NetraLanggraphInstrumentor = class {
8290
8412
  }
8291
8413
  async instrument(options = {}) {
8292
8414
  if (isInstrumented3) {
8293
- Logger.warn("Langgraph is already instrumented");
8415
+ NetraLogger.warn("Langgraph is already instrumented");
8294
8416
  return this;
8295
8417
  }
8296
8418
  const Langgraph = await resolveLanggraph();
8297
8419
  if (!Langgraph) {
8298
- Logger.warn("LangGraph class not found, skipping instrumentation");
8420
+ NetraLogger.warn("LangGraph class not found, skipping instrumentation");
8299
8421
  return this;
8300
8422
  }
8301
8423
  if (!await loadLanggraphCallbackHandler()) {
8302
- Logger.warn("@langchain/core not found, skipping LangGraph instrumentation");
8424
+ NetraLogger.warn("@langchain/core not found, skipping LangGraph instrumentation");
8303
8425
  return this;
8304
8426
  }
8305
8427
  try {
8306
8428
  this.tracerProvider = options.tracerProvider;
8307
8429
  this.tracer = this.tracerProvider ? this.tracerProvider.getTracer(INSTRUMENTATION_NAME3, __version__5) : trace.getTracer(INSTRUMENTATION_NAME3, __version__5);
8308
8430
  } catch (error) {
8309
- Logger.error(`Failed to initialize tracer: ${error}`);
8431
+ NetraLogger.error(`Failed to initialize tracer: ${error}`);
8310
8432
  return this;
8311
8433
  }
8312
8434
  this._instrumentInvoke(Langgraph);
@@ -8316,7 +8438,7 @@ var NetraLanggraphInstrumentor = class {
8316
8438
  }
8317
8439
  async uninstrument() {
8318
8440
  if (!isInstrumented3) {
8319
- Logger.warn("LangGraph is not instrumented");
8441
+ NetraLogger.warn("LangGraph is not instrumented");
8320
8442
  return;
8321
8443
  }
8322
8444
  const Langgraph = await resolveLanggraph();
@@ -8336,17 +8458,17 @@ var NetraLanggraphInstrumentor = class {
8336
8458
  targetProto = Object.getPrototypeOf(targetProto);
8337
8459
  }
8338
8460
  if (!targetProto?.invoke) {
8339
- Logger.error("Failed to find langgraph invoke function to instrument");
8461
+ NetraLogger.error("Failed to find langgraph invoke function to instrument");
8340
8462
  return;
8341
8463
  }
8342
- Logger.debug(`Found invoke on prototype: ${targetProto.constructor?.name}`);
8464
+ NetraLogger.debug(`Found invoke on prototype: ${targetProto.constructor?.name}`);
8343
8465
  const originalInvoke = targetProto.invoke;
8344
8466
  originalMethods2.set("langgraph.graph.invoke", originalInvoke);
8345
8467
  originalMethods2.set("langgraph.graph.invoke.proto", targetProto);
8346
8468
  const tracer = this.tracer;
8347
8469
  const wrapper = new LanggraphWrapper(tracer);
8348
8470
  const patchedInvoke = async function(input, config, ...rest) {
8349
- Logger.debug("LangGraph invoke intercepted!");
8471
+ NetraLogger.debug("LangGraph invoke intercepted!");
8350
8472
  return await wrapper.invoke(
8351
8473
  originalInvoke,
8352
8474
  this,
@@ -8357,10 +8479,10 @@ var NetraLanggraphInstrumentor = class {
8357
8479
  };
8358
8480
  patchedInvoke.__netra_patched = true;
8359
8481
  targetProto.invoke = patchedInvoke;
8360
- Logger.debug(`Successfully instrumented LangGraph invoke method on ${targetProto.constructor?.name}`);
8361
- Logger.debug(`Patched Pregel class identity:`, targetProto.constructor);
8482
+ NetraLogger.debug(`Successfully instrumented LangGraph invoke method on ${targetProto.constructor?.name}`);
8483
+ NetraLogger.debug(`Patched Pregel class identity:`, targetProto.constructor);
8362
8484
  } catch (error) {
8363
- Logger.error(`Failed to instrument langgraph invoke: ${error}`);
8485
+ NetraLogger.error(`Failed to instrument langgraph invoke: ${error}`);
8364
8486
  }
8365
8487
  }
8366
8488
  _instrumentStream(Langgraph) {
@@ -8371,17 +8493,17 @@ var NetraLanggraphInstrumentor = class {
8371
8493
  targetProto = Object.getPrototypeOf(targetProto);
8372
8494
  }
8373
8495
  if (!targetProto?.stream) {
8374
- Logger.error("Failed to find langgraph stream function to instrument");
8496
+ NetraLogger.error("Failed to find langgraph stream function to instrument");
8375
8497
  return;
8376
8498
  }
8377
- Logger.debug(`Found stream on prototype: ${targetProto.constructor?.name}`);
8499
+ NetraLogger.debug(`Found stream on prototype: ${targetProto.constructor?.name}`);
8378
8500
  const originalStream = targetProto.stream;
8379
8501
  originalMethods2.set("langgraph.graph.stream", originalStream);
8380
8502
  originalMethods2.set("langgraph.graph.stream.proto", targetProto);
8381
8503
  const tracer = this.tracer;
8382
8504
  const wrapper = new LanggraphWrapper(tracer);
8383
8505
  targetProto.stream = async function(input, config, ...rest) {
8384
- Logger.debug("LangGraph stream intercepted!");
8506
+ NetraLogger.debug("LangGraph stream intercepted!");
8385
8507
  return await wrapper.stream(
8386
8508
  originalStream,
8387
8509
  this,
@@ -8390,9 +8512,9 @@ var NetraLanggraphInstrumentor = class {
8390
8512
  ...rest
8391
8513
  );
8392
8514
  };
8393
- Logger.debug(`Successfully instrumented LangGraph stream method on ${targetProto.constructor?.name}`);
8515
+ NetraLogger.debug(`Successfully instrumented LangGraph stream method on ${targetProto.constructor?.name}`);
8394
8516
  } catch (error) {
8395
- Logger.error(`Failed to instrument langgraph stream: ${error}`);
8517
+ NetraLogger.error(`Failed to instrument langgraph stream: ${error}`);
8396
8518
  }
8397
8519
  }
8398
8520
  _uninstrumentInvoke(Langgraph) {
@@ -8403,7 +8525,7 @@ var NetraLanggraphInstrumentor = class {
8403
8525
  targetProto.invoke = originalInvoke;
8404
8526
  }
8405
8527
  } catch (error) {
8406
- Logger.error(`Failed to uninstrument langgraph invoke: ${error}`);
8528
+ NetraLogger.error(`Failed to uninstrument langgraph invoke: ${error}`);
8407
8529
  }
8408
8530
  return;
8409
8531
  }
@@ -8415,7 +8537,7 @@ var NetraLanggraphInstrumentor = class {
8415
8537
  targetProto.stream = originalStream;
8416
8538
  }
8417
8539
  } catch (error) {
8418
- Logger.error(`Failed to uninstrument langgraph stream: ${error}`);
8540
+ NetraLogger.error(`Failed to uninstrument langgraph stream: ${error}`);
8419
8541
  }
8420
8542
  return;
8421
8543
  }
@@ -8488,7 +8610,7 @@ function mistralWrapper(tracer, spanName, requestType) {
8488
8610
  span2.end();
8489
8611
  return value;
8490
8612
  } catch (error) {
8491
- Logger.error("netra.instrumentation.mistralai:", error);
8613
+ NetraLogger.error("netra.instrumentation.mistralai:", error);
8492
8614
  span2.setStatus({
8493
8615
  code: SpanStatusCode.ERROR,
8494
8616
  message: error instanceof Error ? error.message : String(error)
@@ -8509,7 +8631,7 @@ function mistralWrapper(tracer, spanName, requestType) {
8509
8631
  span2.end();
8510
8632
  return response;
8511
8633
  } catch (error) {
8512
- Logger.error("netra.instrumentation.mistralai:", error);
8634
+ NetraLogger.error("netra.instrumentation.mistralai:", error);
8513
8635
  span2.setStatus({
8514
8636
  code: SpanStatusCode.ERROR,
8515
8637
  message: error instanceof Error ? error.message : String(error)
@@ -8553,7 +8675,7 @@ function mistralStreamWrapper(tracer, spanName, requestType) {
8553
8675
  }
8554
8676
  return new StreamingWrapper2(span2, stream, startTime, kwargs);
8555
8677
  } catch (error) {
8556
- Logger.error("netra.instrumentation.mistralai:", error);
8678
+ NetraLogger.error("netra.instrumentation.mistralai:", error);
8557
8679
  span2.setStatus({
8558
8680
  code: SpanStatusCode.ERROR,
8559
8681
  message: error instanceof Error ? error.message : String(error)
@@ -8569,7 +8691,7 @@ function mistralStreamWrapper(tracer, spanName, requestType) {
8569
8691
  }
8570
8692
  return new StreamingWrapper2(span2, response, startTime, kwargs);
8571
8693
  } catch (error) {
8572
- Logger.error("netra.instrumentation.mistralai:", error);
8694
+ NetraLogger.error("netra.instrumentation.mistralai:", error);
8573
8695
  span2.setStatus({
8574
8696
  code: SpanStatusCode.ERROR,
8575
8697
  message: error instanceof Error ? error.message : String(error)
@@ -8893,7 +9015,7 @@ async function resolveMistralAsync() {
8893
9015
  mistralModule.Mistral || mistralModule.default || mistralModule
8894
9016
  );
8895
9017
  } catch {
8896
- Logger.warn("Failed to resolve MistralAI ESM module");
9018
+ NetraLogger.warn("Failed to resolve MistralAI ESM module");
8897
9019
  }
8898
9020
  try {
8899
9021
  const req = createRequire(import.meta.url);
@@ -8903,7 +9025,7 @@ async function resolveMistralAsync() {
8903
9025
  mistralClasses.push(cjsClass);
8904
9026
  }
8905
9027
  } catch {
8906
- Logger.warn("Failed to resolve MistralAI CJS module");
9028
+ NetraLogger.warn("Failed to resolve MistralAI CJS module");
8907
9029
  }
8908
9030
  return mistralClasses;
8909
9031
  }
@@ -8927,7 +9049,7 @@ var NetraMistralAIInstrumentor = class {
8927
9049
  */
8928
9050
  async instrumentAsync(options = {}) {
8929
9051
  if (isInstrumented4) {
8930
- Logger.warn("MistralAI is already instrumented");
9052
+ NetraLogger.warn("MistralAI is already instrumented");
8931
9053
  return this;
8932
9054
  }
8933
9055
  const classes = await resolveMistralAsync();
@@ -8945,7 +9067,7 @@ var NetraMistralAIInstrumentor = class {
8945
9067
  this.tracer = trace.getTracer(INSTRUMENTATION_NAME4, __version__6);
8946
9068
  }
8947
9069
  } catch (error) {
8948
- Logger.error(`Failed to initialize tracer: ${error}`);
9070
+ NetraLogger.error(`Failed to initialize tracer: ${error}`);
8949
9071
  return this;
8950
9072
  }
8951
9073
  let didPatch = false;
@@ -8959,7 +9081,7 @@ var NetraMistralAIInstrumentor = class {
8959
9081
  }
8960
9082
  });
8961
9083
  if (!didPatch) {
8962
- Logger.warn(
9084
+ NetraLogger.warn(
8963
9085
  "MistralAI instrumentation initialized but no methods were patched. Is '@mistralai/mistralai' installed and compatible?"
8964
9086
  );
8965
9087
  return this;
@@ -8973,13 +9095,13 @@ var NetraMistralAIInstrumentor = class {
8973
9095
  */
8974
9096
  instrument(options = {}) {
8975
9097
  if (isInstrumented4) {
8976
- Logger.warn("MistralAI is already instrumented");
9098
+ NetraLogger.warn("MistralAI is already instrumented");
8977
9099
  return this;
8978
9100
  }
8979
9101
  const classes = resolveMistral();
8980
9102
  if (classes.length === 0) {
8981
9103
  this.instrumentAsync(options).catch((e) => {
8982
- Logger.error("Failed to instrument MistralAI:", e);
9104
+ NetraLogger.error("Failed to instrument MistralAI:", e);
8983
9105
  });
8984
9106
  return this;
8985
9107
  }
@@ -8994,7 +9116,7 @@ var NetraMistralAIInstrumentor = class {
8994
9116
  this.tracer = trace.getTracer(INSTRUMENTATION_NAME4, __version__6);
8995
9117
  }
8996
9118
  } catch (error) {
8997
- Logger.error(`Failed to initialize tracer: ${error}`);
9119
+ NetraLogger.error(`Failed to initialize tracer: ${error}`);
8998
9120
  return this;
8999
9121
  }
9000
9122
  let didPatch = false;
@@ -9008,7 +9130,7 @@ var NetraMistralAIInstrumentor = class {
9008
9130
  }
9009
9131
  });
9010
9132
  if (!didPatch) {
9011
- Logger.warn(
9133
+ NetraLogger.warn(
9012
9134
  "MistralAI instrumentation initialized but no methods were patched. Is '@mistralai/mistralai' installed and compatible?"
9013
9135
  );
9014
9136
  return this;
@@ -9021,7 +9143,7 @@ var NetraMistralAIInstrumentor = class {
9021
9143
  */
9022
9144
  uninstrument() {
9023
9145
  if (!isInstrumented4) {
9024
- Logger.warn("MistralAI is not instrumented");
9146
+ NetraLogger.warn("MistralAI is not instrumented");
9025
9147
  return;
9026
9148
  }
9027
9149
  const classes = resolveMistral();
@@ -9111,7 +9233,7 @@ var NetraMistralAIInstrumentor = class {
9111
9233
  }
9112
9234
  return didPatch;
9113
9235
  } catch (error) {
9114
- Logger.error("Failed to instrument MistralAI chat:", error);
9236
+ NetraLogger.error("Failed to instrument MistralAI chat:", error);
9115
9237
  return false;
9116
9238
  }
9117
9239
  }
@@ -9139,7 +9261,7 @@ var NetraMistralAIInstrumentor = class {
9139
9261
  }
9140
9262
  return didPatch;
9141
9263
  } catch (error) {
9142
- Logger.error("Failed to instrument MistralAI embeddings:", error);
9264
+ NetraLogger.error("Failed to instrument MistralAI embeddings:", error);
9143
9265
  return false;
9144
9266
  }
9145
9267
  }
@@ -9184,7 +9306,7 @@ var NetraMistralAIInstrumentor = class {
9184
9306
  }
9185
9307
  return didPatch;
9186
9308
  } catch (error) {
9187
- Logger.error("Failed to instrument MistralAI FIM:", error);
9309
+ NetraLogger.error("Failed to instrument MistralAI FIM:", error);
9188
9310
  return false;
9189
9311
  }
9190
9312
  }
@@ -9229,7 +9351,7 @@ var NetraMistralAIInstrumentor = class {
9229
9351
  }
9230
9352
  return didPatch;
9231
9353
  } catch (error) {
9232
- Logger.error("Failed to instrument MistralAI agents:", error);
9354
+ NetraLogger.error("Failed to instrument MistralAI agents:", error);
9233
9355
  return false;
9234
9356
  }
9235
9357
  }
@@ -9245,7 +9367,7 @@ var NetraMistralAIInstrumentor = class {
9245
9367
  ChatClass.prototype.stream = originalStream;
9246
9368
  }
9247
9369
  } catch (error) {
9248
- Logger.error(`Failed to uninstrument MistralAI chat: ${error}`);
9370
+ NetraLogger.error(`Failed to uninstrument MistralAI chat: ${error}`);
9249
9371
  }
9250
9372
  }
9251
9373
  _uninstrumentEmbeddings(Mistral, index) {
@@ -9256,7 +9378,7 @@ var NetraMistralAIInstrumentor = class {
9256
9378
  EmbeddingsClass.prototype.create = originalCreate;
9257
9379
  }
9258
9380
  } catch (error) {
9259
- Logger.error(`Failed to uninstrument MistralAI embeddings: ${error}`);
9381
+ NetraLogger.error(`Failed to uninstrument MistralAI embeddings: ${error}`);
9260
9382
  }
9261
9383
  }
9262
9384
  _uninstrumentFIM(Mistral, index) {
@@ -9271,7 +9393,7 @@ var NetraMistralAIInstrumentor = class {
9271
9393
  FimClass.prototype.stream = originalStream;
9272
9394
  }
9273
9395
  } catch (error) {
9274
- Logger.error(`Failed to uninstrument MistralAI FIM: ${error}`);
9396
+ NetraLogger.error(`Failed to uninstrument MistralAI FIM: ${error}`);
9275
9397
  }
9276
9398
  }
9277
9399
  _uninstrumentAgents(Mistral, index) {
@@ -9286,7 +9408,7 @@ var NetraMistralAIInstrumentor = class {
9286
9408
  AgentsClass.prototype.stream = originalStream;
9287
9409
  }
9288
9410
  } catch (error) {
9289
- Logger.error(`Failed to uninstrument MistralAI agents: ${error}`);
9411
+ NetraLogger.error(`Failed to uninstrument MistralAI agents: ${error}`);
9290
9412
  }
9291
9413
  }
9292
9414
  };
@@ -9579,7 +9701,7 @@ async function resolveOpenAI() {
9579
9701
  const mod = await import('openai');
9580
9702
  openAIClasses.push(mod.OpenAI ?? mod.default ?? mod);
9581
9703
  } catch {
9582
- Logger.warn("Failed to resolve OpenAI ESM module");
9704
+ NetraLogger.warn("Failed to resolve OpenAI ESM module");
9583
9705
  }
9584
9706
  try {
9585
9707
  const req = createRequire(import.meta.url);
@@ -9589,7 +9711,7 @@ async function resolveOpenAI() {
9589
9711
  openAIClasses.push(cjsClass);
9590
9712
  }
9591
9713
  } catch {
9592
- Logger.warn("Failed to resolve OpenAI CJS module");
9714
+ NetraLogger.warn("Failed to resolve OpenAI CJS module");
9593
9715
  }
9594
9716
  return openAIClasses;
9595
9717
  }
@@ -9624,14 +9746,14 @@ var _NetraOpenAIInstrumentor = class _NetraOpenAIInstrumentor {
9624
9746
  }
9625
9747
  async instrument(options = {}) {
9626
9748
  if (this.isInstrumented()) {
9627
- Logger.warn("OpenAI is already instrumented");
9749
+ NetraLogger.warn("OpenAI is already instrumented");
9628
9750
  return this;
9629
9751
  }
9630
9752
  try {
9631
9753
  const provider = options.tracerProvider;
9632
9754
  this.tracer = provider ? provider.getTracer(INSTRUMENTATION_NAME5, __version__7) : trace.getTracer(INSTRUMENTATION_NAME5, __version__7);
9633
9755
  } catch (error) {
9634
- Logger.error(`Failed to initialize tracer: ${error}`);
9756
+ NetraLogger.error(`Failed to initialize tracer: ${error}`);
9635
9757
  return this;
9636
9758
  }
9637
9759
  const openAIClasses2 = await resolveOpenAI();
@@ -9645,7 +9767,7 @@ var _NetraOpenAIInstrumentor = class _NetraOpenAIInstrumentor {
9645
9767
  }
9646
9768
  async uninstrument() {
9647
9769
  if (!this.isInstrumented()) {
9648
- Logger.warn("OpenAI is not instrumented");
9770
+ NetraLogger.warn("OpenAI is not instrumented");
9649
9771
  return;
9650
9772
  }
9651
9773
  const openAIClasses2 = await resolveOpenAI();
@@ -9663,7 +9785,7 @@ var _NetraOpenAIInstrumentor = class _NetraOpenAIInstrumentor {
9663
9785
  const proto = target.getPrototype(openAIClass);
9664
9786
  if (!proto?.create) {
9665
9787
  if (!target.optional) {
9666
- Logger.error(`Failed to find OpenAI method to patch: ${target.key}`);
9788
+ NetraLogger.error(`Failed to find OpenAI method to patch: ${target.key}`);
9667
9789
  }
9668
9790
  return;
9669
9791
  }
@@ -9681,7 +9803,7 @@ var _NetraOpenAIInstrumentor = class _NetraOpenAIInstrumentor {
9681
9803
  );
9682
9804
  };
9683
9805
  } catch (error) {
9684
- Logger.error(`Failed to patch ${target.key}: ${error}`);
9806
+ NetraLogger.error(`Failed to patch ${target.key}: ${error}`);
9685
9807
  }
9686
9808
  }
9687
9809
  unpatch(openAIClass, target, index) {
@@ -9692,7 +9814,7 @@ var _NetraOpenAIInstrumentor = class _NetraOpenAIInstrumentor {
9692
9814
  proto.create = original;
9693
9815
  }
9694
9816
  } catch (error) {
9695
- Logger.error(`Failed to unpatch ${target.key}: ${error}`);
9817
+ NetraLogger.error(`Failed to unpatch ${target.key}: ${error}`);
9696
9818
  }
9697
9819
  }
9698
9820
  };
@@ -9884,7 +10006,7 @@ function setResponseAttributes8(span2, agentSpan, systemName) {
9884
10006
  span2.setAttribute(GEN_AI_RESPONSE_ID, data.response_id);
9885
10007
  }
9886
10008
  if (!data._response && !data._input) {
9887
- Logger.debug(
10009
+ NetraLogger.debug(
9888
10010
  "NetraAgentsTracingProcessor: response span has no _response/_input data;",
9889
10011
  "the @openai/agents SDK may have changed its internal fields"
9890
10012
  );
@@ -10189,7 +10311,7 @@ var _NetraAgentsTracingProcessor = class _NetraAgentsTracingProcessor {
10189
10311
  } catch {
10190
10312
  }
10191
10313
  this._otelSpans.delete(oldest);
10192
- Logger.debug("NetraAgentsTracingProcessor: evicted span due to MAX_TRACKED_SPANS limit");
10314
+ NetraLogger.debug("NetraAgentsTracingProcessor: evicted span due to MAX_TRACKED_SPANS limit");
10193
10315
  }
10194
10316
  }
10195
10317
  _evictOldestTrace() {
@@ -10220,7 +10342,7 @@ var _NetraAgentsTracingProcessor = class _NetraAgentsTracingProcessor {
10220
10342
  }
10221
10343
  this._traceSpans.delete(oldest);
10222
10344
  }
10223
- Logger.debug("NetraAgentsTracingProcessor: evicted root trace due to MAX_TRACKED_TRACES limit");
10345
+ NetraLogger.debug("NetraAgentsTracingProcessor: evicted root trace due to MAX_TRACKED_TRACES limit");
10224
10346
  }
10225
10347
  }
10226
10348
  onTraceStart(agentTrace) {
@@ -10413,7 +10535,7 @@ async function resolveAgentsModule() {
10413
10535
  cachedAgentsModule = mod;
10414
10536
  return cachedAgentsModule;
10415
10537
  } catch {
10416
- Logger.debug("ESM resolution of @openai/agents failed, trying CJS fallback");
10538
+ NetraLogger.debug("ESM resolution of @openai/agents failed, trying CJS fallback");
10417
10539
  }
10418
10540
  try {
10419
10541
  const req = createRequire(import.meta.url);
@@ -10421,7 +10543,7 @@ async function resolveAgentsModule() {
10421
10543
  cachedAgentsModule = mod;
10422
10544
  return cachedAgentsModule;
10423
10545
  } catch {
10424
- Logger.debug("CJS resolution of @openai/agents also failed");
10546
+ NetraLogger.debug("CJS resolution of @openai/agents also failed");
10425
10547
  }
10426
10548
  return null;
10427
10549
  }
@@ -10438,19 +10560,19 @@ var NetraOpenAIAgentsInstrumentor = class {
10438
10560
  */
10439
10561
  async instrument(options = {}) {
10440
10562
  if (isInstrumented5) {
10441
- Logger.warn("OpenAI Agents SDK is already instrumented");
10563
+ NetraLogger.warn("OpenAI Agents SDK is already instrumented");
10442
10564
  return this;
10443
10565
  }
10444
10566
  try {
10445
10567
  const provider = options.tracerProvider;
10446
10568
  activeTracer = provider ? provider.getTracer(INSTRUMENTATION_NAME6, __version__8) : trace.getTracer(INSTRUMENTATION_NAME6, __version__8);
10447
10569
  } catch (error) {
10448
- Logger.error(`Failed to initialize tracer for OpenAI Agents: ${error}`);
10570
+ NetraLogger.error(`Failed to initialize tracer for OpenAI Agents: ${error}`);
10449
10571
  return this;
10450
10572
  }
10451
10573
  const agentsModule = await resolveAgentsModule();
10452
10574
  if (!agentsModule) {
10453
- Logger.warn(
10575
+ NetraLogger.warn(
10454
10576
  "OpenAI Agents SDK (@openai/agents) not found.",
10455
10577
  "Install it to enable automatic agent tracing."
10456
10578
  );
@@ -10477,26 +10599,26 @@ var NetraOpenAIAgentsInstrumentor = class {
10477
10599
  }
10478
10600
  agentsModule.setTraceProcessors([activeProcessor]);
10479
10601
  didReplaceProcessors = true;
10480
- Logger.debug("OpenAI Agents native tracing disabled \u2014 traces will only be sent to Netra.");
10602
+ NetraLogger.debug("OpenAI Agents native tracing disabled \u2014 traces will only be sent to Netra.");
10481
10603
  break;
10482
10604
  case "append":
10483
10605
  if (canAdd) {
10484
10606
  agentsModule.addTraceProcessor(activeProcessor);
10485
10607
  } else {
10486
- Logger.warn("OpenAI Agents SDK does not expose addTraceProcessor or setTraceProcessors.");
10608
+ NetraLogger.warn("OpenAI Agents SDK does not expose addTraceProcessor or setTraceProcessors.");
10487
10609
  activeProcessor = null;
10488
10610
  activeTracer = null;
10489
10611
  return this;
10490
10612
  }
10491
10613
  if (mode === "netra") {
10492
- Logger.warn(
10614
+ NetraLogger.warn(
10493
10615
  "Cannot exclusively replace native trace processors in this @openai/agents version.",
10494
10616
  "Traces may still be sent to OpenAI."
10495
10617
  );
10496
10618
  }
10497
10619
  break;
10498
10620
  case "skip":
10499
- Logger.warn(
10621
+ NetraLogger.warn(
10500
10622
  'nativeTracing is "netra-strict" but the installed @openai/agents version',
10501
10623
  "does not support processor replacement. Skipping instrumentation."
10502
10624
  );
@@ -10505,7 +10627,7 @@ var NetraOpenAIAgentsInstrumentor = class {
10505
10627
  return this;
10506
10628
  }
10507
10629
  } catch (error) {
10508
- Logger.warn("Failed to register trace processor with @openai/agents:", error);
10630
+ NetraLogger.warn("Failed to register trace processor with @openai/agents:", error);
10509
10631
  activeProcessor = null;
10510
10632
  activeTracer = null;
10511
10633
  return this;
@@ -10515,7 +10637,7 @@ var NetraOpenAIAgentsInstrumentor = class {
10515
10637
  }
10516
10638
  uninstrument() {
10517
10639
  if (!isInstrumented5) {
10518
- Logger.warn("OpenAI Agents SDK is not instrumented");
10640
+ NetraLogger.warn("OpenAI Agents SDK is not instrumented");
10519
10641
  return;
10520
10642
  }
10521
10643
  if (activeProcessor) {
@@ -10526,13 +10648,13 @@ var NetraOpenAIAgentsInstrumentor = class {
10526
10648
  try {
10527
10649
  if (originalProcessors && typeof cachedAgentsModule.setTraceProcessors === "function") {
10528
10650
  cachedAgentsModule.setTraceProcessors(originalProcessors);
10529
- Logger.debug("Restored original OpenAI Agents trace processors");
10651
+ NetraLogger.debug("Restored original OpenAI Agents trace processors");
10530
10652
  } else if (typeof cachedAgentsModule.setDefaultOpenAITracingExporter === "function") {
10531
10653
  cachedAgentsModule.setDefaultOpenAITracingExporter();
10532
- Logger.debug("Restored default OpenAI Agents tracing exporter");
10654
+ NetraLogger.debug("Restored default OpenAI Agents tracing exporter");
10533
10655
  }
10534
10656
  } catch (error) {
10535
- Logger.debug("Failed to restore original trace processors:", error);
10657
+ NetraLogger.debug("Failed to restore original trace processors:", error);
10536
10658
  }
10537
10659
  }
10538
10660
  originalProcessors = null;
@@ -10589,7 +10711,7 @@ function setQueryAttributes(span2, sql, parameters, operation) {
10589
10711
  try {
10590
10712
  span2.setAttribute("db.statement.parameters", JSON.stringify(parameters));
10591
10713
  } catch (e) {
10592
- Logger.log(e);
10714
+ NetraLogger.log(e);
10593
10715
  }
10594
10716
  }
10595
10717
  }
@@ -10615,7 +10737,7 @@ function extractDatabaseName(dataSource) {
10615
10737
  const dbName = url.pathname?.replace(/^\//, "");
10616
10738
  if (dbName) return dbName;
10617
10739
  } catch (e) {
10618
- Logger.log(e);
10740
+ NetraLogger.log(e);
10619
10741
  }
10620
10742
  }
10621
10743
  }
@@ -10808,14 +10930,14 @@ var NetraTypeORMInstrumentor = class {
10808
10930
  }
10809
10931
  async instrument(options = {}) {
10810
10932
  if (isInstrumented6) {
10811
- Logger.warn("TypeORM is already instrumented");
10933
+ NetraLogger.warn("TypeORM is already instrumented");
10812
10934
  return this;
10813
10935
  }
10814
10936
  try {
10815
10937
  this.tracerProvider = options.tracerProvider;
10816
10938
  this.tracer = this.tracerProvider ? this.tracerProvider.getTracer(INSTRUMENTATION_NAME7, __version__9) : trace.getTracer(INSTRUMENTATION_NAME7, __version__9);
10817
10939
  } catch (error) {
10818
- Logger.error(`Failed to initialize tracer: ${error}`);
10940
+ NetraLogger.error(`Failed to initialize tracer: ${error}`);
10819
10941
  return this;
10820
10942
  }
10821
10943
  await this._instrumentDataSource();
@@ -10826,7 +10948,7 @@ var NetraTypeORMInstrumentor = class {
10826
10948
  }
10827
10949
  uninstrument() {
10828
10950
  if (!isInstrumented6) {
10829
- Logger.warn("TypeORM is not instrumented");
10951
+ NetraLogger.warn("TypeORM is not instrumented");
10830
10952
  return;
10831
10953
  }
10832
10954
  this._uninstrumentDataSource().catch(() => {
@@ -10848,7 +10970,7 @@ var NetraTypeORMInstrumentor = class {
10848
10970
  const DataSource = typeorm.DataSource || typeorm.default?.DataSource;
10849
10971
  if (!DataSource) {
10850
10972
  if (this.tracerProvider) {
10851
- Logger.debug("TypeORM DataSource not found, skipping instrumentation");
10973
+ NetraLogger.debug("TypeORM DataSource not found, skipping instrumentation");
10852
10974
  }
10853
10975
  return;
10854
10976
  }
@@ -10863,7 +10985,7 @@ var NetraTypeORMInstrumentor = class {
10863
10985
  };
10864
10986
  }
10865
10987
  } catch (error) {
10866
- Logger.debug(`Failed to instrument DataSource: ${error}`);
10988
+ NetraLogger.debug(`Failed to instrument DataSource: ${error}`);
10867
10989
  }
10868
10990
  }
10869
10991
  async _instrumentEntityManager() {
@@ -10873,7 +10995,7 @@ var NetraTypeORMInstrumentor = class {
10873
10995
  const EntityManager = typeorm.EntityManager || typeorm.default?.EntityManager;
10874
10996
  if (!EntityManager) {
10875
10997
  if (this.tracerProvider) {
10876
- Logger.debug("TypeORM EntityManager not found, skipping instrumentation");
10998
+ NetraLogger.debug("TypeORM EntityManager not found, skipping instrumentation");
10877
10999
  }
10878
11000
  return;
10879
11001
  }
@@ -10888,7 +11010,7 @@ var NetraTypeORMInstrumentor = class {
10888
11010
  };
10889
11011
  }
10890
11012
  } catch (error) {
10891
- Logger.debug(`Failed to instrument EntityManager: ${error}`);
11013
+ NetraLogger.debug(`Failed to instrument EntityManager: ${error}`);
10892
11014
  }
10893
11015
  }
10894
11016
  async _instrumentRepository() {
@@ -10898,7 +11020,7 @@ var NetraTypeORMInstrumentor = class {
10898
11020
  const Repository = typeorm.Repository || typeorm.default?.Repository;
10899
11021
  if (!Repository) {
10900
11022
  if (this.tracerProvider) {
10901
- Logger.debug("TypeORM Repository not found, skipping instrumentation");
11023
+ NetraLogger.debug("TypeORM Repository not found, skipping instrumentation");
10902
11024
  }
10903
11025
  return;
10904
11026
  }
@@ -10913,7 +11035,7 @@ var NetraTypeORMInstrumentor = class {
10913
11035
  };
10914
11036
  }
10915
11037
  } catch (error) {
10916
- Logger.debug(`Failed to instrument Repository: ${error}`);
11038
+ NetraLogger.debug(`Failed to instrument Repository: ${error}`);
10917
11039
  }
10918
11040
  }
10919
11041
  async _uninstrumentDataSource() {
@@ -10925,7 +11047,7 @@ var NetraTypeORMInstrumentor = class {
10925
11047
  DataSource.prototype.query = originalQuery;
10926
11048
  }
10927
11049
  } catch (error) {
10928
- Logger.debug(`Failed to uninstrument DataSource: ${error}`);
11050
+ NetraLogger.debug(`Failed to uninstrument DataSource: ${error}`);
10929
11051
  }
10930
11052
  }
10931
11053
  async _uninstrumentEntityManager() {
@@ -10937,7 +11059,7 @@ var NetraTypeORMInstrumentor = class {
10937
11059
  EntityManager.prototype.query = originalQuery;
10938
11060
  }
10939
11061
  } catch (error) {
10940
- Logger.debug(`Failed to uninstrument EntityManager: ${error}`);
11062
+ NetraLogger.debug(`Failed to uninstrument EntityManager: ${error}`);
10941
11063
  }
10942
11064
  }
10943
11065
  async _uninstrumentRepository() {
@@ -10949,7 +11071,7 @@ var NetraTypeORMInstrumentor = class {
10949
11071
  Repository.prototype.query = originalQuery;
10950
11072
  }
10951
11073
  } catch (error) {
10952
- Logger.debug(`Failed to uninstrument Repository: ${error}`);
11074
+ NetraLogger.debug(`Failed to uninstrument Repository: ${error}`);
10953
11075
  }
10954
11076
  }
10955
11077
  };
@@ -10962,7 +11084,8 @@ function setTrialBlocked(blocked) {
10962
11084
  {
10963
11085
  if (!trialBlockedAt) {
10964
11086
  trialBlockedAt = Date.now();
10965
- Logger.warn(
11087
+ NetraLogger.notice(
11088
+ "warn",
10966
11089
  `Trial/quota exhausted: blocking span export for ${Config.TRIAL_BLOCK_DURATION_SECONDS}s`
10967
11090
  );
10968
11091
  }
@@ -11456,7 +11579,8 @@ var TrialAwareOTLPExporter = class {
11456
11579
  if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
11457
11580
  resultCallback({ code: ExportResultCode.SUCCESS });
11458
11581
  } else {
11459
- Logger.warn(
11582
+ NetraLogger.notice(
11583
+ "warn",
11460
11584
  formatExportFailure(
11461
11585
  res.statusCode,
11462
11586
  res.statusMessage,
@@ -11474,7 +11598,8 @@ var TrialAwareOTLPExporter = class {
11474
11598
  });
11475
11599
  });
11476
11600
  req.on("error", (err) => {
11477
- Logger.warn(
11601
+ NetraLogger.notice(
11602
+ "warn",
11478
11603
  `Span export failed: ${err.message}. Dropped a batch of ${spans.length} spans (${requestBytes} bytes).`
11479
11604
  );
11480
11605
  resultCallback({ code: ExportResultCode.FAILED, error: err });
@@ -11532,7 +11657,7 @@ function patchTraceloopLangchainCallbackHandler() {
11532
11657
  const parentRunId = args[3];
11533
11658
  const parentSpan = parentRunId ? this?.spans?.get(parentRunId)?.span : void 0;
11534
11659
  const active = trace.getSpan(context.active());
11535
- Logger.debug(
11660
+ NetraLogger.debug(
11536
11661
  `Traceloop ${methodName}: runId=${args[2]} parentRunId=${parentRunId} parentSpan=${parentSpan ? "yes" : "no"} activeSpanId=${active?.spanContext().spanId}`
11537
11662
  );
11538
11663
  const ctx = parentSpan ? trace.setSpan(context.active(), parentSpan) : context.active();
@@ -11544,15 +11669,15 @@ function patchTraceloopLangchainCallbackHandler() {
11544
11669
  wrapWithParentContext("handleChatModelStart");
11545
11670
  wrapWithParentContext("handleToolStart");
11546
11671
  Handler.__netra_patched = true;
11547
- Logger.debug(`Patched TraceloopCallbackHandler for parent context (${sourceLabel}).`);
11672
+ NetraLogger.debug(`Patched TraceloopCallbackHandler for parent context (${sourceLabel}).`);
11548
11673
  };
11549
11674
  try {
11550
11675
  const mod = require3("@traceloop/instrumentation-langchain");
11551
- Logger.debug(`Loaded @traceloop/instrumentation-langchain via require from ${require3.resolve("@traceloop/instrumentation-langchain")}`);
11676
+ NetraLogger.debug(`Loaded @traceloop/instrumentation-langchain via require from ${require3.resolve("@traceloop/instrumentation-langchain")}`);
11552
11677
  applyPatch(mod, "require");
11553
11678
  return;
11554
11679
  } catch (e) {
11555
- Logger.debug("require() for traceloop langchain failed, falling back to import().");
11680
+ NetraLogger.debug("require() for traceloop langchain failed, falling back to import().");
11556
11681
  }
11557
11682
  import('@traceloop/instrumentation-langchain').then((mod) => {
11558
11683
  applyPatch(mod, "import");
@@ -11592,21 +11717,23 @@ function disableTraceloopLangchainCallbackHandler() {
11592
11717
  );
11593
11718
  };
11594
11719
  CallbackManager.__netra_disable_traceloop = true;
11595
- Logger.debug("Disabled Traceloop LangChain callback injection.");
11720
+ NetraLogger.debug("Disabled Traceloop LangChain callback injection.");
11596
11721
  } catch {
11597
11722
  }
11598
11723
  }
11724
+ var MISSING_ENDPOINT_NOTICE = "NETRA_OTLP_ENDPOINT is not set, so traces will NOT be sent to Netra (spans are printed to the console instead) and Netra API calls are disabled. Fix: set NETRA_OTLP_ENDPOINT to https://api.getnetra.ai/telemetry (or https://api.eu.getnetra.ai/telemetry for EU projects).";
11599
11725
  function resolveRootInstrumentNames(rootInstruments, blockInstruments) {
11600
11726
  const allSentinel = "__all__" /* ALL */;
11601
11727
  const rootHasAll = rootInstruments != null && rootInstruments.has(allSentinel);
11602
11728
  const blockHasAll = blockInstruments != null && blockInstruments.has(allSentinel);
11603
11729
  if (blockHasAll) {
11604
11730
  if (rootHasAll) {
11605
- Logger.error(
11731
+ NetraLogger.notice(
11732
+ "error",
11606
11733
  "Netra: rootInstruments=ALL is contradicted by blockInstruments=ALL; all root instrumentation is disabled."
11607
11734
  );
11608
11735
  } else {
11609
- Logger.warn(
11736
+ NetraLogger.warn(
11610
11737
  "Netra: blockInstruments contains ALL; all instrumentation will be disabled."
11611
11738
  );
11612
11739
  }
@@ -11736,12 +11863,12 @@ function initInstrumentations(config, instruments, blockInstruments, rootInstrum
11736
11863
  if (blockAll || blockInstruments.has("together" /* TOGETHER */)) instrumentModules.together = false;
11737
11864
  }
11738
11865
  config.setTraceloopEnv();
11739
- Logger.debug("Netra SDK Configuration:");
11740
- Logger.debug(` App Name: ${config.appName}`);
11741
- Logger.debug(` OTLP Endpoint: ${config.otlpEndpoint || "(default - localhost:3002)"}`);
11742
- Logger.debug(` API Key: ${config.apiKey ? "***" + config.apiKey.slice(-4) : "(not set)"}`);
11743
- Logger.debug(` Trace Content: ${config.traceContent}`);
11744
- Logger.debug(` Enable Scrubbing: ${config.enableScrubbing}`);
11866
+ NetraLogger.debug("Netra SDK Configuration:");
11867
+ NetraLogger.debug(` App Name: ${config.appName}`);
11868
+ NetraLogger.debug(` OTLP Endpoint: ${config.otlpEndpoint || "(default - localhost:3002)"}`);
11869
+ NetraLogger.debug(` API Key: ${config.apiKey ? "***" + config.apiKey.slice(-4) : "(not set)"}`);
11870
+ NetraLogger.debug(` Trace Content: ${config.traceContent}`);
11871
+ NetraLogger.debug(` Enable Scrubbing: ${config.enableScrubbing}`);
11745
11872
  const traceloopOptions = {
11746
11873
  appName: config.appName,
11747
11874
  apiKey: config.apiKey,
@@ -11754,6 +11881,7 @@ function initInstrumentations(config, instruments, blockInstruments, rootInstrum
11754
11881
  };
11755
11882
  let exporter;
11756
11883
  if (!traceloopOptions.baseUrl || traceloopOptions.baseUrl == void 0) {
11884
+ NetraLogger.notice("warn", MISSING_ENDPOINT_NOTICE);
11757
11885
  exporter = new ConsoleSpanExporter();
11758
11886
  } else {
11759
11887
  const formattedEndpoint = config.formatOtlpEndpoint();
@@ -11804,33 +11932,33 @@ async function initCustomInstrumentationsAsync(config, tracerProvider, customIns
11804
11932
  if (customInstrumentModules.mistral) {
11805
11933
  try {
11806
11934
  await mistralAIInstrumentor.instrumentAsync({ tracerProvider });
11807
- Logger.debug("Custom MistralAI instrumentation enabled");
11935
+ NetraLogger.debug("Custom MistralAI instrumentation enabled");
11808
11936
  } catch (e) {
11809
- Logger.debug("Failed to initialize custom MistralAI instrumentation:", e);
11937
+ NetraLogger.debug("Failed to initialize custom MistralAI instrumentation:", e);
11810
11938
  }
11811
11939
  }
11812
11940
  if (customInstrumentModules.openai) {
11813
11941
  try {
11814
11942
  await openAIInstrumentor.instrument({ tracerProvider });
11815
- Logger.debug("Custom OpenAI instrumentation enabled");
11943
+ NetraLogger.debug("Custom OpenAI instrumentation enabled");
11816
11944
  } catch (e) {
11817
- Logger.debug("Failed to initialize custom OpenAI instrumentation:", e);
11945
+ NetraLogger.debug("Failed to initialize custom OpenAI instrumentation:", e);
11818
11946
  }
11819
11947
  }
11820
11948
  if (customInstrumentModules.groq) {
11821
11949
  try {
11822
11950
  await groqInstrumentor.instrumentAsync({ tracerProvider });
11823
- Logger.debug("Custom Groq instrumentation enabled");
11951
+ NetraLogger.debug("Custom Groq instrumentation enabled");
11824
11952
  } catch (e) {
11825
- Logger.debug("Failed to initialize custom Groq instrumentation:", e);
11953
+ NetraLogger.debug("Failed to initialize custom Groq instrumentation:", e);
11826
11954
  }
11827
11955
  }
11828
11956
  if (customInstrumentModules.googleGenAI) {
11829
11957
  try {
11830
11958
  await googleGenAIInstrumentor.instrument({ tracerProvider });
11831
- Logger.debug("Custom Google GenAI instrumentation enabled");
11959
+ NetraLogger.debug("Custom Google GenAI instrumentation enabled");
11832
11960
  } catch (e) {
11833
- Logger.debug(
11961
+ NetraLogger.debug(
11834
11962
  "Failed to initialize custom Google GenAI instrumentation:",
11835
11963
  e
11836
11964
  );
@@ -11839,33 +11967,33 @@ async function initCustomInstrumentationsAsync(config, tracerProvider, customIns
11839
11967
  if (customInstrumentModules.googleGenerativeAI) {
11840
11968
  try {
11841
11969
  await googleGenerativeAIInstrumentor.instrument({ tracerProvider });
11842
- Logger.debug("Custom Google Generative AI instrumentation enabled");
11970
+ NetraLogger.debug("Custom Google Generative AI instrumentation enabled");
11843
11971
  } catch (e) {
11844
- Logger.debug("Failed to initialize custom Google Generative AI instrumentation:", e);
11972
+ NetraLogger.debug("Failed to initialize custom Google Generative AI instrumentation:", e);
11845
11973
  }
11846
11974
  }
11847
11975
  if (customInstrumentModules.langgraph) {
11848
11976
  try {
11849
11977
  await langgraphInstrumentor.instrument({ tracerProvider });
11850
- Logger.debug("Custom Langgraph instrumentation enabled");
11978
+ NetraLogger.debug("Custom Langgraph instrumentation enabled");
11851
11979
  } catch (e) {
11852
- Logger.debug("Failed to initialize custom Langgraph instrumentation:", e);
11980
+ NetraLogger.debug("Failed to initialize custom Langgraph instrumentation:", e);
11853
11981
  }
11854
11982
  }
11855
11983
  if (customInstrumentModules.anthropic) {
11856
11984
  try {
11857
11985
  await anthropicInstrumentor.instrument({ tracerProvider });
11858
- Logger.debug("Custom Anthropic instrumentation enabled");
11986
+ NetraLogger.debug("Custom Anthropic instrumentation enabled");
11859
11987
  } catch (e) {
11860
- Logger.debug("Failed to initialize custom Anthropic instrumentation:", e);
11988
+ NetraLogger.debug("Failed to initialize custom Anthropic instrumentation:", e);
11861
11989
  }
11862
11990
  }
11863
11991
  if (customInstrumentModules.openAiAgents && !blockInstruments?.has("openai_agents" /* OPENAI_AGENTS */)) {
11864
11992
  try {
11865
11993
  await openaiAgentsInstrumentor.instrument({ tracerProvider });
11866
- Logger.debug("Custom OpenAI Agents SDK instrumentation enabled");
11994
+ NetraLogger.debug("Custom OpenAI Agents SDK instrumentation enabled");
11867
11995
  } catch (e) {
11868
- Logger.debug("Failed to initialize custom OpenAI Agents SDK instrumentation:", e);
11996
+ NetraLogger.debug("Failed to initialize custom OpenAI Agents SDK instrumentation:", e);
11869
11997
  }
11870
11998
  }
11871
11999
  }
@@ -11876,14 +12004,14 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11876
12004
  netraHost = new URL(config.otlpEndpoint).host;
11877
12005
  }
11878
12006
  } catch {
11879
- Logger.debug(`OTEL_NODE_EXCLUDED_URLS: malformed otlpEndpoint '${config.otlpEndpoint}', skipping host-based exclusion`);
12007
+ NetraLogger.debug(`OTEL_NODE_EXCLUDED_URLS: malformed otlpEndpoint '${config.otlpEndpoint}', skipping host-based exclusion`);
11880
12008
  }
11881
12009
  const excludeRegexes = (process.env.OTEL_NODE_EXCLUDED_URLS || "").split(",").map((s) => s.trim()).filter(Boolean).map((pattern) => {
11882
12010
  try {
11883
12011
  return new RegExp(pattern);
11884
12012
  } catch {
11885
12013
  if (config.debugMode) {
11886
- Logger.debug(
12014
+ NetraLogger.debug(
11887
12015
  `Invalid OTEL_NODE_EXCLUDED_URLS pattern skipped: ${pattern}`
11888
12016
  );
11889
12017
  }
@@ -11906,10 +12034,10 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11906
12034
  });
11907
12035
  registerInstrumentations({ instrumentations: [_httpInstrumentation] });
11908
12036
  if (config.debugMode) {
11909
- Logger.debug("HTTP instrumentation enabled");
12037
+ NetraLogger.debug("HTTP instrumentation enabled");
11910
12038
  }
11911
12039
  } catch (e) {
11912
- Logger.debug("HTTP instrumentation not available:", e);
12040
+ NetraLogger.debug("HTTP instrumentation not available:", e);
11913
12041
  }
11914
12042
  }
11915
12043
  const fetchEnabled = !isBlocked("http" /* HTTP */, blockInstruments) && resolved.has("http" /* HTTP */);
@@ -11925,11 +12053,11 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11925
12053
  });
11926
12054
  registerInstrumentations({ instrumentations: [_undiciInstrumentation] });
11927
12055
  if (config.debugMode) {
11928
- Logger.debug("Undici/fetch instrumentation enabled");
12056
+ NetraLogger.debug("Undici/fetch instrumentation enabled");
11929
12057
  }
11930
12058
  } catch (e) {
11931
12059
  if (config.debugMode) {
11932
- Logger.debug("Undici/fetch instrumentation not available:", e);
12060
+ NetraLogger.debug("Undici/fetch instrumentation not available:", e);
11933
12061
  }
11934
12062
  }
11935
12063
  }
@@ -11937,14 +12065,14 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11937
12065
  try {
11938
12066
  const { PrismaInstrumentation } = require3("@prisma/instrumentation");
11939
12067
  } catch (e) {
11940
- Logger.debug("Prisma instrumentation not available:", e);
12068
+ NetraLogger.debug("Prisma instrumentation not available:", e);
11941
12069
  }
11942
12070
  }
11943
12071
  if (!isBlocked("typeorm" /* TYPEORM */, blockInstruments) && resolved.has("typeorm" /* TYPEORM */) && isPackageInstalled("typeorm")) {
11944
12072
  typeORMInstrumentor.instrument().then(() => {
11945
- Logger.debug("TypeORM instrumentation successfully initialized");
12073
+ NetraLogger.debug("TypeORM instrumentation successfully initialized");
11946
12074
  }).catch((e) => {
11947
- Logger.debug("TypeORM instrumentation error:", e);
12075
+ NetraLogger.debug("TypeORM instrumentation error:", e);
11948
12076
  });
11949
12077
  }
11950
12078
  if (!isBlocked("express" /* EXPRESS */, blockInstruments) && resolved.has("express" /* EXPRESS */)) {
@@ -11953,10 +12081,10 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11953
12081
  const { registerInstrumentations } = require3("@opentelemetry/instrumentation");
11954
12082
  registerInstrumentations({ instrumentations: [new ExpressInstrumentation()] });
11955
12083
  if (config.debugMode) {
11956
- Logger.debug("Express instrumentation enabled");
12084
+ NetraLogger.debug("Express instrumentation enabled");
11957
12085
  }
11958
12086
  } catch (e) {
11959
- Logger.debug("Express instrumentation not available:", e);
12087
+ NetraLogger.debug("Express instrumentation not available:", e);
11960
12088
  }
11961
12089
  }
11962
12090
  }
@@ -11991,7 +12119,7 @@ function addCustomSpanProcessors(tracerProvider, config, rootInstrumentNames) {
11991
12119
  }
11992
12120
  }
11993
12121
  if (!provider) {
11994
- Logger.debug(
12122
+ NetraLogger.debug(
11995
12123
  "Could not access TracerProvider for adding span processors. Session context will still be propagated via baggage."
11996
12124
  );
11997
12125
  return null;
@@ -12020,10 +12148,10 @@ function addCustomSpanProcessors(tracerProvider, config, rootInstrumentNames) {
12020
12148
  provider.addSpanProcessor(llmTraceProcessor);
12021
12149
  const rootSpanProcessor = new RootSpanProcessor();
12022
12150
  provider.addSpanProcessor(rootSpanProcessor);
12023
- Logger.debug("Custom span processors registered successfully");
12151
+ NetraLogger.debug("Custom span processors registered successfully");
12024
12152
  return provider;
12025
12153
  } catch (e) {
12026
- Logger.debug("Failed to add custom span processors:", e);
12154
+ NetraLogger.debug("Failed to add custom span processors:", e);
12027
12155
  return null;
12028
12156
  }
12029
12157
  }
@@ -12031,92 +12159,92 @@ async function uninstrumentAll() {
12031
12159
  try {
12032
12160
  if (openAIInstrumentor.isInstrumented()) {
12033
12161
  await openAIInstrumentor.uninstrument();
12034
- Logger.debug("Custom OpenAI instrumentation disabled");
12162
+ NetraLogger.debug("Custom OpenAI instrumentation disabled");
12035
12163
  }
12036
12164
  } catch (e) {
12037
- Logger.debug("Failed to uninstrument OpenAI:", e);
12165
+ NetraLogger.debug("Failed to uninstrument OpenAI:", e);
12038
12166
  }
12039
12167
  try {
12040
12168
  if (mistralAIInstrumentor.isInstrumented()) {
12041
12169
  mistralAIInstrumentor.uninstrument();
12042
- Logger.debug("Custom MistralAI instrumentation disabled");
12170
+ NetraLogger.debug("Custom MistralAI instrumentation disabled");
12043
12171
  }
12044
12172
  } catch (e) {
12045
- Logger.debug("Failed to uninstrument MistralAI:", e);
12173
+ NetraLogger.debug("Failed to uninstrument MistralAI:", e);
12046
12174
  }
12047
12175
  try {
12048
12176
  if (groqInstrumentor.isInstrumented()) {
12049
12177
  groqInstrumentor.uninstrument();
12050
- Logger.debug("Custom Groq instrumentation disabled");
12178
+ NetraLogger.debug("Custom Groq instrumentation disabled");
12051
12179
  }
12052
12180
  } catch (e) {
12053
- Logger.debug("Failed to uninstrument Groq:", e);
12181
+ NetraLogger.debug("Failed to uninstrument Groq:", e);
12054
12182
  }
12055
12183
  try {
12056
12184
  if (anthropicInstrumentor.isInstrumented()) {
12057
12185
  anthropicInstrumentor.uninstrument();
12058
- Logger.debug("Custom Anthropic instrumentation disabled");
12186
+ NetraLogger.debug("Custom Anthropic instrumentation disabled");
12059
12187
  }
12060
12188
  } catch (e) {
12061
- Logger.debug("Failed to uninstrument Anthropic:", e);
12189
+ NetraLogger.debug("Failed to uninstrument Anthropic:", e);
12062
12190
  }
12063
12191
  try {
12064
12192
  if (googleGenAIInstrumentor.isInstrumented()) {
12065
12193
  googleGenAIInstrumentor.uninstrument();
12066
- Logger.debug("Custom Google GenAI instrumentation disabled");
12194
+ NetraLogger.debug("Custom Google GenAI instrumentation disabled");
12067
12195
  }
12068
12196
  } catch (e) {
12069
- Logger.debug("Failed to uninstrument Google GenAI:", e);
12197
+ NetraLogger.debug("Failed to uninstrument Google GenAI:", e);
12070
12198
  }
12071
12199
  try {
12072
12200
  if (googleGenerativeAIInstrumentor.isInstrumented()) {
12073
12201
  googleGenerativeAIInstrumentor.uninstrument();
12074
- Logger.debug("Custom Google Generative AI instrumentation disabled");
12202
+ NetraLogger.debug("Custom Google Generative AI instrumentation disabled");
12075
12203
  }
12076
12204
  } catch (e) {
12077
- Logger.debug("Failed to uninstrument Google Generative AI:", e);
12205
+ NetraLogger.debug("Failed to uninstrument Google Generative AI:", e);
12078
12206
  }
12079
12207
  try {
12080
12208
  if (langgraphInstrumentor.isInstrumented()) {
12081
12209
  await langgraphInstrumentor.uninstrument();
12082
- Logger.debug("Custom Langgraph instrumentation disabled");
12210
+ NetraLogger.debug("Custom Langgraph instrumentation disabled");
12083
12211
  }
12084
12212
  } catch (e) {
12085
- Logger.debug("Failed to uninstrument Langgraph:", e);
12213
+ NetraLogger.debug("Failed to uninstrument Langgraph:", e);
12086
12214
  }
12087
12215
  try {
12088
12216
  if (typeORMInstrumentor.isInstrumented()) {
12089
12217
  typeORMInstrumentor.uninstrument();
12090
- Logger.debug("Custom TypeORM instrumentation disabled");
12218
+ NetraLogger.debug("Custom TypeORM instrumentation disabled");
12091
12219
  }
12092
12220
  } catch (e) {
12093
- Logger.debug("Failed to uninstrument TypeORM:", e);
12221
+ NetraLogger.debug("Failed to uninstrument TypeORM:", e);
12094
12222
  }
12095
12223
  try {
12096
12224
  if (openaiAgentsInstrumentor.isInstrumented()) {
12097
12225
  openaiAgentsInstrumentor.uninstrument();
12098
- Logger.debug("Custom OpenAI Agents SDK instrumentation disabled");
12226
+ NetraLogger.debug("Custom OpenAI Agents SDK instrumentation disabled");
12099
12227
  }
12100
12228
  } catch (e) {
12101
- Logger.debug("Failed to uninstrument OpenAI Agents SDK:", e);
12229
+ NetraLogger.debug("Failed to uninstrument OpenAI Agents SDK:", e);
12102
12230
  }
12103
12231
  try {
12104
12232
  if (_httpInstrumentation) {
12105
12233
  _httpInstrumentation.disable();
12106
12234
  _httpInstrumentation = null;
12107
- Logger.debug("HTTP instrumentation disabled");
12235
+ NetraLogger.debug("HTTP instrumentation disabled");
12108
12236
  }
12109
12237
  } catch (e) {
12110
- Logger.debug("Failed to uninstrument HTTP:", e);
12238
+ NetraLogger.debug("Failed to uninstrument HTTP:", e);
12111
12239
  }
12112
12240
  try {
12113
12241
  if (_undiciInstrumentation) {
12114
12242
  _undiciInstrumentation.disable();
12115
12243
  _undiciInstrumentation = null;
12116
- Logger.debug("Undici/fetch instrumentation disabled");
12244
+ NetraLogger.debug("Undici/fetch instrumentation disabled");
12117
12245
  }
12118
12246
  } catch (e) {
12119
- Logger.debug("Failed to uninstrument undici:", e);
12247
+ NetraLogger.debug("Failed to uninstrument undici:", e);
12120
12248
  }
12121
12249
  }
12122
12250
 
@@ -12281,11 +12409,11 @@ var onSignal = (sig) => {
12281
12409
  if (firing) {
12282
12410
  const handled2 = process.listeners(sig).some((l) => !ours.has(l));
12283
12411
  if (!handled2 && sig === appOwnedSignal && !handedBack) {
12284
- Logger.debug(`netra: ${sig} handed back by the app; exiting after flush`);
12412
+ NetraLogger.debug(`netra: ${sig} handed back by the app; exiting after flush`);
12285
12413
  handedBack = sig;
12286
12414
  return;
12287
12415
  }
12288
- Logger.debug(`netra: second ${sig} during shutdown; exiting now`);
12416
+ NetraLogger.debug(`netra: second ${sig} during shutdown; exiting now`);
12289
12417
  generation++;
12290
12418
  firing = false;
12291
12419
  uninstall();
@@ -12299,9 +12427,9 @@ var onSignal = (sig) => {
12299
12427
  }
12300
12428
  const handled = appHandles(sig);
12301
12429
  const gen = startFire(handled ? sig : void 0);
12302
- Logger.log(`
12430
+ NetraLogger.log(`
12303
12431
  Received ${sig}. Flushing Netra SDK...`);
12304
- void runTasks({ kind: "signal", signal: sig }).catch((err) => Logger.error("netra: error during shutdown:", err)).finally(() => {
12432
+ void runTasks({ kind: "signal", signal: sig }).catch((err) => NetraLogger.error("netra: error during shutdown:", err)).finally(() => {
12305
12433
  if (gen !== generation) {
12306
12434
  return;
12307
12435
  }
@@ -12335,8 +12463,8 @@ var onUncaughtException = (error) => {
12335
12463
  return;
12336
12464
  }
12337
12465
  const gen = startFire();
12338
- Logger.error("Uncaught exception; flushing Netra SDK before exit...");
12339
- void runTasks({ kind: "uncaughtException", error }).catch((err) => Logger.error("netra: error during crash shutdown:", err)).finally(() => {
12466
+ NetraLogger.error("Uncaught exception; flushing Netra SDK before exit...");
12467
+ void runTasks({ kind: "uncaughtException", error }).catch((err) => NetraLogger.error("netra: error during crash shutdown:", err)).finally(() => {
12340
12468
  if (gen !== generation) {
12341
12469
  return;
12342
12470
  }
@@ -12357,7 +12485,7 @@ var onUnhandledRejection = (reason) => {
12357
12485
  }
12358
12486
  if (!appHandles("uncaughtException")) {
12359
12487
  const gen = startFire();
12360
- void runTasks({ kind: "unhandledRejection", error: reason }).catch((err) => Logger.error("netra: error during shutdown:", err)).finally(() => {
12488
+ void runTasks({ kind: "unhandledRejection", error: reason }).catch((err) => NetraLogger.error("netra: error during shutdown:", err)).finally(() => {
12361
12489
  if (gen !== generation) {
12362
12490
  return;
12363
12491
  }
@@ -12387,11 +12515,11 @@ var MAX_FILE_DOWNLOAD_WORKERS = 8;
12387
12515
  var _cachedFileDownloadTimeoutMs = null;
12388
12516
  function validateSimulationInputs(datasetId, task2) {
12389
12517
  if (!datasetId) {
12390
- Logger.error(`${LOG_PREFIX4}: dataset_id is required`);
12518
+ NetraLogger.notice("error", `${LOG_PREFIX4}: dataset_id is required`);
12391
12519
  return false;
12392
12520
  }
12393
12521
  if (!(task2 instanceof BaseTask)) {
12394
- Logger.error(`${LOG_PREFIX4}: task must be a BaseTask instance`);
12522
+ NetraLogger.notice("error", `${LOG_PREFIX4}: task must be a BaseTask instance`);
12395
12523
  return false;
12396
12524
  }
12397
12525
  return true;
@@ -12407,7 +12535,8 @@ function _getFileDownloadTimeout() {
12407
12535
  _cachedFileDownloadTimeoutMs = parsed * 1e3;
12408
12536
  return _cachedFileDownloadTimeoutMs;
12409
12537
  }
12410
- Logger.warn(
12538
+ NetraLogger.notice(
12539
+ "warn",
12411
12540
  `${LOG_PREFIX4}: Invalid file download timeout '${envVal}', using default ${DEFAULT_FILE_DOWNLOAD_TIMEOUT_S}s`
12412
12541
  );
12413
12542
  }
@@ -12436,7 +12565,8 @@ async function _downloadSingleFile(fileData, timeoutMs, signal) {
12436
12565
  }
12437
12566
  const status = axios.isAxiosError(error) ? error.response?.status : void 0;
12438
12567
  const reason = status ? `HTTP ${status}` : error instanceof Error ? error.message : String(error);
12439
- Logger.error(
12568
+ NetraLogger.notice(
12569
+ "error",
12440
12570
  `${LOG_PREFIX4}: Failed to download file '${fileData.fileName}': ${reason}`
12441
12571
  );
12442
12572
  throw new Error(
@@ -12453,7 +12583,7 @@ function parseFiles(rawFiles) {
12453
12583
  const fileName = entry.fileName || "";
12454
12584
  const downloadUrl = entry.downloadUrl || "";
12455
12585
  if (!fileName || !downloadUrl) {
12456
- Logger.warn(
12586
+ NetraLogger.warn(
12457
12587
  `${LOG_PREFIX4}: Skipping malformed file attachment (missing fileName or downloadUrl)`
12458
12588
  );
12459
12589
  continue;
@@ -12511,7 +12641,7 @@ var SimulationHttpClient = class {
12511
12641
  _createClient(config) {
12512
12642
  const endpoint = (config.otlpEndpoint || "").trim();
12513
12643
  if (!endpoint) {
12514
- Logger.error(`${LOG_PREFIX5}: NETRA_OTLP_ENDPOINT is required`);
12644
+ NetraLogger.debug(`${LOG_PREFIX5}: NETRA_OTLP_ENDPOINT is required`);
12515
12645
  return null;
12516
12646
  }
12517
12647
  const baseURL = this._resolveBaseUrl(endpoint);
@@ -12533,7 +12663,7 @@ var SimulationHttpClient = class {
12533
12663
  );
12534
12664
  return instance;
12535
12665
  } catch (error) {
12536
- Logger.error(`${LOG_PREFIX5}: Failed to create HTTP client:`, error);
12666
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Failed to create HTTP client:`, error);
12537
12667
  return null;
12538
12668
  }
12539
12669
  }
@@ -12567,7 +12697,8 @@ var SimulationHttpClient = class {
12567
12697
  }
12568
12698
  const timeout = parseFloat(timeoutStr);
12569
12699
  if (isNaN(timeout)) {
12570
- Logger.warn(
12700
+ NetraLogger.notice(
12701
+ "warn",
12571
12702
  `${LOG_PREFIX5}: Invalid timeout '${timeoutStr}', using default ${DEFAULT_TIMEOUT}ms`
12572
12703
  );
12573
12704
  return DEFAULT_TIMEOUT;
@@ -12582,7 +12713,7 @@ var SimulationHttpClient = class {
12582
12713
  */
12583
12714
  async initializeRun(name, datasetId, context16, hooksMeta) {
12584
12715
  if (!this.client) {
12585
- Logger.error(`${LOG_PREFIX5}: Client not initialized`);
12716
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Client not initialized`);
12586
12717
  return null;
12587
12718
  }
12588
12719
  try {
@@ -12600,7 +12731,7 @@ var SimulationHttpClient = class {
12600
12731
  const responseData = data.data || {};
12601
12732
  const items = responseData.items || [];
12602
12733
  if (items.length === 0) {
12603
- Logger.warn(`${LOG_PREFIX5}: No items returned from initialize_run`);
12734
+ NetraLogger.warn(`${LOG_PREFIX5}: No items returned from initialize_run`);
12604
12735
  return null;
12605
12736
  }
12606
12737
  const runId = responseData.id || "";
@@ -12613,7 +12744,7 @@ var SimulationHttpClient = class {
12613
12744
  };
12614
12745
  } catch (error) {
12615
12746
  const errorMsg = this._extractErrorMessage(error);
12616
- Logger.error(`${LOG_PREFIX5}: Failed to initialize run:`, errorMsg);
12747
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Failed to initialize run:`, errorMsg);
12617
12748
  return null;
12618
12749
  }
12619
12750
  }
@@ -12624,7 +12755,7 @@ var SimulationHttpClient = class {
12624
12755
  */
12625
12756
  async generateFirstTurn(runId, runItemId) {
12626
12757
  if (!this.client) {
12627
- Logger.error(`${LOG_PREFIX5}: Client not initialized`);
12758
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Client not initialized`);
12628
12759
  return null;
12629
12760
  }
12630
12761
  try {
@@ -12641,7 +12772,8 @@ var SimulationHttpClient = class {
12641
12772
  };
12642
12773
  } catch (error) {
12643
12774
  const errorMsg = this._extractErrorMessage(error);
12644
- Logger.error(
12775
+ NetraLogger.notice(
12776
+ "error",
12645
12777
  `${LOG_PREFIX5}: Failed to generate first turn for item ${runItemId}:`,
12646
12778
  errorMsg
12647
12779
  );
@@ -12653,7 +12785,7 @@ var SimulationHttpClient = class {
12653
12785
  */
12654
12786
  async triggerConversation(message, turnId, sessionId, traceId) {
12655
12787
  if (!this.client) {
12656
- Logger.error(`${LOG_PREFIX5}: Client not initialized`);
12788
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Client not initialized`);
12657
12789
  return null;
12658
12790
  }
12659
12791
  try {
@@ -12676,7 +12808,7 @@ var SimulationHttpClient = class {
12676
12808
  }
12677
12809
  const userMessages = responseData.userMessages || [];
12678
12810
  if (userMessages.length === 0) {
12679
- Logger.warn(`${LOG_PREFIX5}: No user messages in continue response`);
12811
+ NetraLogger.warn(`${LOG_PREFIX5}: No user messages in continue response`);
12680
12812
  return null;
12681
12813
  }
12682
12814
  const nextMsg = userMessages[0];
@@ -12689,7 +12821,7 @@ var SimulationHttpClient = class {
12689
12821
  };
12690
12822
  } catch (error) {
12691
12823
  const errorMsg = this._extractErrorMessage(error);
12692
- Logger.error(`${LOG_PREFIX5}: Failed to trigger conversation:`, errorMsg);
12824
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Failed to trigger conversation:`, errorMsg);
12693
12825
  return null;
12694
12826
  }
12695
12827
  }
@@ -12708,17 +12840,17 @@ var SimulationHttpClient = class {
12708
12840
  */
12709
12841
  async reportFailure(runId, runItemId, error, status = "failed") {
12710
12842
  if (!this.client) {
12711
- Logger.error(`${LOG_PREFIX5}: Client not initialized`);
12843
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Client not initialized`);
12712
12844
  return;
12713
12845
  }
12714
12846
  try {
12715
12847
  const url = apiPath`/evaluations/run/${runId}/item/${runItemId}/status`;
12716
12848
  const payload = { status, failureReason: error };
12717
12849
  await this.client.patch(url, payload);
12718
- Logger.info(`${LOG_PREFIX5}: Reported failure - ${error}`);
12850
+ NetraLogger.info(`${LOG_PREFIX5}: Reported failure - ${error}`);
12719
12851
  } catch (err) {
12720
12852
  const errorMsg = this._extractErrorMessage(err);
12721
- Logger.error(`${LOG_PREFIX5}: Failed to report failure:`, errorMsg);
12853
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Failed to report failure:`, errorMsg);
12722
12854
  }
12723
12855
  }
12724
12856
  /**
@@ -12726,7 +12858,8 @@ var SimulationHttpClient = class {
12726
12858
  */
12727
12859
  async postRunStatus(runId, status) {
12728
12860
  if (!this.client) {
12729
- Logger.error(
12861
+ NetraLogger.notice(
12862
+ "error",
12730
12863
  `${LOG_PREFIX5}: Client not initialized; cannot post run status`
12731
12864
  );
12732
12865
  return { success: false };
@@ -12737,13 +12870,14 @@ var SimulationHttpClient = class {
12737
12870
  const response = await this.client.post(url, payload);
12738
12871
  const data = response.data;
12739
12872
  if (data && typeof data === "object" && "data" in data) {
12740
- Logger.info(`${LOG_PREFIX5}: Completed test run successfully`);
12873
+ NetraLogger.info(`${LOG_PREFIX5}: Completed test run successfully`);
12741
12874
  return data.data || {};
12742
12875
  }
12743
12876
  return data;
12744
12877
  } catch (error) {
12745
12878
  const errorMsg = this._extractErrorMessage(error);
12746
- Logger.error(
12879
+ NetraLogger.notice(
12880
+ "error",
12747
12881
  `${LOG_PREFIX5}: Failed to post run status for run '${runId}':`,
12748
12882
  errorMsg
12749
12883
  );
@@ -12813,10 +12947,11 @@ function describeHooks(hooks) {
12813
12947
  }
12814
12948
  async function runBeforeAll(hooks) {
12815
12949
  if (!hooks?.beforeAll) return null;
12816
- Logger.info(`${LOG_PREFIX6}: running beforeAll hook`);
12950
+ NetraLogger.info(`${LOG_PREFIX6}: running beforeAll hook`);
12817
12951
  const result = await hooks.beforeAll();
12818
12952
  if (result !== null && result !== void 0 && typeof result !== "object") {
12819
- Logger.warn(
12953
+ NetraLogger.notice(
12954
+ "warn",
12820
12955
  `${LOG_PREFIX6}: beforeAll returned ${typeof result} (expected object or null); ignoring value`
12821
12956
  );
12822
12957
  return null;
@@ -12825,7 +12960,7 @@ async function runBeforeAll(hooks) {
12825
12960
  }
12826
12961
  async function runBefore(hooks, datasetItemId, sharedContext) {
12827
12962
  if (hooks?.before && datasetItemId in hooks.before) {
12828
- Logger.info(
12963
+ NetraLogger.info(
12829
12964
  `${LOG_PREFIX6}: running before hook for datasetItemId=${datasetItemId}`
12830
12965
  );
12831
12966
  const itemHook = hooks.before[datasetItemId];
@@ -12835,7 +12970,8 @@ async function runBefore(hooks, datasetItemId, sharedContext) {
12835
12970
  if (typeof result === "object") {
12836
12971
  Object.assign(base, result);
12837
12972
  } else {
12838
- Logger.warn(
12973
+ NetraLogger.notice(
12974
+ "warn",
12839
12975
  `${LOG_PREFIX6}: before hook returned ${typeof result} (expected object or null); ignoring value`
12840
12976
  );
12841
12977
  }
@@ -12846,7 +12982,7 @@ async function runBefore(hooks, datasetItemId, sharedContext) {
12846
12982
  }
12847
12983
  async function runBeforeEach(hooks, datasetItemId, sharedContext) {
12848
12984
  if (!hooks?.beforeEach) return sharedContext;
12849
- Logger.info(
12985
+ NetraLogger.info(
12850
12986
  `${LOG_PREFIX6}: running beforeEach hook for datasetItemId=${datasetItemId}`
12851
12987
  );
12852
12988
  const result = await hooks.beforeEach(sharedContext);
@@ -12855,7 +12991,8 @@ async function runBeforeEach(hooks, datasetItemId, sharedContext) {
12855
12991
  if (typeof result === "object") {
12856
12992
  Object.assign(base, result);
12857
12993
  } else {
12858
- Logger.warn(
12994
+ NetraLogger.notice(
12995
+ "warn",
12859
12996
  `${LOG_PREFIX6}: beforeEach hook returned ${typeof result} (expected object or null); ignoring value`
12860
12997
  );
12861
12998
  }
@@ -12864,7 +13001,7 @@ async function runBeforeEach(hooks, datasetItemId, sharedContext) {
12864
13001
  }
12865
13002
  async function runAfter(hooks, datasetItemId, itemResult, setupContext) {
12866
13003
  if (hooks?.after && datasetItemId in hooks.after) {
12867
- Logger.info(
13004
+ NetraLogger.info(
12868
13005
  `${LOG_PREFIX6}: running after hook for datasetItemId=${datasetItemId}`
12869
13006
  );
12870
13007
  await hooks.after[datasetItemId](itemResult, setupContext);
@@ -12872,14 +13009,14 @@ async function runAfter(hooks, datasetItemId, itemResult, setupContext) {
12872
13009
  }
12873
13010
  async function runAfterEach(hooks, datasetItemId, itemResult, setupContext) {
12874
13011
  if (!hooks?.afterEach) return;
12875
- Logger.info(
13012
+ NetraLogger.info(
12876
13013
  `${LOG_PREFIX6}: running afterEach hook for datasetItemId=${datasetItemId}`
12877
13014
  );
12878
13015
  await hooks.afterEach(itemResult, setupContext);
12879
13016
  }
12880
13017
  async function runAfterAll(hooks, results, sharedContext) {
12881
13018
  if (!hooks?.afterAll) return;
12882
- Logger.info(`${LOG_PREFIX6}: running afterAll hook`);
13019
+ NetraLogger.info(`${LOG_PREFIX6}: running afterAll hook`);
12883
13020
  await hooks.afterAll(results, sharedContext);
12884
13021
  }
12885
13022
 
@@ -12928,7 +13065,7 @@ var Simulation = class {
12928
13065
  }
12929
13066
  const { runId, items } = initResult;
12930
13067
  if (!items || items.length === 0) {
12931
- Logger.error(`${LOG_PREFIX7}: No items returned from initialize_run`);
13068
+ NetraLogger.notice("error", `${LOG_PREFIX7}: No items returned from initialize_run`);
12932
13069
  return null;
12933
13070
  }
12934
13071
  const unregisterExitTask = registerExitTask(
@@ -12942,7 +13079,7 @@ var Simulation = class {
12942
13079
  sharedContext = await runBeforeAll(hooks);
12943
13080
  } catch (error) {
12944
13081
  const errorMsg = `beforeAll hook failed: ${error instanceof Error ? error.message : String(error)}`;
12945
- Logger.error(`${LOG_PREFIX7}: ${errorMsg} \u2014 aborting run (no LLM spent)`);
13082
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg} \u2014 aborting run (no LLM spent)`);
12946
13083
  await this._reportFailures(
12947
13084
  runId,
12948
13085
  items.map((item) => item.runItemId),
@@ -12964,7 +13101,7 @@ var Simulation = class {
12964
13101
  await runAfterAll(hooks, results, null);
12965
13102
  } catch (afterAllError) {
12966
13103
  const afterAllMsg = `afterAll hook failed: ${afterAllError instanceof Error ? afterAllError.message : String(afterAllError)}`;
12967
- Logger.error(`${LOG_PREFIX7}: ${afterAllMsg}`);
13104
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${afterAllMsg}`);
12968
13105
  }
12969
13106
  await this._client.postRunStatus(runId, "completed");
12970
13107
  return results;
@@ -12987,7 +13124,7 @@ var Simulation = class {
12987
13124
  setupContexts.set(runItemId, setupContext);
12988
13125
  } catch (error) {
12989
13126
  const errorMsg = `before hook failed: ${error instanceof Error ? error.message : String(error)}`;
12990
- Logger.error(`${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13127
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
12991
13128
  await this._client.reportFailure(runId, runItemId, errorMsg, "prescript_failed");
12992
13129
  const itemResult = {
12993
13130
  runItemId,
@@ -13003,7 +13140,7 @@ var Simulation = class {
13003
13140
  }
13004
13141
  const simItem = await this._client.generateFirstTurn(runId, runItemId);
13005
13142
  if (!simItem) {
13006
- Logger.warn(`${LOG_PREFIX7}: Failed to generate first turn for item ${runItemId}, marking failed`);
13143
+ NetraLogger.notice("warn", `${LOG_PREFIX7}: Failed to generate first turn for item ${runItemId}, marking failed`);
13007
13144
  await this._client.reportFailure(runId, runItemId, "Failed to generate first user message");
13008
13145
  const itemResult = {
13009
13146
  runItemId,
@@ -13019,7 +13156,7 @@ var Simulation = class {
13019
13156
  );
13020
13157
  await Promise.all(setupPromises);
13021
13158
  if (simulationItems.length === 0) {
13022
- Logger.error(`${LOG_PREFIX7}: All items failed during setup/generation`);
13159
+ NetraLogger.notice("error", `${LOG_PREFIX7}: All items failed during setup/generation`);
13023
13160
  const results = {
13024
13161
  success: false,
13025
13162
  completed: [],
@@ -13030,12 +13167,12 @@ var Simulation = class {
13030
13167
  await runAfterAll(hooks, results, sharedContext);
13031
13168
  } catch (afterAllError) {
13032
13169
  const afterAllMsg = `afterAll hook failed: ${afterAllError instanceof Error ? afterAllError.message : String(afterAllError)}`;
13033
- Logger.error(`${LOG_PREFIX7}: ${afterAllMsg}`);
13170
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${afterAllMsg}`);
13034
13171
  }
13035
13172
  await this._client.postRunStatus(runId, "completed");
13036
13173
  return results;
13037
13174
  }
13038
- Logger.info(`${LOG_PREFIX7}: Starting simulation with ${simulationItems.length} items`);
13175
+ NetraLogger.info(`${LOG_PREFIX7}: Starting simulation with ${simulationItems.length} items`);
13039
13176
  try {
13040
13177
  const result = await this._runSimulationAsync(
13041
13178
  runId,
@@ -13048,11 +13185,11 @@ var Simulation = class {
13048
13185
  failedItems
13049
13186
  );
13050
13187
  const elapsedTime = ((Date.now() - startTime) / 1e3).toFixed(2);
13051
- Logger.info(`${LOG_PREFIX7}: Simulation completed in ${elapsedTime} seconds`);
13188
+ NetraLogger.info(`${LOG_PREFIX7}: Simulation completed in ${elapsedTime} seconds`);
13052
13189
  await this._client.postRunStatus(runId, "completed");
13053
13190
  return result;
13054
13191
  } catch (error) {
13055
- Logger.error(`${LOG_PREFIX7}: Run simulation failed`);
13192
+ NetraLogger.notice("error", `${LOG_PREFIX7}: Run simulation failed`);
13056
13193
  await this._client.postRunStatus(runId, "failed");
13057
13194
  throw error;
13058
13195
  }
@@ -13088,7 +13225,7 @@ var Simulation = class {
13088
13225
  results.failed.push(result);
13089
13226
  }
13090
13227
  processedCount++;
13091
- Logger.info(
13228
+ NetraLogger.info(
13092
13229
  `${LOG_PREFIX7}: ${processedCount}/${runItems.length} processed (run_item_id=${runItem.runItemId})`
13093
13230
  );
13094
13231
  return result;
@@ -13100,7 +13237,7 @@ var Simulation = class {
13100
13237
  await runAfterAll(hooks, results, sharedContext);
13101
13238
  } catch (error) {
13102
13239
  const errorMsg = `afterAll hook failed: ${error instanceof Error ? error.message : String(error)}`;
13103
- Logger.error(`${LOG_PREFIX7}: ${errorMsg}`);
13240
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg}`);
13104
13241
  const completed = results.completed;
13105
13242
  const successfulIds = completed.map((item) => item.runItemId);
13106
13243
  await this._reportFailures(
@@ -13119,7 +13256,7 @@ var Simulation = class {
13119
13256
  results.completed = [];
13120
13257
  }
13121
13258
  results.success = results.failed.length === 0;
13122
- Logger.info(
13259
+ NetraLogger.info(
13123
13260
  `${LOG_PREFIX7}: Completed=${results.completed.length}, Failed=${results.failed.length}`
13124
13261
  );
13125
13262
  return results;
@@ -13151,14 +13288,14 @@ var Simulation = class {
13151
13288
  await runAfter(hooks, datasetItemId, itemResult, setupContext);
13152
13289
  } catch (error) {
13153
13290
  const errorMsg = `after hook failed: ${error instanceof Error ? error.message : String(error)}`;
13154
- Logger.error(`${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13291
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13155
13292
  errors.push(errorMsg);
13156
13293
  }
13157
13294
  try {
13158
13295
  await runAfterEach(hooks, datasetItemId, itemResult, setupContext);
13159
13296
  } catch (error) {
13160
13297
  const errorMsg = `afterEach hook failed: ${error instanceof Error ? error.message : String(error)}`;
13161
- Logger.error(`${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13298
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13162
13299
  errors.push(errorMsg);
13163
13300
  }
13164
13301
  if (errors.length > 0 && itemResult.success) {
@@ -13221,7 +13358,7 @@ var Simulation = class {
13221
13358
  return itemResult;
13222
13359
  }
13223
13360
  if (response.decision === "stop") {
13224
- Logger.info(
13361
+ NetraLogger.info(
13225
13362
  `${LOG_PREFIX7}: Completed run_item_id=${runItemId} reason=${response.reason}`
13226
13363
  );
13227
13364
  const itemResult = {
@@ -13237,7 +13374,8 @@ var Simulation = class {
13237
13374
  rawFiles = response.nextFiles || [];
13238
13375
  } catch (error) {
13239
13376
  const errorMsg = error instanceof Error ? error.message : String(error);
13240
- Logger.error(
13377
+ NetraLogger.notice(
13378
+ "error",
13241
13379
  `${LOG_PREFIX7}: Task failed run_item_id=${runItemId}, turn_id=${turnId}: ${errorMsg}`
13242
13380
  );
13243
13381
  await this._client.reportFailure(runId, runItemId, errorMsg);
@@ -13271,7 +13409,7 @@ function spanHasOutput(span2) {
13271
13409
  if (attrs && typeof attrs === "object" && attrs["output"]) return true;
13272
13410
  }
13273
13411
  } catch (e) {
13274
- Logger.warn("spanHasOutput: error inspecting span attributes:", e);
13412
+ NetraLogger.warn("spanHasOutput: error inspecting span attributes:", e);
13275
13413
  }
13276
13414
  return false;
13277
13415
  }
@@ -13461,12 +13599,12 @@ var _Netra = class _Netra {
13461
13599
  await this._shutdownPromise;
13462
13600
  }
13463
13601
  if (this._initialized) {
13464
- Logger.warn("Netra.init() called more than once; ignoring subsequent calls.");
13602
+ NetraLogger.notice("warn", "Netra.init() called more than once; ignoring subsequent calls.");
13465
13603
  return;
13466
13604
  }
13467
13605
  const cfg = new Config(config);
13468
13606
  this._config = cfg;
13469
- Logger.setDebugMode(cfg.debugMode);
13607
+ NetraLogger.setDebugMode(cfg.debugMode);
13470
13608
  const effectiveProvider = initInstrumentations(
13471
13609
  cfg,
13472
13610
  config.instruments,
@@ -13478,35 +13616,35 @@ var _Netra = class _Netra {
13478
13616
  try {
13479
13617
  this.usage = new Usage(cfg);
13480
13618
  } catch (e) {
13481
- Logger.warn("Netra: failed to initialize usage client:", e);
13619
+ NetraLogger.warn("Netra: failed to initialize usage client:", e);
13482
13620
  }
13483
13621
  try {
13484
13622
  this.evaluation = new Evaluation(cfg);
13485
13623
  } catch (e) {
13486
- Logger.warn("Netra: failed to initialize evaluation client:", e);
13624
+ NetraLogger.warn("Netra: failed to initialize evaluation client:", e);
13487
13625
  }
13488
13626
  try {
13489
13627
  this.dashboard = new Dashboard(cfg);
13490
13628
  } catch (e) {
13491
- Logger.warn("Netra: failed to initialize dashboard client:", e);
13629
+ NetraLogger.warn("Netra: failed to initialize dashboard client:", e);
13492
13630
  }
13493
13631
  try {
13494
13632
  this.simulation = new Simulation(cfg);
13495
13633
  } catch (e) {
13496
- Logger.warn("Netra: failed to initialize simulation client:", e);
13634
+ NetraLogger.warn("Netra: failed to initialize simulation client:", e);
13497
13635
  }
13498
13636
  try {
13499
13637
  this.prompts = new Prompts(cfg);
13500
13638
  } catch (e) {
13501
- Logger.warn("Netra: failed to initialize prompts client:", e);
13639
+ NetraLogger.warn("Netra: failed to initialize prompts client:", e);
13502
13640
  }
13503
13641
  try {
13504
13642
  this.models = new Models(cfg);
13505
13643
  } catch (e) {
13506
- Logger.warn("Netra: failed to initialize models client:", e);
13644
+ NetraLogger.warn("Netra: failed to initialize models client:", e);
13507
13645
  }
13508
13646
  this._initialized = true;
13509
- Logger.info("Netra successfully initialized.");
13647
+ NetraLogger.info("Netra successfully initialized.");
13510
13648
  {
13511
13649
  let pkgVersion = Config.LIBRARY_VERSION;
13512
13650
  let pkgPath = "unknown";
@@ -13517,7 +13655,7 @@ var _Netra = class _Netra {
13517
13655
  pkgVersion = pkg?.version || pkgVersion;
13518
13656
  } catch {
13519
13657
  }
13520
- Logger.debug(
13658
+ NetraLogger.debug(
13521
13659
  `SDK version=${pkgVersion} libraryVersion=${Config.LIBRARY_VERSION} build=langgraph-parenting-v3 packageJson=${pkgPath}`
13522
13660
  );
13523
13661
  }
@@ -13575,7 +13713,7 @@ var _Netra = class _Netra {
13575
13713
  try {
13576
13714
  await uninstrumentAll();
13577
13715
  } catch (e) {
13578
- Logger.error("Error during uninstrumentAll:", e);
13716
+ NetraLogger.error("Error during uninstrumentAll:", e);
13579
13717
  }
13580
13718
  let flushTimer;
13581
13719
  try {
@@ -13594,7 +13732,7 @@ var _Netra = class _Netra {
13594
13732
  })
13595
13733
  ]);
13596
13734
  } catch (e) {
13597
- Logger.error("Error during Netra trace shutdown:", e);
13735
+ NetraLogger.error("Error during Netra trace shutdown:", e);
13598
13736
  } finally {
13599
13737
  clearTimeout(flushTimer);
13600
13738
  }
@@ -13602,12 +13740,12 @@ var _Netra = class _Netra {
13602
13740
  this.prompts?.clearCache();
13603
13741
  this.models?.clearCache();
13604
13742
  } catch (e) {
13605
- Logger.error("Error clearing SDK API caches:", e);
13743
+ NetraLogger.error("Error clearing SDK API caches:", e);
13606
13744
  }
13607
13745
  try {
13608
13746
  await settleOtherExitTasks(this._flushTask);
13609
13747
  } catch (e) {
13610
- Logger.error("Error awaiting pending shutdown tasks:", e);
13748
+ NetraLogger.error("Error awaiting pending shutdown tasks:", e);
13611
13749
  }
13612
13750
  this._initialized = false;
13613
13751
  this._tracer = void 0;
@@ -13629,7 +13767,7 @@ var _Netra = class _Netra {
13629
13767
  }
13630
13768
  static setSessionId(sessionId) {
13631
13769
  if (typeof sessionId !== "string") {
13632
- Logger.error(`setSessionId: sessionId must be a string, got ${typeof sessionId}`);
13770
+ NetraLogger.notice("error", `setSessionId: sessionId must be a string, got ${typeof sessionId}`);
13633
13771
  return;
13634
13772
  }
13635
13773
  if (sessionId) {
@@ -13639,7 +13777,7 @@ var _Netra = class _Netra {
13639
13777
  sessionId
13640
13778
  );
13641
13779
  } else {
13642
- Logger.warn("setSessionId: Session ID must be provided for setting session_id.");
13780
+ NetraLogger.notice("warn", "setSessionId: Session ID must be provided for setting session_id.");
13643
13781
  }
13644
13782
  }
13645
13783
  /**
@@ -13648,7 +13786,7 @@ var _Netra = class _Netra {
13648
13786
  */
13649
13787
  static setUserId(userId) {
13650
13788
  if (typeof userId !== "string") {
13651
- Logger.error(`setUserId: userId must be a string, got ${typeof userId}`);
13789
+ NetraLogger.notice("error", `setUserId: userId must be a string, got ${typeof userId}`);
13652
13790
  return;
13653
13791
  }
13654
13792
  if (userId) {
@@ -13658,7 +13796,7 @@ var _Netra = class _Netra {
13658
13796
  userId
13659
13797
  );
13660
13798
  } else {
13661
- Logger.warn("setUserId: User ID must be provided for setting user_id.");
13799
+ NetraLogger.notice("warn", "setUserId: User ID must be provided for setting user_id.");
13662
13800
  }
13663
13801
  }
13664
13802
  /**
@@ -13667,7 +13805,7 @@ var _Netra = class _Netra {
13667
13805
  */
13668
13806
  static setTenantId(tenantId) {
13669
13807
  if (typeof tenantId !== "string") {
13670
- Logger.error(`setTenantId: tenantId must be a string, got ${typeof tenantId}`);
13808
+ NetraLogger.notice("error", `setTenantId: tenantId must be a string, got ${typeof tenantId}`);
13671
13809
  return;
13672
13810
  }
13673
13811
  if (tenantId) {
@@ -13677,7 +13815,7 @@ var _Netra = class _Netra {
13677
13815
  tenantId
13678
13816
  );
13679
13817
  } else {
13680
- Logger.warn("setTenantId: Tenant ID must be provided for setting tenant_id.");
13818
+ NetraLogger.notice("warn", "setTenantId: Tenant ID must be provided for setting tenant_id.");
13681
13819
  }
13682
13820
  }
13683
13821
  /**
@@ -13690,7 +13828,7 @@ var _Netra = class _Netra {
13690
13828
  value
13691
13829
  );
13692
13830
  } else {
13693
- Logger.warn("Both key and value must be provided for custom attributes.");
13831
+ NetraLogger.notice("warn", "Both key and value must be provided for custom attributes.");
13694
13832
  }
13695
13833
  }
13696
13834
  /**
@@ -13700,7 +13838,7 @@ var _Netra = class _Netra {
13700
13838
  if (eventName && attributes) {
13701
13839
  SessionManager.setCustomEvent(eventName, attributes);
13702
13840
  } else {
13703
- Logger.warn("Both eventName and attributes must be provided for custom events.");
13841
+ NetraLogger.notice("warn", "Both eventName and attributes must be provided for custom events.");
13704
13842
  }
13705
13843
  }
13706
13844
  /**