netra-sdk 1.12.0 → 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
@@ -8,7 +8,7 @@ import shimmer from 'shimmer';
8
8
  import { CompositePropagator, W3CTraceContextPropagator, W3CBaggagePropagator, ExportResultCode } from '@opentelemetry/core';
9
9
  import * as http from 'http';
10
10
  import * as https from 'https';
11
- import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';
11
+ import { ProtobufTraceSerializer } from '@opentelemetry/otlp-transformer';
12
12
  import pLimit2 from 'p-limit';
13
13
  import axios from 'axios';
14
14
 
@@ -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.0";
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;
829
+ }
830
+ const hasApiKeyHeader = Object.keys(this.headers).some(
831
+ (name) => name.toLowerCase() === NETRA_API_KEY_HEADER
832
+ );
833
+ if (hasApiKeyHeader) {
834
+ return;
760
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
  }
@@ -11392,6 +11515,27 @@ var _FilteringSpanExporter = class _FilteringSpanExporter {
11392
11515
  _FilteringSpanExporter.MAX_REMEMBERED_ENTRIES = 1e4;
11393
11516
  _FilteringSpanExporter.MAX_LOCAL_PATTERN_CACHE = 100;
11394
11517
  var FilteringSpanExporter = _FilteringSpanExporter;
11518
+ var HTTP_STATUS_PAYLOAD_TOO_LARGE = 413;
11519
+ var RESPONSE_EXCERPT_MAX_CHARS = 200;
11520
+ var PAYLOAD_TOO_LARGE_HINT = "Lower OTEL_BSP_MAX_EXPORT_BATCH_SIZE or reduce large span attributes such as prompts and completions.";
11521
+ function describeServerMessage(responseBody) {
11522
+ try {
11523
+ const parsed = JSON.parse(responseBody);
11524
+ const message = parsed?.error?.message;
11525
+ if (typeof message === "string") return `"${message}"`;
11526
+ if (Array.isArray(message) && message.every((m) => typeof m === "string")) {
11527
+ return `"${message.join("; ")}"`;
11528
+ }
11529
+ } catch {
11530
+ }
11531
+ const excerpt = responseBody.trim().slice(0, RESPONSE_EXCERPT_MAX_CHARS);
11532
+ return excerpt ? `"${excerpt}"` : "(empty response body)";
11533
+ }
11534
+ function formatExportFailure(statusCode, statusMessage, responseBody, spanCount, requestBytes) {
11535
+ const status = [statusCode ?? "unknown", statusMessage].filter(Boolean).join(" ");
11536
+ const hint = statusCode === HTTP_STATUS_PAYLOAD_TOO_LARGE ? ` ${PAYLOAD_TOO_LARGE_HINT}` : "";
11537
+ return `Span export failed with HTTP ${status}: ${describeServerMessage(responseBody)}. Dropped a batch of ${spanCount} spans (${requestBytes} bytes).${hint}`;
11538
+ }
11395
11539
  var TrialAwareOTLPExporter = class {
11396
11540
  constructor(config) {
11397
11541
  this._isShutdown = false;
@@ -11404,7 +11548,7 @@ var TrialAwareOTLPExporter = class {
11404
11548
  }
11405
11549
  let data;
11406
11550
  try {
11407
- const serialized = JsonTraceSerializer.serializeRequest(spans);
11551
+ const serialized = ProtobufTraceSerializer.serializeRequest(spans);
11408
11552
  if (!serialized) throw new Error("Serialization failed");
11409
11553
  data = serialized;
11410
11554
  } catch (err) {
@@ -11413,6 +11557,7 @@ var TrialAwareOTLPExporter = class {
11413
11557
  error: err instanceof Error ? err : new Error("Serialization failed")
11414
11558
  });
11415
11559
  }
11560
+ const requestBytes = typeof data === "string" ? Buffer.byteLength(data) : data.byteLength;
11416
11561
  const url = new URL(this._url);
11417
11562
  const options = {
11418
11563
  hostname: url.hostname,
@@ -11422,8 +11567,8 @@ var TrialAwareOTLPExporter = class {
11422
11567
  headers: {
11423
11568
  ...this._headers,
11424
11569
  host: url.host,
11425
- "Content-Type": "application/json",
11426
- "Content-Length": typeof data === "string" ? Buffer.byteLength(data) : data.byteLength
11570
+ "Content-Type": "application/x-protobuf",
11571
+ "Content-Length": requestBytes
11427
11572
  }
11428
11573
  };
11429
11574
  const lib = url.protocol === "https:" ? https : http;
@@ -11434,6 +11579,16 @@ var TrialAwareOTLPExporter = class {
11434
11579
  if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
11435
11580
  resultCallback({ code: ExportResultCode.SUCCESS });
11436
11581
  } else {
11582
+ NetraLogger.notice(
11583
+ "warn",
11584
+ formatExportFailure(
11585
+ res.statusCode,
11586
+ res.statusMessage,
11587
+ body,
11588
+ spans.length,
11589
+ requestBytes
11590
+ )
11591
+ );
11437
11592
  this.checkErrorBody(body, res.statusCode);
11438
11593
  resultCallback({
11439
11594
  code: ExportResultCode.FAILED,
@@ -11442,10 +11597,13 @@ var TrialAwareOTLPExporter = class {
11442
11597
  }
11443
11598
  });
11444
11599
  });
11445
- req.on(
11446
- "error",
11447
- (err) => resultCallback({ code: ExportResultCode.FAILED, error: err })
11448
- );
11600
+ req.on("error", (err) => {
11601
+ NetraLogger.notice(
11602
+ "warn",
11603
+ `Span export failed: ${err.message}. Dropped a batch of ${spans.length} spans (${requestBytes} bytes).`
11604
+ );
11605
+ resultCallback({ code: ExportResultCode.FAILED, error: err });
11606
+ });
11449
11607
  req.write(data);
11450
11608
  req.end();
11451
11609
  }
@@ -11499,7 +11657,7 @@ function patchTraceloopLangchainCallbackHandler() {
11499
11657
  const parentRunId = args[3];
11500
11658
  const parentSpan = parentRunId ? this?.spans?.get(parentRunId)?.span : void 0;
11501
11659
  const active = trace.getSpan(context.active());
11502
- Logger.debug(
11660
+ NetraLogger.debug(
11503
11661
  `Traceloop ${methodName}: runId=${args[2]} parentRunId=${parentRunId} parentSpan=${parentSpan ? "yes" : "no"} activeSpanId=${active?.spanContext().spanId}`
11504
11662
  );
11505
11663
  const ctx = parentSpan ? trace.setSpan(context.active(), parentSpan) : context.active();
@@ -11511,15 +11669,15 @@ function patchTraceloopLangchainCallbackHandler() {
11511
11669
  wrapWithParentContext("handleChatModelStart");
11512
11670
  wrapWithParentContext("handleToolStart");
11513
11671
  Handler.__netra_patched = true;
11514
- Logger.debug(`Patched TraceloopCallbackHandler for parent context (${sourceLabel}).`);
11672
+ NetraLogger.debug(`Patched TraceloopCallbackHandler for parent context (${sourceLabel}).`);
11515
11673
  };
11516
11674
  try {
11517
11675
  const mod = require3("@traceloop/instrumentation-langchain");
11518
- 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")}`);
11519
11677
  applyPatch(mod, "require");
11520
11678
  return;
11521
11679
  } catch (e) {
11522
- Logger.debug("require() for traceloop langchain failed, falling back to import().");
11680
+ NetraLogger.debug("require() for traceloop langchain failed, falling back to import().");
11523
11681
  }
11524
11682
  import('@traceloop/instrumentation-langchain').then((mod) => {
11525
11683
  applyPatch(mod, "import");
@@ -11559,21 +11717,23 @@ function disableTraceloopLangchainCallbackHandler() {
11559
11717
  );
11560
11718
  };
11561
11719
  CallbackManager.__netra_disable_traceloop = true;
11562
- Logger.debug("Disabled Traceloop LangChain callback injection.");
11720
+ NetraLogger.debug("Disabled Traceloop LangChain callback injection.");
11563
11721
  } catch {
11564
11722
  }
11565
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).";
11566
11725
  function resolveRootInstrumentNames(rootInstruments, blockInstruments) {
11567
11726
  const allSentinel = "__all__" /* ALL */;
11568
11727
  const rootHasAll = rootInstruments != null && rootInstruments.has(allSentinel);
11569
11728
  const blockHasAll = blockInstruments != null && blockInstruments.has(allSentinel);
11570
11729
  if (blockHasAll) {
11571
11730
  if (rootHasAll) {
11572
- Logger.error(
11731
+ NetraLogger.notice(
11732
+ "error",
11573
11733
  "Netra: rootInstruments=ALL is contradicted by blockInstruments=ALL; all root instrumentation is disabled."
11574
11734
  );
11575
11735
  } else {
11576
- Logger.warn(
11736
+ NetraLogger.warn(
11577
11737
  "Netra: blockInstruments contains ALL; all instrumentation will be disabled."
11578
11738
  );
11579
11739
  }
@@ -11703,12 +11863,12 @@ function initInstrumentations(config, instruments, blockInstruments, rootInstrum
11703
11863
  if (blockAll || blockInstruments.has("together" /* TOGETHER */)) instrumentModules.together = false;
11704
11864
  }
11705
11865
  config.setTraceloopEnv();
11706
- Logger.debug("Netra SDK Configuration:");
11707
- Logger.debug(` App Name: ${config.appName}`);
11708
- Logger.debug(` OTLP Endpoint: ${config.otlpEndpoint || "(default - localhost:3002)"}`);
11709
- Logger.debug(` API Key: ${config.apiKey ? "***" + config.apiKey.slice(-4) : "(not set)"}`);
11710
- Logger.debug(` Trace Content: ${config.traceContent}`);
11711
- 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}`);
11712
11872
  const traceloopOptions = {
11713
11873
  appName: config.appName,
11714
11874
  apiKey: config.apiKey,
@@ -11721,6 +11881,7 @@ function initInstrumentations(config, instruments, blockInstruments, rootInstrum
11721
11881
  };
11722
11882
  let exporter;
11723
11883
  if (!traceloopOptions.baseUrl || traceloopOptions.baseUrl == void 0) {
11884
+ NetraLogger.notice("warn", MISSING_ENDPOINT_NOTICE);
11724
11885
  exporter = new ConsoleSpanExporter();
11725
11886
  } else {
11726
11887
  const formattedEndpoint = config.formatOtlpEndpoint();
@@ -11771,33 +11932,33 @@ async function initCustomInstrumentationsAsync(config, tracerProvider, customIns
11771
11932
  if (customInstrumentModules.mistral) {
11772
11933
  try {
11773
11934
  await mistralAIInstrumentor.instrumentAsync({ tracerProvider });
11774
- Logger.debug("Custom MistralAI instrumentation enabled");
11935
+ NetraLogger.debug("Custom MistralAI instrumentation enabled");
11775
11936
  } catch (e) {
11776
- Logger.debug("Failed to initialize custom MistralAI instrumentation:", e);
11937
+ NetraLogger.debug("Failed to initialize custom MistralAI instrumentation:", e);
11777
11938
  }
11778
11939
  }
11779
11940
  if (customInstrumentModules.openai) {
11780
11941
  try {
11781
11942
  await openAIInstrumentor.instrument({ tracerProvider });
11782
- Logger.debug("Custom OpenAI instrumentation enabled");
11943
+ NetraLogger.debug("Custom OpenAI instrumentation enabled");
11783
11944
  } catch (e) {
11784
- Logger.debug("Failed to initialize custom OpenAI instrumentation:", e);
11945
+ NetraLogger.debug("Failed to initialize custom OpenAI instrumentation:", e);
11785
11946
  }
11786
11947
  }
11787
11948
  if (customInstrumentModules.groq) {
11788
11949
  try {
11789
11950
  await groqInstrumentor.instrumentAsync({ tracerProvider });
11790
- Logger.debug("Custom Groq instrumentation enabled");
11951
+ NetraLogger.debug("Custom Groq instrumentation enabled");
11791
11952
  } catch (e) {
11792
- Logger.debug("Failed to initialize custom Groq instrumentation:", e);
11953
+ NetraLogger.debug("Failed to initialize custom Groq instrumentation:", e);
11793
11954
  }
11794
11955
  }
11795
11956
  if (customInstrumentModules.googleGenAI) {
11796
11957
  try {
11797
11958
  await googleGenAIInstrumentor.instrument({ tracerProvider });
11798
- Logger.debug("Custom Google GenAI instrumentation enabled");
11959
+ NetraLogger.debug("Custom Google GenAI instrumentation enabled");
11799
11960
  } catch (e) {
11800
- Logger.debug(
11961
+ NetraLogger.debug(
11801
11962
  "Failed to initialize custom Google GenAI instrumentation:",
11802
11963
  e
11803
11964
  );
@@ -11806,33 +11967,33 @@ async function initCustomInstrumentationsAsync(config, tracerProvider, customIns
11806
11967
  if (customInstrumentModules.googleGenerativeAI) {
11807
11968
  try {
11808
11969
  await googleGenerativeAIInstrumentor.instrument({ tracerProvider });
11809
- Logger.debug("Custom Google Generative AI instrumentation enabled");
11970
+ NetraLogger.debug("Custom Google Generative AI instrumentation enabled");
11810
11971
  } catch (e) {
11811
- Logger.debug("Failed to initialize custom Google Generative AI instrumentation:", e);
11972
+ NetraLogger.debug("Failed to initialize custom Google Generative AI instrumentation:", e);
11812
11973
  }
11813
11974
  }
11814
11975
  if (customInstrumentModules.langgraph) {
11815
11976
  try {
11816
11977
  await langgraphInstrumentor.instrument({ tracerProvider });
11817
- Logger.debug("Custom Langgraph instrumentation enabled");
11978
+ NetraLogger.debug("Custom Langgraph instrumentation enabled");
11818
11979
  } catch (e) {
11819
- Logger.debug("Failed to initialize custom Langgraph instrumentation:", e);
11980
+ NetraLogger.debug("Failed to initialize custom Langgraph instrumentation:", e);
11820
11981
  }
11821
11982
  }
11822
11983
  if (customInstrumentModules.anthropic) {
11823
11984
  try {
11824
11985
  await anthropicInstrumentor.instrument({ tracerProvider });
11825
- Logger.debug("Custom Anthropic instrumentation enabled");
11986
+ NetraLogger.debug("Custom Anthropic instrumentation enabled");
11826
11987
  } catch (e) {
11827
- Logger.debug("Failed to initialize custom Anthropic instrumentation:", e);
11988
+ NetraLogger.debug("Failed to initialize custom Anthropic instrumentation:", e);
11828
11989
  }
11829
11990
  }
11830
11991
  if (customInstrumentModules.openAiAgents && !blockInstruments?.has("openai_agents" /* OPENAI_AGENTS */)) {
11831
11992
  try {
11832
11993
  await openaiAgentsInstrumentor.instrument({ tracerProvider });
11833
- Logger.debug("Custom OpenAI Agents SDK instrumentation enabled");
11994
+ NetraLogger.debug("Custom OpenAI Agents SDK instrumentation enabled");
11834
11995
  } catch (e) {
11835
- Logger.debug("Failed to initialize custom OpenAI Agents SDK instrumentation:", e);
11996
+ NetraLogger.debug("Failed to initialize custom OpenAI Agents SDK instrumentation:", e);
11836
11997
  }
11837
11998
  }
11838
11999
  }
@@ -11843,14 +12004,14 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11843
12004
  netraHost = new URL(config.otlpEndpoint).host;
11844
12005
  }
11845
12006
  } catch {
11846
- 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`);
11847
12008
  }
11848
12009
  const excludeRegexes = (process.env.OTEL_NODE_EXCLUDED_URLS || "").split(",").map((s) => s.trim()).filter(Boolean).map((pattern) => {
11849
12010
  try {
11850
12011
  return new RegExp(pattern);
11851
12012
  } catch {
11852
12013
  if (config.debugMode) {
11853
- Logger.debug(
12014
+ NetraLogger.debug(
11854
12015
  `Invalid OTEL_NODE_EXCLUDED_URLS pattern skipped: ${pattern}`
11855
12016
  );
11856
12017
  }
@@ -11873,10 +12034,10 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11873
12034
  });
11874
12035
  registerInstrumentations({ instrumentations: [_httpInstrumentation] });
11875
12036
  if (config.debugMode) {
11876
- Logger.debug("HTTP instrumentation enabled");
12037
+ NetraLogger.debug("HTTP instrumentation enabled");
11877
12038
  }
11878
12039
  } catch (e) {
11879
- Logger.debug("HTTP instrumentation not available:", e);
12040
+ NetraLogger.debug("HTTP instrumentation not available:", e);
11880
12041
  }
11881
12042
  }
11882
12043
  const fetchEnabled = !isBlocked("http" /* HTTP */, blockInstruments) && resolved.has("http" /* HTTP */);
@@ -11892,11 +12053,11 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11892
12053
  });
11893
12054
  registerInstrumentations({ instrumentations: [_undiciInstrumentation] });
11894
12055
  if (config.debugMode) {
11895
- Logger.debug("Undici/fetch instrumentation enabled");
12056
+ NetraLogger.debug("Undici/fetch instrumentation enabled");
11896
12057
  }
11897
12058
  } catch (e) {
11898
12059
  if (config.debugMode) {
11899
- Logger.debug("Undici/fetch instrumentation not available:", e);
12060
+ NetraLogger.debug("Undici/fetch instrumentation not available:", e);
11900
12061
  }
11901
12062
  }
