@oxygen-agent/cli 1.1014.773 → 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 CHANGED
@@ -34,4 +34,4 @@ oxygen update
34
34
 
35
35
  For product documentation, visit https://oxygen-agent.com/docs. For support, visit https://oxygen-agent.com.
36
36
 
37
- Version: 1.1014.773
37
+ Version: 1.1014.779
@@ -2,6 +2,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { sanitizeLogFields } from "./redaction.js";
3
3
  import { redactSqlParameters } from "./sql-error.js";
4
4
  import { OXYGEN_VERSION } from "./version.js";
5
+ import { resolveLogSinkSelector } from "./log-sink-selector.js";
5
6
  const store = new AsyncLocalStorage();
6
7
  export function withLogContext(ctx, fn) {
7
8
  const merged = { ...(store.getStore() ?? {}), ...ctx };
@@ -139,7 +140,8 @@ export function getLogSink() {
139
140
  }
140
141
  const LEVEL_RANK = { debug: 10, info: 20, warn: 30, error: 40 };
141
142
  /**
142
- * Minimum level that reaches the Axiom SINK. stdout is deliberately untouched —
143
+ * Minimum level for managed or dual-write sinks. Native-only bypasses this
144
+ * legacy floor so every emitted level reaches its transport. stdout is untouched —
143
145
  * `flyctl logs`, `vercel logs`, and local runs keep every line, so nothing becomes
144
146
  * un-debuggable; this only decides what we pay to store and query.
145
147
  *
@@ -164,7 +166,9 @@ function shipMinRank() {
164
166
  return LEVEL_RANK.info;
165
167
  }
166
168
  function shouldShip(level) {
167
- return LEVEL_RANK[level] >= shipMinRank();
169
+ // Native-only capture includes all emitted levels, even when a legacy floor
170
+ // remains inherited. This gate runs before the selected transport sees a record.
171
+ return resolveLogSinkSelector() === "otlp" || LEVEL_RANK[level] >= shipMinRank();
168
172
  }
169
173
  export function log(level, msg, fields) {
170
174
  const context = getLogContext();
@@ -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 batchSize = options.batchSize && options.batchSize > 0 ? options.batchSize : DEFAULT_BATCH_SIZE;
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 flush = async () => {
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
- const run = (async () => {
355
- try {
356
- const response = await doFetch(options.endpoint, {
357
- method: "POST",
358
- headers: { "Content-Type": "application/json", ...options.headers },
359
- body: payload,
360
- signal: AbortSignal.timeout(EXPORT_TIMEOUT_MS),
361
- });
362
- if (response.ok) {
363
- try {
364
- const rejected = await rejectedRecords(response, batch.length);
365
- if (rejected)
366
- report(rejected, { status: response.status, error_code: "partial_rejection" });
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
- inFlight = run.finally(() => {
391
- inFlight = null;
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, and one flush ships only the oldest `batchSize`.
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
  }
@@ -0,0 +1,8 @@
1
+ import type { SpanProcessor } from "@opentelemetry/sdk-trace-base";
2
+ /**
3
+ * Count ended recording spans once per SDK, before destination filters. Stored
4
+ * spans cannot size full capture while quiet execution roots are suppressed.
5
+ * Fixed dimensions include children without retaining names or customer data.
6
+ * This counts generated recording spans; an upstream sampler remains a limit.
7
+ */
8
+ export declare function generatedSpanVolumeProcessor(surface: "web" | "worker"): SpanProcessor;
@@ -0,0 +1,26 @@
1
+ import { metrics } from "@opentelemetry/api";
2
+ /**
3
+ * Count ended recording spans once per SDK, before destination filters. Stored
4
+ * spans cannot size full capture while quiet execution roots are suppressed.
5
+ * Fixed dimensions include children without retaining names or customer data.
6
+ * This counts generated recording spans; an upstream sampler remains a limit.
7
+ */
8
+ export function generatedSpanVolumeProcessor(surface) {
9
+ let counter;
10
+ return {
11
+ onStart() { },
12
+ onEnd(span) {
13
+ counter ??= metrics.getMeter("oxygen.capture").createCounter("oxygen.telemetry.generated_spans", {
14
+ description: "Ended recording spans before destination suppression; cumulative per process",
15
+ unit: "{span}",
16
+ });
17
+ counter.add(1, {
18
+ surface,
19
+ relationship: span.parentSpanContext ? "child" : "root",
20
+ family: span.name === "bullmq.execute" ? "execution" : "other",
21
+ });
22
+ },
23
+ forceFlush: async () => { },
24
+ shutdown: async () => { },
25
+ };
26
+ }
@@ -1,5 +1,6 @@
1
1
  import { deployEnvTelemetryEnvironment, resolveDeployEnv } from "./deploy-env.js";
2
2
  import { processResourceIdentity } from "./process-resource.js";
3
+ import { resolveLogSinkSelector } from "./log-sink-selector.js";
3
4
  export function planTelemetryResource({ declared, managedEnvironment, collectorConfigured, env = process.env, }) {
4
5
  // The label a process without a collector has always exported: `production`
5
6
  // on selfhost-prod, `development` on shadow/dev, the managed chain otherwise.
@@ -18,7 +19,7 @@ export function planTelemetryResource({ declared, managedEnvironment, collectorC
18
19
  }
19
20
  const collectorEnvironment = env.OXYGEN_DEPLOY_ENV?.trim() ? resolveDeployEnv(env).tier : axiomEnvironment;
20
21
  const collectorAttributes = withEnvironment(collectorEnvironment, { ...processResourceIdentity(), ...declared });
21
- if (collectorEnvironment === "prod") {
22
+ if (collectorEnvironment === "prod" && resolveLogSinkSelector(env) !== "otlp") {
22
23
  return {
23
24
  deploymentEnvironment: axiomEnvironment,
24
25
  resourceAttributes: withEnvironment(axiomEnvironment, declared),
@@ -1 +1 @@
1
- export declare const OXYGEN_BUILD_VERSION = "1.1014.773";
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.773";
2
+ export const OXYGEN_BUILD_VERSION = "1.1014.779";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxygen-agent/cli",
3
- "version": "1.1014.773",
3
+ "version": "1.1014.779",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",