netra-sdk 1.12.0 → 1.12.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 +41 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -648,7 +648,7 @@ var Usage = class {
|
|
|
648
648
|
};
|
|
649
649
|
|
|
650
650
|
// src/version.ts
|
|
651
|
-
var SDK_VERSION = "1.12.
|
|
651
|
+
var SDK_VERSION = "1.12.1";
|
|
652
652
|
|
|
653
653
|
// src/config.ts
|
|
654
654
|
var NetraInstruments = /* @__PURE__ */ ((NetraInstruments2) => {
|
|
@@ -11423,6 +11423,27 @@ var _FilteringSpanExporter = class _FilteringSpanExporter {
|
|
|
11423
11423
|
_FilteringSpanExporter.MAX_REMEMBERED_ENTRIES = 1e4;
|
|
11424
11424
|
_FilteringSpanExporter.MAX_LOCAL_PATTERN_CACHE = 100;
|
|
11425
11425
|
var FilteringSpanExporter = _FilteringSpanExporter;
|
|
11426
|
+
var HTTP_STATUS_PAYLOAD_TOO_LARGE = 413;
|
|
11427
|
+
var RESPONSE_EXCERPT_MAX_CHARS = 200;
|
|
11428
|
+
var PAYLOAD_TOO_LARGE_HINT = "Lower OTEL_BSP_MAX_EXPORT_BATCH_SIZE or reduce large span attributes such as prompts and completions.";
|
|
11429
|
+
function describeServerMessage(responseBody) {
|
|
11430
|
+
try {
|
|
11431
|
+
const parsed = JSON.parse(responseBody);
|
|
11432
|
+
const message = parsed?.error?.message;
|
|
11433
|
+
if (typeof message === "string") return `"${message}"`;
|
|
11434
|
+
if (Array.isArray(message) && message.every((m) => typeof m === "string")) {
|
|
11435
|
+
return `"${message.join("; ")}"`;
|
|
11436
|
+
}
|
|
11437
|
+
} catch {
|
|
11438
|
+
}
|
|
11439
|
+
const excerpt = responseBody.trim().slice(0, RESPONSE_EXCERPT_MAX_CHARS);
|
|
11440
|
+
return excerpt ? `"${excerpt}"` : "(empty response body)";
|
|
11441
|
+
}
|
|
11442
|
+
function formatExportFailure(statusCode, statusMessage, responseBody, spanCount, requestBytes) {
|
|
11443
|
+
const status = [statusCode ?? "unknown", statusMessage].filter(Boolean).join(" ");
|
|
11444
|
+
const hint = statusCode === HTTP_STATUS_PAYLOAD_TOO_LARGE ? ` ${PAYLOAD_TOO_LARGE_HINT}` : "";
|
|
11445
|
+
return `Span export failed with HTTP ${status}: ${describeServerMessage(responseBody)}. Dropped a batch of ${spanCount} spans (${requestBytes} bytes).${hint}`;
|
|
11446
|
+
}
|
|
11426
11447
|
var TrialAwareOTLPExporter = class {
|
|
11427
11448
|
constructor(config) {
|
|
11428
11449
|
this._isShutdown = false;
|
|
@@ -11435,7 +11456,7 @@ var TrialAwareOTLPExporter = class {
|
|
|
11435
11456
|
}
|
|
11436
11457
|
let data;
|
|
11437
11458
|
try {
|
|
11438
|
-
const serialized = otlpTransformer.
|
|
11459
|
+
const serialized = otlpTransformer.ProtobufTraceSerializer.serializeRequest(spans);
|
|
11439
11460
|
if (!serialized) throw new Error("Serialization failed");
|
|
11440
11461
|
data = serialized;
|
|
11441
11462
|
} catch (err) {
|
|
@@ -11444,6 +11465,7 @@ var TrialAwareOTLPExporter = class {
|
|
|
11444
11465
|
error: err instanceof Error ? err : new Error("Serialization failed")
|
|
11445
11466
|
});
|
|
11446
11467
|
}
|
|
11468
|
+
const requestBytes = typeof data === "string" ? Buffer.byteLength(data) : data.byteLength;
|
|
11447
11469
|
const url = new URL(this._url);
|
|
11448
11470
|
const options = {
|
|
11449
11471
|
hostname: url.hostname,
|
|
@@ -11453,8 +11475,8 @@ var TrialAwareOTLPExporter = class {
|
|
|
11453
11475
|
headers: {
|
|
11454
11476
|
...this._headers,
|
|
11455
11477
|
host: url.host,
|
|
11456
|
-
"Content-Type": "application/
|
|
11457
|
-
"Content-Length":
|
|
11478
|
+
"Content-Type": "application/x-protobuf",
|
|
11479
|
+
"Content-Length": requestBytes
|
|
11458
11480
|
}
|
|
11459
11481
|
};
|
|
11460
11482
|
const lib = url.protocol === "https:" ? https__namespace : http__namespace;
|
|
@@ -11465,6 +11487,15 @@ var TrialAwareOTLPExporter = class {
|
|
|
11465
11487
|
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
|
11466
11488
|
resultCallback({ code: core.ExportResultCode.SUCCESS });
|
|
11467
11489
|
} else {
|
|
11490
|
+
Logger.warn(
|
|
11491
|
+
formatExportFailure(
|
|
11492
|
+
res.statusCode,
|
|
11493
|
+
res.statusMessage,
|
|
11494
|
+
body,
|
|
11495
|
+
spans.length,
|
|
11496
|
+
requestBytes
|
|
11497
|
+
)
|
|
11498
|
+
);
|
|
11468
11499
|
this.checkErrorBody(body, res.statusCode);
|
|
11469
11500
|
resultCallback({
|
|
11470
11501
|
code: core.ExportResultCode.FAILED,
|
|
@@ -11473,10 +11504,12 @@ var TrialAwareOTLPExporter = class {
|
|
|
11473
11504
|
}
|
|
11474
11505
|
});
|
|
11475
11506
|
});
|
|
11476
|
-
req.on(
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11507
|
+
req.on("error", (err) => {
|
|
11508
|
+
Logger.warn(
|
|
11509
|
+
`Span export failed: ${err.message}. Dropped a batch of ${spans.length} spans (${requestBytes} bytes).`
|
|
11510
|
+
);
|
|
11511
|
+
resultCallback({ code: core.ExportResultCode.FAILED, error: err });
|
|
11512
|
+
});
|
|
11480
11513
|
req.write(data);
|
|
11481
11514
|
req.end();
|
|
11482
11515
|
}
|