11902
12063
  }
@@ -11904,14 +12065,14 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11904
12065
  try {
11905
12066
  const { PrismaInstrumentation } = require3("@prisma/instrumentation");
11906
12067
  } catch (e) {
11907
- Logger.debug("Prisma instrumentation not available:", e);
12068
+ NetraLogger.debug("Prisma instrumentation not available:", e);
11908
12069
  }
11909
12070
  }
11910
12071
  if (!isBlocked("typeorm" /* TYPEORM */, blockInstruments) && resolved.has("typeorm" /* TYPEORM */) && isPackageInstalled("typeorm")) {
11911
12072
  typeORMInstrumentor.instrument().then(() => {
11912
- Logger.debug("TypeORM instrumentation successfully initialized");
12073
+ NetraLogger.debug("TypeORM instrumentation successfully initialized");
11913
12074
  }).catch((e) => {
11914
- Logger.debug("TypeORM instrumentation error:", e);
12075
+ NetraLogger.debug("TypeORM instrumentation error:", e);
11915
12076
  });
11916
12077
  }
11917
12078
  if (!isBlocked("express" /* EXPRESS */, blockInstruments) && resolved.has("express" /* EXPRESS */)) {
@@ -11920,10 +12081,10 @@ function initOpenTelemetryInstrumentations(config, resolved, blockInstruments) {
11920
12081
  const { registerInstrumentations } = require3("@opentelemetry/instrumentation");
11921
12082
  registerInstrumentations({ instrumentations: [new ExpressInstrumentation()] });
11922
12083
  if (config.debugMode) {
11923
- Logger.debug("Express instrumentation enabled");
12084
+ NetraLogger.debug("Express instrumentation enabled");
11924
12085
  }
11925
12086
  } catch (e) {
11926
- Logger.debug("Express instrumentation not available:", e);
12087
+ NetraLogger.debug("Express instrumentation not available:", e);
11927
12088
  }
11928
12089
  }
