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.d.cts
CHANGED
|
@@ -90,7 +90,7 @@ declare const DEFAULT_INSTRUMENTS: Set<NetraInstruments>;
|
|
|
90
90
|
declare class Config {
|
|
91
91
|
static readonly SDK_NAME = "netra";
|
|
92
92
|
static readonly LIBRARY_NAME = "netra";
|
|
93
|
-
static readonly LIBRARY_VERSION = "1.12.
|
|
93
|
+
static readonly LIBRARY_VERSION = "1.12.1";
|
|
94
94
|
static readonly TRIAL_BLOCK_DURATION_SECONDS = 900;
|
|
95
95
|
static readonly TRACE_ORIGIN_KEY = "netra.trace.origin";
|
|
96
96
|
static readonly TRACE_ORIGIN_EVALUATION = "evaluation";
|
package/dist/index.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ declare const DEFAULT_INSTRUMENTS: Set<NetraInstruments>;
|
|
|
90
90
|
declare class Config {
|
|
91
91
|
static readonly SDK_NAME = "netra";
|
|
92
92
|
static readonly LIBRARY_NAME = "netra";
|
|
93
|
-
static readonly LIBRARY_VERSION = "1.12.
|
|
93
|
+
static readonly LIBRARY_VERSION = "1.12.1";
|
|
94
94
|
static readonly TRIAL_BLOCK_DURATION_SECONDS = 900;
|
|
95
95
|
static readonly TRACE_ORIGIN_KEY = "netra.trace.origin";
|
|
96
96
|
static readonly TRACE_ORIGIN_EVALUATION = "evaluation";
|
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 {
|
|
11
|
+
import { ProtobufTraceSerializer } from '@opentelemetry/otlp-transformer';
|
|
12
12
|
import pLimit2 from 'p-limit';
|
|
13
13
|
import axios from 'axios';
|
|
14
14
|
|
|
@@ -617,7 +617,7 @@ var Usage = class {
|
|
|
617
617
|
};
|
|
618
618
|
|
|
619
619
|
// src/version.ts
|
|
620
|
-
var SDK_VERSION = "1.12.
|
|
620
|
+
var SDK_VERSION = "1.12.1";
|
|
621
621
|
|
|
622
622
|
// src/config.ts
|
|
623
623
|
var NetraInstruments = /* @__PURE__ */ ((NetraInstruments2) => {
|
|
@@ -11392,6 +11392,27 @@ var _FilteringSpanExporter = class _FilteringSpanExporter {
|
|
|
11392
11392
|
_FilteringSpanExporter.MAX_REMEMBERED_ENTRIES = 1e4;
|
|
11393
11393
|
_FilteringSpanExporter.MAX_LOCAL_PATTERN_CACHE = 100;
|
|
11394
11394
|
var FilteringSpanExporter = _FilteringSpanExporter;
|
|
11395
|
+
var HTTP_STATUS_PAYLOAD_TOO_LARGE = 413;
|
|
11396
|
+
var RESPONSE_EXCERPT_MAX_CHARS = 200;
|
|
11397
|
+
var PAYLOAD_TOO_LARGE_HINT = "Lower OTEL_BSP_MAX_EXPORT_BATCH_SIZE or reduce large span attributes such as prompts and completions.";
|
|
11398
|
+
function describeServerMessage(responseBody) {
|
|
11399
|
+
try {
|
|
11400
|
+
const parsed = JSON.parse(responseBody);
|
|
11401
|
+
const message = parsed?.error?.message;
|
|
11402
|
+
if (typeof message === "string") return `"${message}"`;
|
|
11403
|
+
if (Array.isArray(message) && message.every((m) => typeof m === "string")) {
|
|
11404
|
+
return `"${message.join("; ")}"`;
|
|
11405
|
+
}
|
|
11406
|
+
} catch {
|
|
11407
|
+
}
|
|
11408
|
+
const excerpt = responseBody.trim().slice(0, RESPONSE_EXCERPT_MAX_CHARS);
|
|
11409
|
+
return excerpt ? `"${excerpt}"` : "(empty response body)";
|
|
11410
|
+
}
|
|
11411
|
+
function formatExportFailure(statusCode, statusMessage, responseBody, spanCount, requestBytes) {
|
|
11412
|
+
const status = [statusCode ?? "unknown", statusMessage].filter(Boolean).join(" ");
|
|
11413
|
+
const hint = statusCode === HTTP_STATUS_PAYLOAD_TOO_LARGE ? ` ${PAYLOAD_TOO_LARGE_HINT}` : "";
|
|
11414
|
+
return `Span export failed with HTTP ${status}: ${describeServerMessage(responseBody)}. Dropped a batch of ${spanCount} spans (${requestBytes} bytes).${hint}`;
|
|
11415
|
+
}
|
|
11395
11416
|
var TrialAwareOTLPExporter = class {
|
|
11396
11417
|
constructor(config) {
|
|
11397
11418
|
this._isShutdown = false;
|
|
@@ -11404,7 +11425,7 @@ var TrialAwareOTLPExporter = class {
|
|
|
11404
11425
|
}
|
|
11405
11426
|
let data;
|
|
11406
11427
|
try {
|
|
11407
|
-
const serialized =
|
|
11428
|
+
const serialized = ProtobufTraceSerializer.serializeRequest(spans);
|
|
11408
11429
|
if (!serialized) throw new Error("Serialization failed");
|
|
11409
11430
|
data = serialized;
|
|
11410
11431
|
} catch (err) {
|
|
@@ -11413,6 +11434,7 @@ var TrialAwareOTLPExporter = class {
|
|
|
11413
11434
|
error: err instanceof Error ? err : new Error("Serialization failed")
|
|
11414
11435
|
});
|
|
11415
11436
|
}
|
|
11437
|
+
const requestBytes = typeof data === "string" ? Buffer.byteLength(data) : data.byteLength;
|
|
11416
11438
|
const url = new URL(this._url);
|
|
11417
11439
|
const options = {
|
|
11418
11440
|
hostname: url.hostname,
|
|
@@ -11422,8 +11444,8 @@ var TrialAwareOTLPExporter = class {
|
|
|
11422
11444
|
headers: {
|
|
11423
11445
|
...this._headers,
|
|
11424
11446
|
host: url.host,
|
|
11425
|
-
"Content-Type": "application/
|
|
11426
|
-
"Content-Length":
|
|
11447
|
+
"Content-Type": "application/x-protobuf",
|
|
11448
|
+
"Content-Length": requestBytes
|
|
11427
11449
|
}
|
|
11428
11450
|
};
|
|
11429
11451
|
const lib = url.protocol === "https:" ? https : http;
|
|
@@ -11434,6 +11456,15 @@ var TrialAwareOTLPExporter = class {
|
|
|
11434
11456
|
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
|
11435
11457
|
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
11436
11458
|
} else {
|
|
11459
|
+
Logger.warn(
|
|
11460
|
+
formatExportFailure(
|
|
11461
|
+
res.statusCode,
|
|
11462
|
+
res.statusMessage,
|
|
11463
|
+
body,
|
|
11464
|
+
spans.length,
|
|
11465
|
+
requestBytes
|
|
11466
|
+
)
|
|
11467
|
+
);
|
|
11437
11468
|
this.checkErrorBody(body, res.statusCode);
|
|
11438
11469
|
resultCallback({
|
|
11439
11470
|
code: ExportResultCode.FAILED,
|
|
@@ -11442,10 +11473,12 @@ var TrialAwareOTLPExporter = class {
|
|
|
11442
11473
|
}
|
|
11443
11474
|
});
|
|
11444
11475
|
});
|
|
11445
|
-
req.on(
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11476
|
+
req.on("error", (err) => {
|
|
11477
|
+
Logger.warn(
|
|
11478
|
+
`Span export failed: ${err.message}. Dropped a batch of ${spans.length} spans (${requestBytes} bytes).`
|
|
11479
|
+
);
|
|
11480
|
+
resultCallback({ code: ExportResultCode.FAILED, error: err });
|
|
11481
|
+
});
|
|
11449
11482
|
req.write(data);
|
|
11450
11483
|
req.end();
|
|
11451
11484
|
}
|