@oxygen-agent/cli 1.1014.777 → 1.1014.779
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/README.md +1 -1
- package/node_modules/@oxygen/shared/dist/otlp-log-sink.d.ts +1 -0
- package/node_modules/@oxygen/shared/dist/otlp-log-sink.js +58 -54
- package/node_modules/@oxygen/shared/dist/version.generated.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/version.generated.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,6 +39,7 @@ export type OtlpLogSinkOptions = {
|
|
|
39
39
|
serviceName: string;
|
|
40
40
|
/** Resource attributes merged after the defaults, so a caller can override them. */
|
|
41
41
|
resource?: Record<string, string | null | undefined> | undefined;
|
|
42
|
+
/** Positive safe integer; invalid values use the default batch size. */
|
|
42
43
|
batchSize?: number | undefined;
|
|
43
44
|
/** `0` disables the interval timer, for runtimes that flush off a request lifecycle. */
|
|
44
45
|
flushIntervalMs?: number | undefined;
|
|
@@ -210,7 +210,9 @@ function toLogRecord(record) {
|
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
export function createOtlpLogSink(options) {
|
|
213
|
-
const
|
|
213
|
+
const requestedBatchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
214
|
+
const batchSize = Number.isSafeInteger(requestedBatchSize) && requestedBatchSize > 0
|
|
215
|
+
? requestedBatchSize : DEFAULT_BATCH_SIZE;
|
|
214
216
|
const maxQueue = options.maxQueue && options.maxQueue > 0 ? options.maxQueue : DEFAULT_MAX_QUEUE;
|
|
215
217
|
const flushIntervalMs = options.flushIntervalMs === undefined
|
|
216
218
|
? DEFAULT_FLUSH_INTERVAL_MS
|
|
@@ -332,64 +334,66 @@ export function createOtlpLogSink(options) {
|
|
|
332
334
|
: {}),
|
|
333
335
|
})));
|
|
334
336
|
};
|
|
335
|
-
const
|
|
336
|
-
if (inFlight)
|
|
337
|
-
return inFlight;
|
|
338
|
-
if (queue.length === 0)
|
|
339
|
-
return undefined;
|
|
340
|
-
const batch = queue.splice(0, batchSize);
|
|
337
|
+
const postBatch = async (batch) => {
|
|
341
338
|
const payload = JSON.stringify({
|
|
342
|
-
resourceLogs: [
|
|
343
|
-
{
|
|
339
|
+
resourceLogs: [{
|
|
344
340
|
resource: { attributes: resourceAttributes },
|
|
345
|
-
scopeLogs: [
|
|
346
|
-
|
|
347
|
-
scope: { name: "oxygen" },
|
|
348
|
-
logRecords: batch.map(toLogRecord),
|
|
349
|
-
},
|
|
350
|
-
],
|
|
351
|
-
},
|
|
352
|
-
],
|
|
341
|
+
scopeLogs: [{ scope: { name: "oxygen" }, logRecords: batch.map(toLogRecord) }],
|
|
342
|
+
}],
|
|
353
343
|
});
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
catch {
|
|
369
|
-
report(batch.length, { status: response.status, error_code: "invalid_response" });
|
|
344
|
+
try {
|
|
345
|
+
const response = await doFetch(options.endpoint, {
|
|
346
|
+
method: "POST",
|
|
347
|
+
headers: { "Content-Type": "application/json", ...options.headers },
|
|
348
|
+
body: payload,
|
|
349
|
+
signal: AbortSignal.timeout(EXPORT_TIMEOUT_MS),
|
|
350
|
+
});
|
|
351
|
+
if (response.ok) {
|
|
352
|
+
try {
|
|
353
|
+
const rejected = await rejectedRecords(response, batch.length);
|
|
354
|
+
if (rejected) {
|
|
355
|
+
report(rejected, { status: response.status, error_code: "partial_rejection" });
|
|
356
|
+
return false;
|
|
370
357
|
}
|
|
371
|
-
return;
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
report(batch.length, { status: response.status, error_code: "invalid_response" });
|
|
362
|
+
return false;
|
|
372
363
|
}
|
|
373
|
-
// Receivers/proxies can echo rejected payloads or credentials. Never
|
|
374
|
-
// read arbitrary response text into operational diagnostics.
|
|
375
|
-
await response.body?.cancel().catch(() => undefined);
|
|
376
|
-
// The batch is gone deliberately: retrying into an unhealthy collector
|
|
377
|
-
// is how a telemetry path turns an ingest blip into memory pressure.
|
|
378
|
-
report(batch.length, { status: response.status, error_code: "receiver_rejected" });
|
|
379
|
-
}
|
|
380
|
-
catch (error) {
|
|
381
|
-
report(batch.length, {
|
|
382
|
-
error_code: "transport_failed",
|
|
383
|
-
error_cause: sanitizedErrorCause(error),
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
finally {
|
|
387
|
-
reportOverflow();
|
|
388
364
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
365
|
+
// Receivers/proxies can echo payloads or credentials. Keep diagnostics fixed.
|
|
366
|
+
await response.body?.cancel().catch(() => undefined);
|
|
367
|
+
report(batch.length, { status: response.status, error_code: "receiver_rejected" });
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
report(batch.length, {
|
|
372
|
+
error_code: "transport_failed",
|
|
373
|
+
error_cause: sanitizedErrorCause(error),
|
|
374
|
+
});
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
finally {
|
|
378
|
+
reportOverflow();
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
const flush = async () => {
|
|
382
|
+
if (inFlight)
|
|
383
|
+
return inFlight;
|
|
384
|
+
if (queue.length === 0)
|
|
385
|
+
return undefined;
|
|
386
|
+
// Keep one POST in flight. Healthy full batches continue immediately so the
|
|
387
|
+
// timer does not cap production at 500/2s. Failure keeps the existing loss
|
|
388
|
+
// accounting/backoff; neither a rejected batch nor a partial reply is retried.
|
|
389
|
+
const drain = async () => {
|
|
390
|
+
do {
|
|
391
|
+
const accepted = await postBatch(queue.splice(0, batchSize));
|
|
392
|
+
if (!accepted || queue.length < batchSize)
|
|
393
|
+
return;
|
|
394
|
+
} while (queue.length > 0);
|
|
395
|
+
};
|
|
396
|
+
inFlight = Promise.resolve().then(drain).finally(() => { inFlight = null; });
|
|
393
397
|
return inFlight;
|
|
394
398
|
};
|
|
395
399
|
const timer = flushIntervalMs > 0
|
|
@@ -404,7 +408,7 @@ export function createOtlpLogSink(options) {
|
|
|
404
408
|
if (timer)
|
|
405
409
|
clearInterval(timer);
|
|
406
410
|
// Drain rather than flush once: a shutdown's final lines are usually the
|
|
407
|
-
// interesting ones
|
|
411
|
+
// interesting ones. Flush the final partial batch as well as healthy full batches.
|
|
408
412
|
while (queue.length > 0) {
|
|
409
413
|
await flush();
|
|
410
414
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const OXYGEN_BUILD_VERSION = "1.1014.
|
|
1
|
+
export declare const OXYGEN_BUILD_VERSION = "1.1014.779";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// GENERATED by scripts/ci/version-stamp.mjs from VERSION + git history. Do not edit; do not commit.
|
|
2
|
-
export const OXYGEN_BUILD_VERSION = "1.1014.
|
|
2
|
+
export const OXYGEN_BUILD_VERSION = "1.1014.779";
|