11929
12090
  }
@@ -11958,7 +12119,7 @@ function addCustomSpanProcessors(tracerProvider, config, rootInstrumentNames) {
11958
12119
  }
11959
12120
  }
11960
12121
  if (!provider) {
11961
- Logger.debug(
12122
+ NetraLogger.debug(
11962
12123
  "Could not access TracerProvider for adding span processors. Session context will still be propagated via baggage."
11963
12124
  );
11964
12125
  return null;
@@ -11987,10 +12148,10 @@ function addCustomSpanProcessors(tracerProvider, config, rootInstrumentNames) {
11987
12148
  provider.addSpanProcessor(llmTraceProcessor);
11988
12149
  const rootSpanProcessor = new RootSpanProcessor();
11989
12150
  provider.addSpanProcessor(rootSpanProcessor);
11990
- Logger.debug("Custom span processors registered successfully");
12151
+ NetraLogger.debug("Custom span processors registered successfully");
11991
12152
  return provider;
11992
12153
  } catch (e) {
11993
- Logger.debug("Failed to add custom span processors:", e);
12154
+ NetraLogger.debug("Failed to add custom span processors:", e);
11994
12155
  return null;
11995
12156
  }
11996
12157
  }
@@ -11998,92 +12159,92 @@ async function uninstrumentAll() {
11998
12159
  try {
11999
12160
  if (openAIInstrumentor.isInstrumented()) {
12000
12161
  await openAIInstrumentor.uninstrument();
12001
- Logger.debug("Custom OpenAI instrumentation disabled");
12162
+ NetraLogger.debug("Custom OpenAI instrumentation disabled");
12002
12163
  }
12003
12164
  } catch (e) {
12004
- Logger.debug("Failed to uninstrument OpenAI:", e);
12165
+ NetraLogger.debug("Failed to uninstrument OpenAI:", e);
12005
12166
  }
12006
12167
  try {
12007
12168
  if (mistralAIInstrumentor.isInstrumented()) {
12008
12169
  mistralAIInstrumentor.uninstrument();
12009
- Logger.debug("Custom MistralAI instrumentation disabled");
12170
+ NetraLogger.debug("Custom MistralAI instrumentation disabled");
12010
12171
  }
12011
12172
  } catch (e) {
12012
- Logger.debug("Failed to uninstrument MistralAI:", e);
12173
+ NetraLogger.debug("Failed to uninstrument MistralAI:", e);
12013
12174
  }
12014
12175
  try {
12015
12176
  if (groqInstrumentor.isInstrumented()) {
12016
12177
  groqInstrumentor.uninstrument();
12017
- Logger.debug("Custom Groq instrumentation disabled");
12178
+ NetraLogger.debug("Custom Groq instrumentation disabled");
12018
12179
  }
12019
12180
  } catch (e) {
12020
- Logger.debug("Failed to uninstrument Groq:", e);
12181
+ NetraLogger.debug("Failed to uninstrument Groq:", e);
12021
12182
  }
12022
12183
  try {
12023
12184
  if (anthropicInstrumentor.isInstrumented()) {
12024
12185
  anthropicInstrumentor.uninstrument();
12025
- Logger.debug("Custom Anthropic instrumentation disabled");
12186
+ NetraLogger.debug("Custom Anthropic instrumentation disabled");
12026
12187
  }
12027
12188
  } catch (e) {
12028
- Logger.debug("Failed to uninstrument Anthropic:", e);
12189
+ NetraLogger.debug("Failed to uninstrument Anthropic:", e);
12029
12190
  }
12030
12191
  try {
12031
12192
  if (googleGenAIInstrumentor.isInstrumented()) {
12032
12193
  googleGenAIInstrumentor.uninstrument();
12033
- Logger.debug("Custom Google GenAI instrumentation disabled");
12194
+ NetraLogger.debug("Custom Google GenAI instrumentation disabled");
12034
12195
  }
12035
12196
  } catch (e) {
12036
- Logger.debug("Failed to uninstrument Google GenAI:", e);
12197
+ NetraLogger.debug("Failed to uninstrument Google GenAI:", e);
12037
12198
  }
12038
12199
  try {
12039
12200
  if (googleGenerativeAIInstrumentor.isInstrumented()) {
12040
12201
  googleGenerativeAIInstrumentor.uninstrument();
12041
- Logger.debug("Custom Google Generative AI instrumentation disabled");
12202
+ NetraLogger.debug("Custom Google Generative AI instrumentation disabled");
12042
12203
  }
12043
12204
  } catch (e) {
12044
- Logger.debug("Failed to uninstrument Google Generative AI:", e);
12205
+ NetraLogger.debug("Failed to uninstrument Google Generative AI:", e);
12045
12206
  }
12046
12207
  try {
12047
12208
  if (langgraphInstrumentor.isInstrumented()) {
12048
12209
  await langgraphInstrumentor.uninstrument();
12049
- Logger.debug("Custom Langgraph instrumentation disabled");
12210
+ NetraLogger.debug("Custom Langgraph instrumentation disabled");
12050
12211
  }
12051
12212
  } catch (e) {
12052
- Logger.debug("Failed to uninstrument Langgraph:", e);
12213
+ NetraLogger.debug("Failed to uninstrument Langgraph:", e);
12053
12214
  }
12054
12215
  try {
12055
12216
  if (typeORMInstrumentor.isInstrumented()) {
12056
12217
  typeORMInstrumentor.uninstrument();
12057
- Logger.debug("Custom TypeORM instrumentation disabled");
12218
+ NetraLogger.debug("Custom TypeORM instrumentation disabled");
12058
12219
  }
12059
12220
  } catch (e) {
12060
- Logger.debug("Failed to uninstrument TypeORM:", e);
12221
+ NetraLogger.debug("Failed to uninstrument TypeORM:", e);
12061
12222
  }
12062
12223
  try {
12063
12224
  if (openaiAgentsInstrumentor.isInstrumented()) {
12064
12225
  openaiAgentsInstrumentor.uninstrument();
12065
- Logger.debug("Custom OpenAI Agents SDK instrumentation disabled");
12226
+ NetraLogger.debug("Custom OpenAI Agents SDK instrumentation disabled");
12066
12227
  }
12067
12228
  } catch (e) {
12068
- Logger.debug("Failed to uninstrument OpenAI Agents SDK:", e);
12229
+ NetraLogger.debug("Failed to uninstrument OpenAI Agents SDK:", e);
12069
12230
  }
12070
12231
  try {
12071
12232
  if (_httpInstrumentation) {
12072
12233
  _httpInstrumentation.disable();
12073
12234
  _httpInstrumentation = null;
12074
- Logger.debug("HTTP instrumentation disabled");
12235
+ NetraLogger.debug("HTTP instrumentation disabled");
12075
12236
  }
12076
12237
  } catch (e) {
12077
- Logger.debug("Failed to uninstrument HTTP:", e);
12238
+ NetraLogger.debug("Failed to uninstrument HTTP:", e);
12078
12239
  }
12079
12240
  try {
12080
12241
  if (_undiciInstrumentation) {
12081
12242
  _undiciInstrumentation.disable();
12082
12243
  _undiciInstrumentation = null;
12083
- Logger.debug("Undici/fetch instrumentation disabled");
12244
+ NetraLogger.debug("Undici/fetch instrumentation disabled");
12084
12245
  }
12085
12246
  } catch (e) {
12086
- Logger.debug("Failed to uninstrument undici:", e);
12247
+ NetraLogger.debug("Failed to uninstrument undici:", e);
12087
12248
  }
12088
12249
  }
12089
12250
 
@@ -12248,11 +12409,11 @@ var onSignal = (sig) => {
12248
12409
  if (firing) {
12249
12410
  const handled2 = process.listeners(sig).some((l) => !ours.has(l));
12250
12411
  if (!handled2 && sig === appOwnedSignal && !handedBack) {
12251
- 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`);
12252
12413
  handedBack = sig;
12253
12414
  return;
12254
12415
  }
12255
- Logger.debug(`netra: second ${sig} during shutdown; exiting now`);
12416
+ NetraLogger.debug(`netra: second ${sig} during shutdown; exiting now`);
12256
12417
  generation++;
12257
12418
  firing = false;
12258
12419
  uninstall();
@@ -12266,9 +12427,9 @@ var onSignal = (sig) => {
12266
12427
  }
12267
12428
  const handled = appHandles(sig);
12268
12429
  const gen = startFire(handled ? sig : void 0);
12269
- Logger.log(`
12430
+ NetraLogger.log(`
12270
12431
  Received ${sig}. Flushing Netra SDK...`);
12271
- 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(() => {
12272
12433
  if (gen !== generation) {
12273
12434
  return;
12274
12435
  }
@@ -12302,8 +12463,8 @@ var onUncaughtException = (error) => {
12302
12463
  return;
12303
12464
  }
12304
12465
  const gen = startFire();
12305
- Logger.error("Uncaught exception; flushing Netra SDK before exit...");
12306
- 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(() => {
12307
12468
  if (gen !== generation) {
12308
12469
  return;
12309
12470
  }
@@ -12324,7 +12485,7 @@ var onUnhandledRejection = (reason) => {
12324
12485
  }
12325
12486
  if (!appHandles("uncaughtException")) {
12326
12487
  const gen = startFire();
12327
- 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(() => {
12328
12489
  if (gen !== generation) {
12329
12490
  return;
12330
12491
  }
@@ -12354,11 +12515,11 @@ var MAX_FILE_DOWNLOAD_WORKERS = 8;
12354
12515
  var _cachedFileDownloadTimeoutMs = null;
12355
12516
  function validateSimulationInputs(datasetId, task2) {
12356
12517
  if (!datasetId) {
12357
- Logger.error(`${LOG_PREFIX4}: dataset_id is required`);
12518
+ NetraLogger.notice("error", `${LOG_PREFIX4}: dataset_id is required`);
12358
12519
  return false;
12359
12520
  }
12360
12521
  if (!(task2 instanceof BaseTask)) {
12361
- Logger.error(`${LOG_PREFIX4}: task must be a BaseTask instance`);
12522
+ NetraLogger.notice("error", `${LOG_PREFIX4}: task must be a BaseTask instance`);
12362
12523
  return false;
12363
12524
  }
12364
12525
  return true;
@@ -12374,7 +12535,8 @@ function _getFileDownloadTimeout() {
12374
12535
  _cachedFileDownloadTimeoutMs = parsed * 1e3;
12375
12536
  return _cachedFileDownloadTimeoutMs;
12376
12537
  }
12377
- Logger.warn(
12538
+ NetraLogger.notice(
12539
+ "warn",
12378
12540
  `${LOG_PREFIX4}: Invalid file download timeout '${envVal}', using default ${DEFAULT_FILE_DOWNLOAD_TIMEOUT_S}s`
12379
12541
  );
12380
12542
  }
@@ -12403,7 +12565,8 @@ async function _downloadSingleFile(fileData, timeoutMs, signal) {
12403
12565
  }
12404
12566
  const status = axios.isAxiosError(error) ? error.response?.status : void 0;
12405
12567
  const reason = status ? `HTTP ${status}` : error instanceof Error ? error.message : String(error);
12406
- Logger.error(
12568
+ NetraLogger.notice(
12569
+ "error",
12407
12570
  `${LOG_PREFIX4}: Failed to download file '${fileData.fileName}': ${reason}`
12408
12571
  );
12409
12572
  throw new Error(
@@ -12420,7 +12583,7 @@ function parseFiles(rawFiles) {
12420
12583
  const fileName = entry.fileName || "";
12421
12584
  const downloadUrl = entry.downloadUrl || "";
12422
12585
  if (!fileName || !downloadUrl) {
12423
- Logger.warn(
12586
+ NetraLogger.warn(
12424
12587
  `${LOG_PREFIX4}: Skipping malformed file attachment (missing fileName or downloadUrl)`
12425
12588
  );
12426
12589
  continue;
@@ -12478,7 +12641,7 @@ var SimulationHttpClient = class {
12478
12641
  _createClient(config) {
12479
12642
  const endpoint = (config.otlpEndpoint || "").trim();
12480
12643
  if (!endpoint) {
12481
- Logger.error(`${LOG_PREFIX5}: NETRA_OTLP_ENDPOINT is required`);
12644
+ NetraLogger.debug(`${LOG_PREFIX5}: NETRA_OTLP_ENDPOINT is required`);
12482
12645
  return null;
12483
12646
  }
12484
12647
  const baseURL = this._resolveBaseUrl(endpoint);
@@ -12500,7 +12663,7 @@ var SimulationHttpClient = class {
12500
12663
  );
12501
12664
  return instance;
12502
12665
  } catch (error) {
12503
- Logger.error(`${LOG_PREFIX5}: Failed to create HTTP client:`, error);
12666
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Failed to create HTTP client:`, error);
12504
12667
  return null;
12505
12668
  }
12506
12669
  }
@@ -12534,7 +12697,8 @@ var SimulationHttpClient = class {
12534
12697
  }
12535
12698
  const timeout = parseFloat(timeoutStr);
12536
12699
  if (isNaN(timeout)) {
12537
- Logger.warn(
12700
+ NetraLogger.notice(
12701
+ "warn",
12538
12702
  `${LOG_PREFIX5}: Invalid timeout '${timeoutStr}', using default ${DEFAULT_TIMEOUT}ms`
12539
12703
  );
12540
12704
  return DEFAULT_TIMEOUT;
@@ -12549,7 +12713,7 @@ var SimulationHttpClient = class {
12549
12713
  */
12550
12714
  async initializeRun(name, datasetId, context16, hooksMeta) {
12551
12715
  if (!this.client) {
12552
- Logger.error(`${LOG_PREFIX5}: Client not initialized`);
12716
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Client not initialized`);
12553
12717
  return null;
12554
12718
  }
12555
12719
  try {
@@ -12567,7 +12731,7 @@ var SimulationHttpClient = class {
12567
12731
  const responseData = data.data || {};
12568
12732
  const items = responseData.items || [];
12569
12733
  if (items.length === 0) {
12570
- Logger.warn(`${LOG_PREFIX5}: No items returned from initialize_run`);
12734
+ NetraLogger.warn(`${LOG_PREFIX5}: No items returned from initialize_run`);
12571
12735
  return null;
12572
12736
  }
12573
12737
  const runId = responseData.id || "";
@@ -12580,7 +12744,7 @@ var SimulationHttpClient = class {
12580
12744
  };
12581
12745
  } catch (error) {
12582
12746
  const errorMsg = this._extractErrorMessage(error);
12583
- Logger.error(`${LOG_PREFIX5}: Failed to initialize run:`, errorMsg);
12747
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Failed to initialize run:`, errorMsg);
12584
12748
  return null;
12585
12749
  }
12586
12750
  }
@@ -12591,7 +12755,7 @@ var SimulationHttpClient = class {
12591
12755
  */
12592
12756
  async generateFirstTurn(runId, runItemId) {
12593
12757
  if (!this.client) {
12594
- Logger.error(`${LOG_PREFIX5}: Client not initialized`);
12758
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Client not initialized`);
12595
12759
  return null;
12596
12760
  }
12597
12761
  try {
@@ -12608,7 +12772,8 @@ var SimulationHttpClient = class {
12608
12772
  };
12609
12773
  } catch (error) {
12610
12774
  const errorMsg = this._extractErrorMessage(error);
12611
- Logger.error(
12775
+ NetraLogger.notice(
12776
+ "error",
12612
12777
  `${LOG_PREFIX5}: Failed to generate first turn for item ${runItemId}:`,
12613
12778
  errorMsg
12614
12779
  );
@@ -12620,7 +12785,7 @@ var SimulationHttpClient = class {
12620
12785
  */
12621
12786
  async triggerConversation(message, turnId, sessionId, traceId) {
12622
12787
  if (!this.client) {
12623
- Logger.error(`${LOG_PREFIX5}: Client not initialized`);
12788
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Client not initialized`);
12624
12789
  return null;
12625
12790
  }
12626
12791
  try {
@@ -12643,7 +12808,7 @@ var SimulationHttpClient = class {
12643
12808
  }
12644
12809
  const userMessages = responseData.userMessages || [];
12645
12810
  if (userMessages.length === 0) {
12646
- Logger.warn(`${LOG_PREFIX5}: No user messages in continue response`);
12811
+ NetraLogger.warn(`${LOG_PREFIX5}: No user messages in continue response`);
12647
12812
  return null;
12648
12813
  }
12649
12814
  const nextMsg = userMessages[0];
@@ -12656,7 +12821,7 @@ var SimulationHttpClient = class {
12656
12821
  };
12657
12822
  } catch (error) {
12658
12823
  const errorMsg = this._extractErrorMessage(error);
12659
- Logger.error(`${LOG_PREFIX5}: Failed to trigger conversation:`, errorMsg);
12824
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Failed to trigger conversation:`, errorMsg);
12660
12825
  return null;
12661
12826
  }
12662
12827
  }
@@ -12675,17 +12840,17 @@ var SimulationHttpClient = class {
12675
12840
  */
12676
12841
  async reportFailure(runId, runItemId, error, status = "failed") {
12677
12842
  if (!this.client) {
12678
- Logger.error(`${LOG_PREFIX5}: Client not initialized`);
12843
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Client not initialized`);
12679
12844
  return;
12680
12845
  }
12681
12846
  try {
12682
12847
  const url = apiPath`/evaluations/run/${runId}/item/${runItemId}/status`;
12683
12848
  const payload = { status, failureReason: error };
12684
12849
  await this.client.patch(url, payload);
12685
- Logger.info(`${LOG_PREFIX5}: Reported failure - ${error}`);
12850
+ NetraLogger.info(`${LOG_PREFIX5}: Reported failure - ${error}`);
12686
12851
  } catch (err) {
12687
12852
  const errorMsg = this._extractErrorMessage(err);
12688
- Logger.error(`${LOG_PREFIX5}: Failed to report failure:`, errorMsg);
12853
+ NetraLogger.notice("error", `${LOG_PREFIX5}: Failed to report failure:`, errorMsg);
12689
12854
  }
12690
12855
  }
12691
12856
  /**
@@ -12693,7 +12858,8 @@ var SimulationHttpClient = class {
12693
12858
  */
12694
12859
  async postRunStatus(runId, status) {
12695
12860
  if (!this.client) {
12696
- Logger.error(
12861
+ NetraLogger.notice(
12862
+ "error",
12697
12863
  `${LOG_PREFIX5}: Client not initialized; cannot post run status`
12698
12864
  );
12699
12865
  return { success: false };
@@ -12704,13 +12870,14 @@ var SimulationHttpClient = class {
12704
12870
  const response = await this.client.post(url, payload);
12705
12871
  const data = response.data;
12706
12872
  if (data && typeof data === "object" && "data" in data) {
12707
- Logger.info(`${LOG_PREFIX5}: Completed test run successfully`);
12873
+ NetraLogger.info(`${LOG_PREFIX5}: Completed test run successfully`);
12708
12874
  return data.data || {};
12709
12875
  }
12710
12876
  return data;
12711
12877
  } catch (error) {
12712
12878
  const errorMsg = this._extractErrorMessage(error);
12713
- Logger.error(
12879
+ NetraLogger.notice(
12880
+ "error",
12714
12881
  `${LOG_PREFIX5}: Failed to post run status for run '${runId}':`,
12715
12882
  errorMsg
12716
12883
  );
@@ -12780,10 +12947,11 @@ function describeHooks(hooks) {
12780
12947
  }
12781
12948
  async function runBeforeAll(hooks) {
12782
12949
  if (!hooks?.beforeAll) return null;
12783
- Logger.info(`${LOG_PREFIX6}: running beforeAll hook`);
12950
+ NetraLogger.info(`${LOG_PREFIX6}: running beforeAll hook`);
12784
12951
  const result = await hooks.beforeAll();
12785
12952
  if (result !== null && result !== void 0 && typeof result !== "object") {
12786
- Logger.warn(
12953
+ NetraLogger.notice(
12954
+ "warn",
12787
12955
  `${LOG_PREFIX6}: beforeAll returned ${typeof result} (expected object or null); ignoring value`
12788
12956
  );
12789
12957
  return null;
@@ -12792,7 +12960,7 @@ async function runBeforeAll(hooks) {
12792
12960
  }
12793
12961
  async function runBefore(hooks, datasetItemId, sharedContext) {
12794
12962
  if (hooks?.before && datasetItemId in hooks.before) {
12795
- Logger.info(
12963
+ NetraLogger.info(
12796
12964
  `${LOG_PREFIX6}: running before hook for datasetItemId=${datasetItemId}`
12797
12965
  );
12798
12966
  const itemHook = hooks.before[datasetItemId];
@@ -12802,7 +12970,8 @@ async function runBefore(hooks, datasetItemId, sharedContext) {
12802
12970
  if (typeof result === "object") {
12803
12971
  Object.assign(base, result);
12804
12972
  } else {
12805
- Logger.warn(
12973
+ NetraLogger.notice(
12974
+ "warn",
12806
12975
  `${LOG_PREFIX6}: before hook returned ${typeof result} (expected object or null); ignoring value`
12807
12976
  );
12808
12977
  }
@@ -12813,7 +12982,7 @@ async function runBefore(hooks, datasetItemId, sharedContext) {
12813
12982
  }
12814
12983
  async function runBeforeEach(hooks, datasetItemId, sharedContext) {
12815
12984
  if (!hooks?.beforeEach) return sharedContext;
12816
- Logger.info(
12985
+ NetraLogger.info(
12817
12986
  `${LOG_PREFIX6}: running beforeEach hook for datasetItemId=${datasetItemId}`
12818
12987
  );
12819
12988
  const result = await hooks.beforeEach(sharedContext);
@@ -12822,7 +12991,8 @@ async function runBeforeEach(hooks, datasetItemId, sharedContext) {
12822
12991
  if (typeof result === "object") {
12823
12992
  Object.assign(base, result);
12824
12993
  } else {
12825
- Logger.warn(
12994
+ NetraLogger.notice(
12995
+ "warn",
12826
12996
  `${LOG_PREFIX6}: beforeEach hook returned ${typeof result} (expected object or null); ignoring value`
12827
12997
  );
12828
12998
  }
@@ -12831,7 +13001,7 @@ async function runBeforeEach(hooks, datasetItemId, sharedContext) {
12831
13001
  }
12832
13002
  async function runAfter(hooks, datasetItemId, itemResult, setupContext) {
12833
13003
  if (hooks?.after && datasetItemId in hooks.after) {
12834
- Logger.info(
13004
+ NetraLogger.info(
12835
13005
  `${LOG_PREFIX6}: running after hook for datasetItemId=${datasetItemId}`
12836
13006
  );
12837
13007
  await hooks.after[datasetItemId](itemResult, setupContext);
@@ -12839,14 +13009,14 @@ async function runAfter(hooks, datasetItemId, itemResult, setupContext) {
12839
13009
  }
12840
13010
  async function runAfterEach(hooks, datasetItemId, itemResult, setupContext) {
12841
13011
  if (!hooks?.afterEach) return;
12842
- Logger.info(
13012
+ NetraLogger.info(
12843
13013
  `${LOG_PREFIX6}: running afterEach hook for datasetItemId=${datasetItemId}`
12844
13014
  );
12845
13015
  await hooks.afterEach(itemResult, setupContext);
12846
13016
  }
12847
13017
  async function runAfterAll(hooks, results, sharedContext) {
12848
13018
  if (!hooks?.afterAll) return;
12849
- Logger.info(`${LOG_PREFIX6}: running afterAll hook`);
13019
+ NetraLogger.info(`${LOG_PREFIX6}: running afterAll hook`);
12850
13020
  await hooks.afterAll(results, sharedContext);
12851
13021
  }
12852
13022
 
@@ -12895,7 +13065,7 @@ var Simulation = class {
12895
13065
  }
12896
13066
  const { runId, items } = initResult;
12897
13067
  if (!items || items.length === 0) {
12898
- Logger.error(`${LOG_PREFIX7}: No items returned from initialize_run`);
13068
+ NetraLogger.notice("error", `${LOG_PREFIX7}: No items returned from initialize_run`);
12899
13069
  return null;
12900
13070
  }
12901
13071
  const unregisterExitTask = registerExitTask(
@@ -12909,7 +13079,7 @@ var Simulation = class {
12909
13079
  sharedContext = await runBeforeAll(hooks);
12910
13080
  } catch (error) {
12911
13081
  const errorMsg = `beforeAll hook failed: ${error instanceof Error ? error.message : String(error)}`;
12912
- Logger.error(`${LOG_PREFIX7}: ${errorMsg} \u2014 aborting run (no LLM spent)`);
13082
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg} \u2014 aborting run (no LLM spent)`);
12913
13083
  await this._reportFailures(
12914
13084
  runId,
12915
13085
  items.map((item) => item.runItemId),
@@ -12931,7 +13101,7 @@ var Simulation = class {
12931
13101
  await runAfterAll(hooks, results, null);
12932
13102
  } catch (afterAllError) {
12933
13103
  const afterAllMsg = `afterAll hook failed: ${afterAllError instanceof Error ? afterAllError.message : String(afterAllError)}`;
12934
- Logger.error(`${LOG_PREFIX7}: ${afterAllMsg}`);
13104
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${afterAllMsg}`);
12935
13105
  }
12936
13106
  await this._client.postRunStatus(runId, "completed");
12937
13107
  return results;
@@ -12954,7 +13124,7 @@ var Simulation = class {
12954
13124
  setupContexts.set(runItemId, setupContext);
12955
13125
  } catch (error) {
12956
13126
  const errorMsg = `before hook failed: ${error instanceof Error ? error.message : String(error)}`;
12957
- Logger.error(`${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13127
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
12958
13128
  await this._client.reportFailure(runId, runItemId, errorMsg, "prescript_failed");
12959
13129
  const itemResult = {
12960
13130
  runItemId,
@@ -12970,7 +13140,7 @@ var Simulation = class {
12970
13140
  }
12971
13141
  const simItem = await this._client.generateFirstTurn(runId, runItemId);
12972
13142
  if (!simItem) {
12973
- 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`);
12974
13144
  await this._client.reportFailure(runId, runItemId, "Failed to generate first user message");
12975
13145
  const itemResult = {
12976
13146
  runItemId,
@@ -12986,7 +13156,7 @@ var Simulation = class {
12986
13156
  );
12987
13157
  await Promise.all(setupPromises);
12988
13158
  if (simulationItems.length === 0) {
12989
- Logger.error(`${LOG_PREFIX7}: All items failed during setup/generation`);
13159
+ NetraLogger.notice("error", `${LOG_PREFIX7}: All items failed during setup/generation`);
12990
13160
  const results = {
12991
13161
  success: false,
12992
13162
  completed: [],
@@ -12997,12 +13167,12 @@ var Simulation = class {
12997
13167
  await runAfterAll(hooks, results, sharedContext);
12998
13168
  } catch (afterAllError) {
12999
13169
  const afterAllMsg = `afterAll hook failed: ${afterAllError instanceof Error ? afterAllError.message : String(afterAllError)}`;
13000
- Logger.error(`${LOG_PREFIX7}: ${afterAllMsg}`);
13170
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${afterAllMsg}`);
13001
13171
  }
13002
13172
  await this._client.postRunStatus(runId, "completed");
13003
13173
  return results;
13004
13174
  }
13005
- Logger.info(`${LOG_PREFIX7}: Starting simulation with ${simulationItems.length} items`);
13175
+ NetraLogger.info(`${LOG_PREFIX7}: Starting simulation with ${simulationItems.length} items`);
13006
13176
  try {
13007
13177
  const result = await this._runSimulationAsync(
13008
13178
  runId,
@@ -13015,11 +13185,11 @@ var Simulation = class {
13015
13185
  failedItems
13016
13186
  );
13017
13187
  const elapsedTime = ((Date.now() - startTime) / 1e3).toFixed(2);
13018
- Logger.info(`${LOG_PREFIX7}: Simulation completed in ${elapsedTime} seconds`);
13188
+ NetraLogger.info(`${LOG_PREFIX7}: Simulation completed in ${elapsedTime} seconds`);
13019
13189
  await this._client.postRunStatus(runId, "completed");
13020
13190
  return result;
13021
13191
  } catch (error) {
13022
- Logger.error(`${LOG_PREFIX7}: Run simulation failed`);
13192
+ NetraLogger.notice("error", `${LOG_PREFIX7}: Run simulation failed`);
13023
13193
  await this._client.postRunStatus(runId, "failed");
13024
13194
  throw error;
13025
13195
  }
@@ -13055,7 +13225,7 @@ var Simulation = class {
13055
13225
  results.failed.push(result);
13056
13226
  }
13057
13227
  processedCount++;
13058
- Logger.info(
13228
+ NetraLogger.info(
13059
13229
  `${LOG_PREFIX7}: ${processedCount}/${runItems.length} processed (run_item_id=${runItem.runItemId})`
13060
13230
  );
13061
13231
  return result;
@@ -13067,7 +13237,7 @@ var Simulation = class {
13067
13237
  await runAfterAll(hooks, results, sharedContext);
13068
13238
  } catch (error) {
13069
13239
  const errorMsg = `afterAll hook failed: ${error instanceof Error ? error.message : String(error)}`;
13070
- Logger.error(`${LOG_PREFIX7}: ${errorMsg}`);
13240
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg}`);
13071
13241
  const completed = results.completed;
13072
13242
  const successfulIds = completed.map((item) => item.runItemId);
13073
13243
  await this._reportFailures(
@@ -13086,7 +13256,7 @@ var Simulation = class {
13086
13256
  results.completed = [];
13087
13257
  }
13088
13258
  results.success = results.failed.length === 0;
13089
- Logger.info(
13259
+ NetraLogger.info(
13090
13260
  `${LOG_PREFIX7}: Completed=${results.completed.length}, Failed=${results.failed.length}`
13091
13261
  );
13092
13262
  return results;
@@ -13118,14 +13288,14 @@ var Simulation = class {
13118
13288
  await runAfter(hooks, datasetItemId, itemResult, setupContext);
13119
13289
  } catch (error) {
13120
13290
  const errorMsg = `after hook failed: ${error instanceof Error ? error.message : String(error)}`;
13121
- Logger.error(`${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13291
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13122
13292
  errors.push(errorMsg);
13123
13293
  }
13124
13294
  try {
13125
13295
  await runAfterEach(hooks, datasetItemId, itemResult, setupContext);
13126
13296
  } catch (error) {
13127
13297
  const errorMsg = `afterEach hook failed: ${error instanceof Error ? error.message : String(error)}`;
13128
- Logger.error(`${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13298
+ NetraLogger.notice("error", `${LOG_PREFIX7}: ${errorMsg} for runItemId=${runItemId}`);
13129
13299
  errors.push(errorMsg);
13130
13300
  }
13131
13301
  if (errors.length > 0 && itemResult.success) {
@@ -13188,7 +13358,7 @@ var Simulation = class {
13188
13358
  return itemResult;
13189
13359
  }
13190
13360
  if (response.decision === "stop") {
13191
- Logger.info(
13361
+ NetraLogger.info(
13192
13362
  `${LOG_PREFIX7}: Completed run_item_id=${runItemId} reason=${response.reason}`
13193
13363
  );
13194
13364
  const itemResult = {
@@ -13204,7 +13374,8 @@ var Simulation = class {
13204
13374
  rawFiles = response.nextFiles || [];
13205
13375
  } catch (error) {
13206
13376
  const errorMsg = error instanceof Error ? error.message : String(error);
13207
- Logger.error(
13377
+ NetraLogger.notice(
13378
+ "error",
13208
13379
  `${LOG_PREFIX7}: Task failed run_item_id=${runItemId}, turn_id=${turnId}: ${errorMsg}`
13209
13380
  );
13210
13381
  await this._client.reportFailure(runId, runItemId, errorMsg);
@@ -13238,7 +13409,7 @@ function spanHasOutput(span2) {
13238
13409
  if (attrs && typeof attrs === "object" && attrs["output"]) return true;
13239
13410
  }
13240
13411
  } catch (e) {
13241
- Logger.warn("spanHasOutput: error inspecting span attributes:", e);
13412
+ NetraLogger.warn("spanHasOutput: error inspecting span attributes:", e);
13242
13413
  }
13243
13414
  return false;
13244
13415
  }
@@ -13428,12 +13599,12 @@ var _Netra = class _Netra {
13428
13599
  await this._shutdownPromise;
13429
13600
  }
13430
13601
  if (this._initialized) {
13431
- Logger.warn("Netra.init() called more than once; ignoring subsequent calls.");
13602
+ NetraLogger.notice("warn", "Netra.init() called more than once; ignoring subsequent calls.");
13432
13603
  return;
13433
13604
  }
13434
13605
  const cfg = new Config(config);
13435
13606
  this._config = cfg;
13436
- Logger.setDebugMode(cfg.debugMode);
13607
+ NetraLogger.setDebugMode(cfg.debugMode);
13437
13608
  const effectiveProvider = initInstrumentations(
13438
13609
  cfg,
13439
13610
  config.instruments,
@@ -13445,35 +13616,35 @@ var _Netra = class _Netra {
13445
13616
  try {
13446
13617
  this.usage = new Usage(cfg);
13447
13618
  } catch (e) {
13448
- Logger.warn("Netra: failed to initialize usage client:", e);
13619
+ NetraLogger.warn("Netra: failed to initialize usage client:", e);
13449
13620
  }
13450
13621
  try {
13451
13622
  this.evaluation = new Evaluation(cfg);
13452
13623
  } catch (e) {
13453
- Logger.warn("Netra: failed to initialize evaluation client:", e);
13624
+ NetraLogger.warn("Netra: failed to initialize evaluation client:", e);
13454
13625
  }
13455
13626
  try {
13456
13627
  this.dashboard = new Dashboard(cfg);
13457
13628
  } catch (e) {
13458
- Logger.warn("Netra: failed to initialize dashboard client:", e);
13629
+ NetraLogger.warn("Netra: failed to initialize dashboard client:", e);
13459
13630
  }
13460
13631
  try {
13461
13632
  this.simulation = new Simulation(cfg);
13462
13633
  } catch (e) {
13463
- Logger.warn("Netra: failed to initialize simulation client:", e);
13634
+ NetraLogger.warn("Netra: failed to initialize simulation client:", e);
13464
13635
  }
13465
13636
  try {
13466
13637
  this.prompts = new Prompts(cfg);
13467
13638
  } catch (e) {
13468
- Logger.warn("Netra: failed to initialize prompts client:", e);
13639
+ NetraLogger.warn("Netra: failed to initialize prompts client:", e);
13469
13640
  }
13470
13641
  try {
13471
13642
  this.models = new Models(cfg);
13472
13643
  } catch (e) {
13473
- Logger.warn("Netra: failed to initialize models client:", e);
13644
+ NetraLogger.warn("Netra: failed to initialize models client:", e);
13474
13645
  }
13475
13646
  this._initialized = true;
13476
- Logger.info("Netra successfully initialized.");
13647
+ NetraLogger.info("Netra successfully initialized.");
13477
13648
  {
13478
13649
  let pkgVersion = Config.LIBRARY_VERSION;
13479
13650
  let pkgPath = "unknown";
@@ -13484,7 +13655,7 @@ var _Netra = class _Netra {
13484
13655
  pkgVersion = pkg?.version || pkgVersion;
13485
13656
  } catch {
13486
13657
  }
13487
- Logger.debug(
13658
+ NetraLogger.debug(
13488
13659
  `SDK version=${pkgVersion} libraryVersion=${Config.LIBRARY_VERSION} build=langgraph-parenting-v3 packageJson=${pkgPath}`
13489
13660
  );
13490
13661
  }
@@ -13542,7 +13713,7 @@ var _Netra = class _Netra {
13542
13713
  try {
13543
13714
  await uninstrumentAll();
13544
13715
  } catch (e) {
13545
- Logger.error("Error during uninstrumentAll:", e);
13716
+ NetraLogger.error("Error during uninstrumentAll:", e);
13546
13717
  }
13547
13718
  let flushTimer;
13548
13719
  try {
@@ -13561,7 +13732,7 @@ var _Netra = class _Netra {
13561
13732
  })
13562
13733
  ]);
13563
13734
  } catch (e) {
13564
- Logger.error("Error during Netra trace shutdown:", e);
13735
+ NetraLogger.error("Error during Netra trace shutdown:", e);
13565
13736
  } finally {
13566
13737
  clearTimeout(flushTimer);
13567
13738
  }
@@ -13569,12 +13740,12 @@ var _Netra = class _Netra {
13569
13740
  this.prompts?.clearCache();
13570
13741
  this.models?.clearCache();
13571
13742
  } catch (e) {
13572
- Logger.error("Error clearing SDK API caches:", e);
13743
+ NetraLogger.error("Error clearing SDK API caches:", e);
13573
13744
  }
13574
13745
  try {
13575
13746
  await settleOtherExitTasks(this._flushTask);
13576
13747
  } catch (e) {
13577
- Logger.error("Error awaiting pending shutdown tasks:", e);
13748
+ NetraLogger.error("Error awaiting pending shutdown tasks:", e);
13578
13749
  }
13579
13750
  this._initialized = false;
13580
13751
  this._tracer = void 0;
@@ -13596,7 +13767,7 @@ var _Netra = class _Netra {
13596
13767
  }
13597
13768
  static setSessionId(sessionId) {
13598
13769
  if (typeof sessionId !== "string") {
13599
- Logger.error(`setSessionId: sessionId must be a string, got ${typeof sessionId}`);
13770
+ NetraLogger.notice("error", `setSessionId: sessionId must be a string, got ${typeof sessionId}`);
13600
13771
  return;
13601
13772
  }
13602
13773
  if (sessionId) {
@@ -13606,7 +13777,7 @@ var _Netra = class _Netra {
13606
13777
  sessionId
13607
13778
  );
13608
13779
  } else {
13609
- 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.");
13610
13781
  }
13611
13782
  }
13612
13783
  /**
@@ -13615,7 +13786,7 @@ var _Netra = class _Netra {
13615
13786
  */
13616
13787
  static setUserId(userId) {
13617
13788
  if (typeof userId !== "string") {
13618
- Logger.error(`setUserId: userId must be a string, got ${typeof userId}`);
13789
+ NetraLogger.notice("error", `setUserId: userId must be a string, got ${typeof userId}`);
13619
13790
  return;
13620
13791
  }
13621
13792
  if (userId) {
@@ -13625,7 +13796,7 @@ var _Netra = class _Netra {
13625
13796
  userId
13626
13797
  );
13627
13798
  } else {
13628
- 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.");
13629
13800
  }
13630
13801
  }
13631
13802
  /**
@@ -13634,7 +13805,7 @@ var _Netra = class _Netra {
13634
13805
  */
13635
13806
  static setTenantId(tenantId) {
13636
13807
  if (typeof tenantId !== "string") {
13637
- Logger.error(`setTenantId: tenantId must be a string, got ${typeof tenantId}`);
13808
+ NetraLogger.notice("error", `setTenantId: tenantId must be a string, got ${typeof tenantId}`);
13638
13809
  return;
13639
13810
  }
13640
13811
  if (tenantId) {
@@ -13644,7 +13815,7 @@ var _Netra = class _Netra {
13644
13815
  tenantId
13645
13816
  );
13646
13817
  } else {
13647
- 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.");
13648
13819
  }
13649
13820
  }
13650
13821
  /**
@@ -13657,7 +13828,7 @@ var _Netra = class _Netra {
13657
13828
  value
13658
13829
  );
13659
13830
  } else {
13660
- 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.");
13661
13832
  }
13662
13833
  }
13663
13834
  /**
@@ -13667,7 +13838,7 @@ var _Netra = class _Netra {
13667
13838
  if (eventName && attributes) {
13668
13839
  SessionManager.setCustomEvent(eventName, attributes);
13669
13840
  } else {
13670
- 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.");
13671
13842
  }
13672
13843
  }
13673
13844
  /**