netra-sdk 1.1.0-beta → 1.1.0-beta.1

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.cjs CHANGED
@@ -24278,10 +24278,10 @@ function disableTraceloopLangchainCallbackHandler() {
24278
24278
  } catch {
24279
24279
  }
24280
24280
  }
24281
- function resolveRootInstrumentNames(rootInstruments, blockInstruments2) {
24281
+ function resolveRootInstrumentNames(rootInstruments, blockInstruments) {
24282
24282
  const allSentinel = "__all__" /* ALL */;
24283
24283
  const rootHasAll = rootInstruments != null && rootInstruments.has(allSentinel);
24284
- const blockHasAll = blockInstruments2 != null && blockInstruments2.has(allSentinel);
24284
+ const blockHasAll = blockInstruments != null && blockInstruments.has(allSentinel);
24285
24285
  if (blockHasAll) {
24286
24286
  if (rootHasAll) {
24287
24287
  Logger.error(
@@ -24299,9 +24299,9 @@ function resolveRootInstrumentNames(rootInstruments, blockInstruments2) {
24299
24299
  let blockedValues;
24300
24300
  if (blockHasAll) {
24301
24301
  blockedValues = new Set(allInstrumentValues);
24302
- } else if (blockInstruments2 && blockInstruments2.size > 0) {
24302
+ } else if (blockInstruments && blockInstruments.size > 0) {
24303
24303
  blockedValues = new Set(
24304
- [...blockInstruments2].filter((m) => m !== allSentinel).map((m) => m.valueOf())
24304
+ [...blockInstruments].filter((m) => m !== allSentinel).map((m) => m.valueOf())
24305
24305
  );
24306
24306
  } else {
24307
24307
  blockedValues = /* @__PURE__ */ new Set();
@@ -24329,11 +24329,11 @@ function resolveRootInstrumentNames(rootInstruments, blockInstruments2) {
24329
24329
  }
24330
24330
  return resolved;
24331
24331
  }
24332
- function initInstrumentations(config2, instruments2, blockInstruments2, rootInstruments) {
24333
- const enableAll = instruments2 != null && instruments2.has("__all__" /* ALL */);
24332
+ function initInstrumentations(config2, instruments, blockInstruments, rootInstruments) {
24333
+ const enableAll = instruments != null && instruments.has("__all__" /* ALL */);
24334
24334
  const resolvedRootNames = resolveRootInstrumentNames(
24335
24335
  rootInstruments,
24336
- blockInstruments2
24336
+ blockInstruments
24337
24337
  );
24338
24338
  const instrumentModules = {};
24339
24339
  const customInstrumentModules = {
@@ -24343,7 +24343,7 @@ function initInstrumentations(config2, instruments2, blockInstruments2, rootInst
24343
24343
  langgraph: false,
24344
24344
  googleGenAI: false,
24345
24345
  anthropic: false};
24346
- const resolved = enableAll ? new Set(Object.values(NetraInstruments).filter((v) => v !== "__all__" /* ALL */)) : instruments2 && instruments2.size > 0 ? instruments2 : DEFAULT_INSTRUMENTS;
24346
+ const resolved = enableAll ? new Set(Object.values(NetraInstruments).filter((v) => v !== "__all__" /* ALL */)) : instruments && instruments.size > 0 ? instruments : DEFAULT_INSTRUMENTS;
24347
24347
  instrumentModules.google_vertexai = false;
24348
24348
  instrumentModules.langchain = false;
24349
24349
  instrumentModules.llamaIndex = false;
@@ -24390,21 +24390,21 @@ function initInstrumentations(config2, instruments2, blockInstruments2, rootInst
24390
24390
  if (resolved.has("anthropic" /* ANTHROPIC */)) {
24391
24391
  customInstrumentModules.anthropic = true;
24392
24392
  }
24393
- if (blockInstruments2 && blockInstruments2.size > 0) {
24394
- const blockAll = blockInstruments2.has("__all__" /* ALL */);
24395
- if (blockAll || blockInstruments2.has("openai" /* OPENAI */)) customInstrumentModules.openai = false;
24396
- if (blockAll || blockInstruments2.has("groq" /* GROQ */)) customInstrumentModules.groq = false;
24397
- if (blockAll || blockInstruments2.has("mistral_ai" /* MISTRAL */)) customInstrumentModules.mistral = false;
24398
- if (blockAll || blockInstruments2.has("langgraph" /* LANGGRAPH */)) customInstrumentModules.langgraph = false;
24399
- if (blockAll || blockInstruments2.has("google_genai" /* GOOGLE_GENERATIVE_AI */)) customInstrumentModules.googleGenAI = false;
24400
- if (blockAll || blockInstruments2.has("anthropic" /* ANTHROPIC */)) customInstrumentModules.anthropic = false;
24401
- if (blockAll || blockInstruments2.has("vertexai" /* VERTEX_AI */)) instrumentModules.google_vertexai = false;
24402
- if (blockAll || blockInstruments2.has("langchain" /* LANGCHAIN */)) instrumentModules.langchain = false;
24403
- if (blockAll || blockInstruments2.has("llama_index" /* LLAMA_INDEX */)) instrumentModules.llamaIndex = false;
24404
- if (blockAll || blockInstruments2.has("pinecone" /* PINECONE */)) instrumentModules.pinecone = false;
24405
- if (blockAll || blockInstruments2.has("qdrant" /* QDRANT */)) instrumentModules.qdrant = false;
24406
- if (blockAll || blockInstruments2.has("chromadb" /* CHROMADB */)) instrumentModules.chromadb = false;
24407
- if (blockAll || blockInstruments2.has("together" /* TOGETHER */)) instrumentModules.together = false;
24393
+ if (blockInstruments && blockInstruments.size > 0) {
24394
+ const blockAll = blockInstruments.has("__all__" /* ALL */);
24395
+ if (blockAll || blockInstruments.has("openai" /* OPENAI */)) customInstrumentModules.openai = false;
24396
+ if (blockAll || blockInstruments.has("groq" /* GROQ */)) customInstrumentModules.groq = false;
24397
+ if (blockAll || blockInstruments.has("mistral_ai" /* MISTRAL */)) customInstrumentModules.mistral = false;
24398
+ if (blockAll || blockInstruments.has("langgraph" /* LANGGRAPH */)) customInstrumentModules.langgraph = false;
24399
+ if (blockAll || blockInstruments.has("google_genai" /* GOOGLE_GENERATIVE_AI */)) customInstrumentModules.googleGenAI = false;
24400
+ if (blockAll || blockInstruments.has("anthropic" /* ANTHROPIC */)) customInstrumentModules.anthropic = false;
24401
+ if (blockAll || blockInstruments.has("vertexai" /* VERTEX_AI */)) instrumentModules.google_vertexai = false;
24402
+ if (blockAll || blockInstruments.has("langchain" /* LANGCHAIN */)) instrumentModules.langchain = false;
24403
+ if (blockAll || blockInstruments.has("llama_index" /* LLAMA_INDEX */)) instrumentModules.llamaIndex = false;
24404
+ if (blockAll || blockInstruments.has("pinecone" /* PINECONE */)) instrumentModules.pinecone = false;
24405
+ if (blockAll || blockInstruments.has("qdrant" /* QDRANT */)) instrumentModules.qdrant = false;
24406
+ if (blockAll || blockInstruments.has("chromadb" /* CHROMADB */)) instrumentModules.chromadb = false;
24407
+ if (blockAll || blockInstruments.has("together" /* TOGETHER */)) instrumentModules.together = false;
24408
24408
  }
24409
24409
  config2.setTraceloopEnv();
24410
24410
  Logger.debug("Netra SDK Configuration:");
@@ -24461,16 +24461,17 @@ function initInstrumentations(config2, instruments2, blockInstruments2, rootInst
24461
24461
  instrumentationsReady = initCustomInstrumentationsAsync(
24462
24462
  config2,
24463
24463
  tracerProvider,
24464
- customInstrumentModules
24464
+ customInstrumentModules,
24465
+ blockInstruments
24465
24466
  );
24466
- initOpenTelemetryInstrumentations(config2, resolved, blockInstruments2);
24467
+ initOpenTelemetryInstrumentations(config2, resolved, blockInstruments);
24467
24468
  return effectiveProvider;
24468
24469
  }
24469
- function isBlocked(instrument, blockInstruments2) {
24470
- if (!blockInstruments2 || blockInstruments2.size === 0) return false;
24471
- return blockInstruments2.has("__all__" /* ALL */) || blockInstruments2.has(instrument);
24470
+ function isBlocked(instrument, blockInstruments) {
24471
+ if (!blockInstruments || blockInstruments.size === 0) return false;
24472
+ return blockInstruments.has("__all__" /* ALL */) || blockInstruments.has(instrument);
24472
24473
  }
24473
- async function initCustomInstrumentationsAsync(config2, tracerProvider, customInstrumentModules) {
24474
+ async function initCustomInstrumentationsAsync(config2, tracerProvider, customInstrumentModules, blockInstruments) {
24474
24475
  if (customInstrumentModules.mistral) {
24475
24476
  try {
24476
24477
  await mistralAIInstrumentor.instrumentAsync({ tracerProvider });
@@ -24528,7 +24529,7 @@ async function initCustomInstrumentationsAsync(config2, tracerProvider, customIn
24528
24529
  }
24529
24530
  }
24530
24531
  }
24531
- function initOpenTelemetryInstrumentations(config2, resolved, blockInstruments2) {
24532
+ function initOpenTelemetryInstrumentations(config2, resolved, blockInstruments) {
24532
24533
  let netraHost = "";
24533
24534
  try {
24534
24535
  if (config2.otlpEndpoint) {
@@ -24553,7 +24554,7 @@ function initOpenTelemetryInstrumentations(config2, resolved, blockInstruments2)
24553
24554
  if (netraHost && url.includes(netraHost)) return true;
24554
24555
  return excludeRegexes.some((re) => re.test(url));
24555
24556
  };
24556
- if (!isBlocked("http" /* HTTP */, blockInstruments2) && (resolved.has("http" /* HTTP */) || resolved.has("express" /* EXPRESS */))) {
24557
+ if (!isBlocked("http" /* HTTP */, blockInstruments) && (resolved.has("http" /* HTTP */) || resolved.has("express" /* EXPRESS */))) {
24557
24558
  try {
24558
24559
  const { HttpInstrumentation } = require3("@opentelemetry/instrumentation-http");
24559
24560
  const { registerInstrumentations } = require3("@opentelemetry/instrumentation");
@@ -24571,7 +24572,7 @@ function initOpenTelemetryInstrumentations(config2, resolved, blockInstruments2)
24571
24572
  Logger.debug("HTTP instrumentation not available:", e);
24572
24573
  }
24573
24574
  }
24574
- const fetchEnabled = !blockInstruments2?.has(NetraInstruments.FETCH) && (!instruments || instruments.has(NetraInstruments.FETCH));
24575
+ const fetchEnabled = !isBlocked("http" /* HTTP */, blockInstruments) && resolved.has("http" /* HTTP */);
24575
24576
  if (fetchEnabled) {
24576
24577
  try {
24577
24578
  const { UndiciInstrumentation } = require3("@opentelemetry/instrumentation-undici");
@@ -24592,21 +24593,21 @@ function initOpenTelemetryInstrumentations(config2, resolved, blockInstruments2)
24592
24593
  }
24593
24594
  }
24594
24595
  }
24595
- if (!isBlocked("prisma" /* PRISMA */, blockInstruments2) && resolved.has("prisma" /* PRISMA */) && isPackageInstalled("@prisma/instrumentation")) {
24596
+ if (!isBlocked("prisma" /* PRISMA */, blockInstruments) && resolved.has("prisma" /* PRISMA */) && isPackageInstalled("@prisma/instrumentation")) {
24596
24597
  try {
24597
24598
  const { PrismaInstrumentation } = require3("@prisma/instrumentation");
24598
24599
  } catch (e) {
24599
24600
  Logger.debug("Prisma instrumentation not available:", e);
24600
24601
  }
24601
24602
  }
24602
- if (!isBlocked("typeorm" /* TYPEORM */, blockInstruments2) && resolved.has("typeorm" /* TYPEORM */) && isPackageInstalled("typeorm")) {
24603
+ if (!isBlocked("typeorm" /* TYPEORM */, blockInstruments) && resolved.has("typeorm" /* TYPEORM */) && isPackageInstalled("typeorm")) {
24603
24604
  typeORMInstrumentor.instrument().then(() => {
24604
24605
  Logger.debug("TypeORM instrumentation successfully initialized");
24605
24606
  }).catch((e) => {
24606
24607
  Logger.debug("TypeORM instrumentation error:", e);
24607
24608
  });
24608
24609
  }
24609
- if (!isBlocked("express" /* EXPRESS */, blockInstruments2) && resolved.has("express" /* EXPRESS */)) {
24610
+ if (!isBlocked("express" /* EXPRESS */, blockInstruments) && resolved.has("express" /* EXPRESS */)) {
24610
24611
  try {
24611
24612
  const { ExpressInstrumentation } = require3("@opentelemetry/instrumentation-express");
24612
24613
  const { registerInstrumentations } = require3("@opentelemetry/instrumentation");
@@ -25216,20 +25217,33 @@ var Tracer17 = class {
25216
25217
  }
25217
25218
  }
25218
25219
  };
25219
- function serializeValue2(value) {
25220
+ function safeStringify3(value, maxLen = 1e3) {
25221
+ const seen = /* @__PURE__ */ new WeakSet();
25220
25222
  try {
25221
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
25222
- return String(value);
25223
- } else if (Array.isArray(value) || typeof value === "object") {
25224
- return JSON.stringify(value).substring(0, 1e3);
25225
- } else {
25226
- return String(value).substring(0, 1e3);
25227
- }
25228
- } catch (e) {
25229
- Logger.warn("serializeValue: serialization failed, falling back to type name:", e);
25230
- return String(typeof value);
25223
+ return JSON.stringify(value, (_key, val) => {
25224
+ if (typeof val === "function") return `[Function: ${val.name || "anonymous"}]`;
25225
+ if (typeof val === "symbol") return val.toString();
25226
+ if (typeof val === "bigint") return val.toString();
25227
+ if (val !== null && typeof val === "object") {
25228
+ if (seen.has(val)) return "[Circular]";
25229
+ seen.add(val);
25230
+ const name = val.constructor?.name;
25231
+ if (name && name !== "Object" && name !== "Array" && Object.keys(val).length > 20) {
25232
+ return `[${name}]`;
25233
+ }
25234
+ }
25235
+ return val;
25236
+ }).substring(0, maxLen);
25237
+ } catch {
25238
+ return value?.constructor?.name ? `[${value.constructor.name}]` : String(typeof value);
25231
25239
  }
25232
25240
  }
25241
+ function serializeValue2(value) {
25242
+ if (value === null || value === void 0) return String(value);
25243
+ const t = typeof value;
25244
+ if (t === "string" || t === "number" || t === "boolean") return String(value);
25245
+ return safeStringify3(value);
25246
+ }
25233
25247
  function spanHasOutput(span2) {
25234
25248
  try {
25235
25249
  for (const field of ["attributes", "_attributes"]) {
@@ -25243,12 +25257,8 @@ function spanHasOutput(span2) {
25243
25257
  }
25244
25258
  function addInputAttributes(span2, args, entityType) {
25245
25259
  span2.setAttribute(`${Config.LIBRARY_NAME}.entity.type`, entityType);
25246
- try {
25247
- if (args.length > 0) {
25248
- span2.setAttribute("input", JSON.stringify(args));
25249
- }
25250
- } catch (e) {
25251
- span2.setAttribute("input_error", String(e));
25260
+ if (args.length > 0) {
25261
+ span2.setAttribute("input", safeStringify3(args));
25252
25262
  }
25253
25263
  }
25254
25264
  function addOutputAttributes(span2, result) {