@usherlabs/cex-broker 0.2.40 → 0.2.41

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.
@@ -6,25 +6,43 @@ var __getProtoOf = Object.getPrototypeOf;
6
6
  var __defProp = Object.defineProperty;
7
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ function __accessProp(key) {
10
+ return this[key];
11
+ }
12
+ var __toESMCache_node;
13
+ var __toESMCache_esm;
9
14
  var __toESM = (mod, isNodeMode, target) => {
15
+ var canCache = mod != null && typeof mod === "object";
16
+ if (canCache) {
17
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
18
+ var cached = cache.get(mod);
19
+ if (cached)
20
+ return cached;
21
+ }
10
22
  target = mod != null ? __create(__getProtoOf(mod)) : {};
11
23
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
12
24
  for (let key of __getOwnPropNames(mod))
13
25
  if (!__hasOwnProp.call(to, key))
14
26
  __defProp(to, key, {
15
- get: () => mod[key],
27
+ get: __accessProp.bind(mod, key),
16
28
  enumerable: true
17
29
  });
30
+ if (canCache)
31
+ cache.set(mod, to);
18
32
  return to;
19
33
  };
20
34
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
35
+ var __returnValue = (v) => v;
36
+ function __exportSetter(name, newValue) {
37
+ this[name] = __returnValue.bind(null, newValue);
38
+ }
21
39
  var __export = (target, all) => {
22
40
  for (var name in all)
23
41
  __defProp(target, name, {
24
42
  get: all[name],
25
43
  enumerable: true,
26
44
  configurable: true,
27
- set: (newValue) => all[name] = () => newValue
45
+ set: __exportSetter.bind(all, name)
28
46
  });
29
47
  };
30
48
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -997,7 +1015,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
997
1015
  this._exitCallback = (err) => {
998
1016
  if (err.code !== "commander.executeSubCommandAsync") {
999
1017
  throw err;
1000
- } else {}
1018
+ }
1001
1019
  };
1002
1020
  }
1003
1021
  return this;
@@ -50030,7 +50048,7 @@ var require_tracestate_impl = __commonJS((exports) => {
50030
50048
  const value = listMember.slice(i2 + 1, part.length);
50031
50049
  if ((0, tracestate_validators_1.validateKey)(key) && (0, tracestate_validators_1.validateValue)(value)) {
50032
50050
  agg.set(key, value);
50033
- } else {}
50051
+ }
50034
50052
  }
50035
50053
  return agg;
50036
50054
  }, new Map);
@@ -59163,7 +59181,7 @@ var require_TraceState = __commonJS((exports) => {
59163
59181
  const value = listMember.slice(i2 + 1, part.length);
59164
59182
  if ((0, validators_1.validateKey)(key) && (0, validators_1.validateValue)(value)) {
59165
59183
  agg.set(key, value);
59166
- } else {}
59184
+ }
59167
59185
  }
59168
59186
  return agg;
59169
59187
  }, new Map);
@@ -315706,7 +315724,9 @@ function buildMarketMetadataSnapshotRow(input) {
315706
315724
  // src/helpers/broker-execution-archive/writer.ts
315707
315725
  var import_api_logs2 = __toESM(require_src7(), 1);
315708
315726
  import { closeSync, fsyncSync, openSync, writeSync } from "node:fs";
315709
- import { request as httpRequest2 } from "node:http";
315727
+ import {
315728
+ request as httpRequest2
315729
+ } from "node:http";
315710
315730
  import { request as httpsRequest2 } from "node:https";
315711
315731
  var BROKER_EXECUTION_ARCHIVE_TABLES = new Set([
315712
315732
  "broker_execution.order_events",
@@ -315779,6 +315799,7 @@ class BrokerExecutionArchiver {
315779
315799
  flushIntervalMs;
315780
315800
  forwarderTimeoutMs;
315781
315801
  queue = [];
315802
+ enqueueTimes = new WeakMap;
315782
315803
  stats = {
315783
315804
  enqueued: 0,
315784
315805
  shed: 0,
@@ -315787,6 +315808,16 @@ class BrokerExecutionArchiver {
315787
315808
  };
315788
315809
  flushTimer = null;
315789
315810
  flushInFlight = null;
315811
+ inFlightBatch = null;
315812
+ inFlightStartedAtMs = null;
315813
+ lastFailureAtMs = null;
315814
+ lastShedAtMs = null;
315815
+ lastSuccessAtMs = null;
315816
+ lastFailureEventSequence = null;
315817
+ lastShedEventSequence = null;
315818
+ lastSuccessEventSequence = null;
315819
+ lastSinkLatencyMs = null;
315820
+ healthEventSequence = 0;
315790
315821
  lastShedWarnAtMs = 0;
315791
315822
  closing = false;
315792
315823
  closed = false;
@@ -315820,6 +315851,7 @@ class BrokerExecutionArchiver {
315820
315851
  }
315821
315852
  try {
315822
315853
  this.flushTimer = setInterval(() => {
315854
+ this.emitArchiveHealthMetrics();
315823
315855
  this.flush();
315824
315856
  }, this.flushIntervalMs);
315825
315857
  this.flushTimer.unref?.();
@@ -315863,32 +315895,34 @@ class BrokerExecutionArchiver {
315863
315895
  row: { ...row.row, source: this.source }
315864
315896
  };
315865
315897
  if (this.queue.length >= this.maxQueueSize) {
315866
- const shedRow = this.queue[0];
315867
- if (shedRow) {
315868
- this.appendLossRecords([shedRow], "queue_shed");
315898
+ const shedEntry = this.queue[0];
315899
+ if (shedEntry) {
315900
+ this.appendLossRecords([shedEntry], "queue_shed");
315869
315901
  this.queue.shift();
315870
315902
  }
315871
315903
  this.stats.shed += 1;
315904
+ this.recordHealthEvent("shed");
315872
315905
  this.recordArchiveMetric("cex_archive_rows_shed_total", {
315873
- table: shedRow?.table ?? "unknown",
315906
+ table: shedEntry?.table ?? "unknown",
315874
315907
  source: this.source,
315875
- feed: shedRow ? archiveFeed(shedRow) : "NON_MARKET"
315908
+ feed: shedEntry ? archiveFeed(shedEntry) : "NON_MARKET"
315876
315909
  });
315877
315910
  this.recordArchiveMetric("cex_archive_queue_saturated_rows_total", {
315878
- table: shedRow?.table ?? "unknown",
315911
+ table: shedEntry?.table ?? "unknown",
315879
315912
  source: this.source,
315880
- feed: shedRow ? archiveFeed(shedRow) : "NON_MARKET"
315913
+ feed: shedEntry ? archiveFeed(shedEntry) : "NON_MARKET"
315881
315914
  });
315882
315915
  const now3 = Date.now();
315883
315916
  if (now3 - this.lastShedWarnAtMs >= SHED_WARN_INTERVAL_MS) {
315884
315917
  log.warn("Archive queue full: shedding oldest rows", {
315885
315918
  shed_total: this.stats.shed,
315886
315919
  queue_max: this.maxQueueSize,
315887
- table: shedRow?.table ?? "unknown"
315920
+ table: shedEntry?.table ?? "unknown"
315888
315921
  });
315889
315922
  this.lastShedWarnAtMs = now3;
315890
315923
  }
315891
315924
  }
315925
+ this.enqueueTimes.set(archiveRow, Date.now());
315892
315926
  this.queue.push(archiveRow);
315893
315927
  this.stats.enqueued += 1;
315894
315928
  this.recordArchiveMetric("cex_archive_rows_enqueued_total", {
@@ -315896,6 +315930,7 @@ class BrokerExecutionArchiver {
315896
315930
  source: this.source,
315897
315931
  feed: archiveFeed(archiveRow)
315898
315932
  });
315933
+ this.emitArchiveHealthMetrics();
315899
315934
  if (this.queue.length >= this.batchSize) {
315900
315935
  this.flush();
315901
315936
  }
@@ -315910,14 +315945,19 @@ class BrokerExecutionArchiver {
315910
315945
  if (this.flushInFlight) {
315911
315946
  return this.flushInFlight;
315912
315947
  }
315948
+ const inFlightState = {};
315913
315949
  const inFlight = this.flushBatch().then(() => {
315914
315950
  return;
315915
315951
  }).finally(() => {
315952
+ if (this.flushInFlight !== inFlightState.promise) {
315953
+ return;
315954
+ }
315916
315955
  this.flushInFlight = null;
315917
315956
  if (!this.closed && !this.closing && this.enabled && this.queue.length >= this.batchSize) {
315918
315957
  queueMicrotask(() => void this.flush());
315919
315958
  }
315920
315959
  });
315960
+ inFlightState.promise = inFlight;
315921
315961
  this.flushInFlight = inFlight;
315922
315962
  return inFlight;
315923
315963
  }
@@ -315964,6 +316004,79 @@ class BrokerExecutionArchiver {
315964
316004
  getQueueDepth() {
315965
316005
  return this.queue.length;
315966
316006
  }
316007
+ getHealthSnapshot() {
316008
+ const now3 = Date.now();
316009
+ const oldestPendingAtMs = this.oldestPendingEnqueueAtMs();
316010
+ const oldestPendingAgeMs = oldestPendingAtMs === null ? 0 : Math.max(0, now3 - oldestPendingAtMs);
316011
+ const inFlightAgeMs = this.inFlightStartedAtMs === null ? 0 : Math.max(0, now3 - this.inFlightStartedAtMs);
316012
+ const lastUnhealthyEventSequence = Math.max(this.lastFailureEventSequence ?? Number.NEGATIVE_INFINITY, this.lastShedEventSequence ?? Number.NEGATIVE_INFINITY);
316013
+ const recoveredFromEvents = lastUnhealthyEventSequence === Number.NEGATIVE_INFINITY || this.lastSuccessEventSequence !== null && this.lastSuccessEventSequence > lastUnhealthyEventSequence;
316014
+ const healthy = this.enabled && !this.closing && !this.closed && this.queue.length < this.maxQueueSize && oldestPendingAgeMs <= this.forwarderTimeoutMs && inFlightAgeMs <= this.forwarderTimeoutMs && recoveredFromEvents;
316015
+ return {
316016
+ healthy,
316017
+ queue_depth: this.queue.length,
316018
+ oldest_pending_age_ms: oldestPendingAgeMs,
316019
+ shed_total: this.stats.shed,
316020
+ last_failure_at: this.lastFailureAtMs,
316021
+ last_shed_at: this.lastShedAtMs,
316022
+ last_success_at: this.lastSuccessAtMs,
316023
+ sink_latency_ms: this.lastSinkLatencyMs,
316024
+ sink_errors_total: this.stats.forwarderFailures,
316025
+ in_flight: this.inFlightBatch !== null,
316026
+ in_flight_age_ms: inFlightAgeMs
316027
+ };
316028
+ }
316029
+ oldestPendingEnqueueAtMs() {
316030
+ let oldest = null;
316031
+ for (const entry of this.queue) {
316032
+ const enqueuedAtMs = this.enqueueTimes.get(entry);
316033
+ if (enqueuedAtMs === undefined) {
316034
+ continue;
316035
+ }
316036
+ oldest = oldest === null ? enqueuedAtMs : Math.min(oldest, enqueuedAtMs);
316037
+ }
316038
+ for (const entry of this.inFlightBatch ?? []) {
316039
+ const enqueuedAtMs = this.enqueueTimes.get(entry);
316040
+ if (enqueuedAtMs === undefined) {
316041
+ continue;
316042
+ }
316043
+ oldest = oldest === null ? enqueuedAtMs : Math.min(oldest, enqueuedAtMs);
316044
+ }
316045
+ return oldest;
316046
+ }
316047
+ recordHealthEvent(event) {
316048
+ const eventSequence = ++this.healthEventSequence;
316049
+ const eventTimestampMs = Date.now();
316050
+ switch (event) {
316051
+ case "failure":
316052
+ this.lastFailureAtMs = eventTimestampMs;
316053
+ this.lastFailureEventSequence = eventSequence;
316054
+ return;
316055
+ case "shed":
316056
+ this.lastShedAtMs = eventTimestampMs;
316057
+ this.lastShedEventSequence = eventSequence;
316058
+ return;
316059
+ case "success":
316060
+ this.lastSuccessAtMs = eventTimestampMs;
316061
+ this.lastSuccessEventSequence = eventSequence;
316062
+ return;
316063
+ }
316064
+ }
316065
+ emitArchiveHealthMetrics() {
316066
+ const snapshot = this.getHealthSnapshot();
316067
+ const labels = { source: this.source };
316068
+ this.recordArchiveObservableGauge("cex_archive_health", snapshot.healthy ? 1 : 0, labels);
316069
+ this.recordArchiveGauge("cex_archive_queue_depth", snapshot.queue_depth, labels);
316070
+ this.recordArchiveGauge("cex_archive_oldest_pending_age_ms", snapshot.oldest_pending_age_ms, labels);
316071
+ this.recordArchiveGauge("cex_archive_shed_total", snapshot.shed_total, labels);
316072
+ this.recordArchiveGauge("cex_archive_last_failure_at", snapshot.last_failure_at ?? 0, labels);
316073
+ this.recordArchiveGauge("cex_archive_last_shed_at", snapshot.last_shed_at ?? 0, labels);
316074
+ this.recordArchiveGauge("cex_archive_last_success_at", snapshot.last_success_at ?? 0, labels);
316075
+ this.recordArchiveGauge("cex_archive_sink_latency_ms", snapshot.sink_latency_ms ?? 0, labels);
316076
+ this.recordArchiveGauge("cex_archive_sink_errors_total", snapshot.sink_errors_total, labels);
316077
+ this.recordArchiveGauge("cex_archive_in_flight", snapshot.in_flight ? 1 : 0, labels);
316078
+ this.recordArchiveGauge("cex_archive_in_flight_age_ms", snapshot.in_flight_age_ms, labels);
316079
+ }
315967
316080
  closeLossJournal() {
315968
316081
  if (this.deadLetterFd === undefined) {
315969
316082
  return;
@@ -315986,8 +316099,9 @@ class BrokerExecutionArchiver {
315986
316099
  this.appendLossRecords([dropped], "queue_shed");
315987
316100
  this.queue.shift();
315988
316101
  this.stats.shed += 1;
316102
+ this.recordHealthEvent("shed");
315989
316103
  this.recordArchiveMetric("cex_archive_rows_shed_total", {
315990
- table: dropped?.table ?? "unknown",
316104
+ table: dropped.table,
315991
316105
  source: this.source,
315992
316106
  feed: archiveFeed(dropped)
315993
316107
  });
@@ -316046,6 +316160,8 @@ class BrokerExecutionArchiver {
316046
316160
  if (batch.length === 0) {
316047
316161
  return true;
316048
316162
  }
316163
+ this.inFlightBatch = batch;
316164
+ this.inFlightStartedAtMs = Date.now();
316049
316165
  for (const entry of batch) {
316050
316166
  if (isBrokerExecutionArchiveTable(entry.table)) {
316051
316167
  this.emitOtelLog(entry);
@@ -316056,8 +316172,15 @@ class BrokerExecutionArchiver {
316056
316172
  await this.postToForwarder(batch);
316057
316173
  } catch (error) {
316058
316174
  this.stats.forwarderFailures += 1;
316059
- this.queue.push(...batch);
316060
- this.enforceQueueBound();
316175
+ this.recordHealthEvent("failure");
316176
+ this.lastSinkLatencyMs = Math.max(0, Date.now() - (this.inFlightStartedAtMs ?? Date.now()));
316177
+ this.queue.unshift(...batch);
316178
+ try {
316179
+ this.enforceQueueBound();
316180
+ } finally {
316181
+ this.clearInFlightBatch(batch);
316182
+ this.emitArchiveHealthMetrics();
316183
+ }
316061
316184
  this.recordArchiveMetric("cex_archive_forwarder_failures_total", {
316062
316185
  count: batch.length
316063
316186
  });
@@ -316066,14 +316189,26 @@ class BrokerExecutionArchiver {
316066
316189
  }
316067
316190
  }
316068
316191
  this.stats.flushed += batch.length;
316192
+ this.recordHealthEvent("success");
316193
+ this.lastSinkLatencyMs = Math.max(0, Date.now() - (this.inFlightStartedAtMs ?? Date.now()));
316194
+ this.clearInFlightBatch(batch);
316069
316195
  this.recordFlushHealth(batch);
316196
+ this.emitArchiveHealthMetrics();
316070
316197
  return true;
316071
316198
  }
316199
+ clearInFlightBatch(batch) {
316200
+ if (this.inFlightBatch !== batch) {
316201
+ return;
316202
+ }
316203
+ this.inFlightBatch = null;
316204
+ this.inFlightStartedAtMs = null;
316205
+ }
316072
316206
  recordFlushHealth(batch) {
316073
316207
  const countByTable = new Map;
316074
316208
  for (const entry of batch) {
316075
- const key = `${entry.table}\x00${archiveFeed(entry)}`;
316076
- const grouped = countByTable.get(key) ?? { row: entry, count: 0 };
316209
+ const row = entry;
316210
+ const key = `${row.table}\x00${archiveFeed(row)}`;
316211
+ const grouped = countByTable.get(key) ?? { row, count: 0 };
316077
316212
  grouped.count += 1;
316078
316213
  countByTable.set(key, grouped);
316079
316214
  }
@@ -316091,9 +316226,14 @@ class BrokerExecutionArchiver {
316091
316226
  await this.otelMetrics?.recordCounter(metricName, value, labels);
316092
316227
  } catch {}
316093
316228
  }
316094
- async recordArchiveGauge(metricName, value) {
316229
+ async recordArchiveGauge(metricName, value, labels = {}) {
316095
316230
  try {
316096
- await this.otelMetrics?.recordGauge(metricName, value, {});
316231
+ await this.otelMetrics?.recordGauge(metricName, value, labels);
316232
+ } catch {}
316233
+ }
316234
+ async recordArchiveObservableGauge(metricName, value, labels) {
316235
+ try {
316236
+ await this.otelMetrics?.setObservableGauge(metricName, value, labels);
316097
316237
  } catch {}
316098
316238
  }
316099
316239
  emitOtelLog(entry) {
@@ -316130,27 +316270,136 @@ class BrokerExecutionArchiver {
316130
316270
  headers.authorization = `Bearer ${this.forwarderAuthToken}`;
316131
316271
  }
316132
316272
  return new Promise((resolve, reject) => {
316133
- const req = doRequest(url2, {
316134
- method: "POST",
316135
- headers,
316136
- timeout: this.forwarderTimeoutMs
316137
- }, (res) => {
316138
- res.on("data", () => {});
316139
- res.on("end", () => {
316140
- const status = res.statusCode ?? 0;
316141
- if (status < 200 || status >= 300) {
316142
- reject(new Error(`Archive forwarder returned ${status} ${res.statusMessage ?? ""}`));
316143
- return;
316144
- }
316273
+ let req;
316274
+ let response;
316275
+ let settled = false;
316276
+ let requestClosed = false;
316277
+ let requestCloseFailureScheduled = false;
316278
+ let responseClosed = false;
316279
+ let responseEnded = false;
316280
+ let outerTimer;
316281
+ function cleanupRequestListeners() {
316282
+ req?.removeListener("error", onRequestError);
316283
+ req?.removeListener("timeout", onRequestTimeout);
316284
+ req?.removeListener("close", onRequestClose);
316285
+ }
316286
+ function cleanupResponseListeners() {
316287
+ response?.removeListener("data", onResponseData);
316288
+ response?.removeListener("end", onResponseEnd);
316289
+ response?.removeListener("aborted", onResponseAborted);
316290
+ response?.removeListener("error", onResponseError);
316291
+ response?.removeListener("close", onResponseClose);
316292
+ }
316293
+ function onRequestClose() {
316294
+ requestClosed = true;
316295
+ if (!settled && !response && !requestCloseFailureScheduled) {
316296
+ requestCloseFailureScheduled = true;
316297
+ queueMicrotask(() => {
316298
+ if (!settled && !response) {
316299
+ settle2(new Error("Archive forwarder request closed before response headers"), false, true);
316300
+ }
316301
+ });
316302
+ }
316303
+ if (settled) {
316304
+ cleanupRequestListeners();
316305
+ }
316306
+ }
316307
+ function onRequestError(error) {
316308
+ if (!settled) {
316309
+ settle2(error, true);
316310
+ } else {
316311
+ cleanupRequestListeners();
316312
+ }
316313
+ }
316314
+ function onRequestTimeout() {
316315
+ settle2(new Error("Archive forwarder socket timed out"), true);
316316
+ }
316317
+ function onResponseData() {}
316318
+ function onResponseEnd() {
316319
+ responseEnded = true;
316320
+ if (!response?.complete) {
316321
+ settle2(new Error("Archive forwarder response was incomplete"), true);
316322
+ return;
316323
+ }
316324
+ const status = response.statusCode ?? 0;
316325
+ if (status < 200 || status >= 300) {
316326
+ settle2(new Error(`Archive forwarder returned ${status} ${response.statusMessage ?? ""}`), false);
316327
+ return;
316328
+ }
316329
+ settle2(undefined, false);
316330
+ }
316331
+ function onResponseAborted() {
316332
+ settle2(new Error("Archive forwarder response was aborted"), true);
316333
+ }
316334
+ function onResponseError(error) {
316335
+ if (!settled) {
316336
+ settle2(error, true);
316337
+ }
316338
+ }
316339
+ function onResponseClose() {
316340
+ responseClosed = true;
316341
+ if (!settled && !responseEnded) {
316342
+ settle2(new Error("Archive forwarder response closed before completion"), true);
316343
+ return;
316344
+ }
316345
+ cleanupResponseListeners();
316346
+ }
316347
+ function settle2(error, destroyRequest, retainClosedRequestError = false) {
316348
+ if (settled) {
316349
+ return;
316350
+ }
316351
+ settled = true;
316352
+ if (outerTimer) {
316353
+ clearTimeout(outerTimer);
316354
+ outerTimer = undefined;
316355
+ }
316356
+ response?.removeListener("data", onResponseData);
316357
+ response?.removeListener("end", onResponseEnd);
316358
+ response?.removeListener("aborted", onResponseAborted);
316359
+ if (responseClosed) {
316360
+ cleanupResponseListeners();
316361
+ }
316362
+ if (destroyRequest && req && !requestClosed) {
316363
+ req.destroy(error);
316364
+ } else if (retainClosedRequestError && req && requestClosed) {
316365
+ req.removeListener("timeout", onRequestTimeout);
316366
+ req.removeListener("close", onRequestClose);
316367
+ } else if (!req || requestClosed) {
316368
+ cleanupRequestListeners();
316369
+ }
316370
+ if (error) {
316371
+ reject(error);
316372
+ } else {
316145
316373
  resolve();
316374
+ }
316375
+ }
316376
+ outerTimer = setTimeout(() => {
316377
+ settle2(new Error("Archive forwarder request deadline exceeded"), true);
316378
+ }, this.forwarderTimeoutMs);
316379
+ try {
316380
+ req = doRequest(url2, {
316381
+ method: "POST",
316382
+ headers,
316383
+ timeout: this.forwarderTimeoutMs
316384
+ }, (nextResponse) => {
316385
+ response = nextResponse;
316386
+ response.on("data", onResponseData);
316387
+ response.on("end", onResponseEnd);
316388
+ response.on("aborted", onResponseAborted);
316389
+ response.on("error", onResponseError);
316390
+ response.on("close", onResponseClose);
316391
+ if (settled) {
316392
+ response.resume();
316393
+ }
316146
316394
  });
316147
- });
316148
- req.on("error", reject);
316149
- req.on("timeout", () => {
316150
- req.destroy(new Error("Archive forwarder request timed out"));
316151
- });
316152
- req.write(body);
316153
- req.end();
316395
+ req.on("error", onRequestError);
316396
+ req.on("timeout", onRequestTimeout);
316397
+ req.on("close", onRequestClose);
316398
+ req.write(body);
316399
+ req.end();
316400
+ } catch (error) {
316401
+ settle2(error instanceof Error ? error : new Error(String(error)), true);
316402
+ }
316154
316403
  });
316155
316404
  }
316156
316405
  }
@@ -329666,7 +329915,7 @@ function finalize(ctx, schema) {
329666
329915
  result.$schema = "http://json-schema.org/draft-07/schema#";
329667
329916
  } else if (ctx.target === "draft-04") {
329668
329917
  result.$schema = "http://json-schema.org/draft-04/schema#";
329669
- } else if (ctx.target === "openapi-3.0") {} else {}
329918
+ } else if (ctx.target === "openapi-3.0") {}
329670
329919
  if (ctx.external?.uri) {
329671
329920
  const id2 = ctx.external.registry.get(schema)?.id;
329672
329921
  if (!id2)
@@ -329914,7 +330163,7 @@ var literalProcessor = (schema, ctx, json3, _params) => {
329914
330163
  if (val === undefined) {
329915
330164
  if (ctx.unrepresentable === "throw") {
329916
330165
  throw new Error("Literal `undefined` cannot be represented in JSON Schema");
329917
- } else {}
330166
+ }
329918
330167
  } else if (typeof val === "bigint") {
329919
330168
  if (ctx.unrepresentable === "throw") {
329920
330169
  throw new Error("BigInt literals cannot be represented in JSON Schema");
@@ -23,6 +23,19 @@ type ArchiverStats = {
23
23
  flushed: number;
24
24
  forwarderFailures: number;
25
25
  };
26
+ export type BrokerExecutionArchiveHealthSnapshot = {
27
+ healthy: boolean;
28
+ queue_depth: number;
29
+ oldest_pending_age_ms: number;
30
+ shed_total: number;
31
+ last_failure_at: number | null;
32
+ last_shed_at: number | null;
33
+ last_success_at: number | null;
34
+ sink_latency_ms: number | null;
35
+ sink_errors_total: number;
36
+ in_flight: boolean;
37
+ in_flight_age_ms: number;
38
+ };
26
39
  export declare function isArchiveOtelLogsEnabled(): boolean;
27
40
  export declare function resolveArchiveForwarderUrlFromEnv(): string | undefined;
28
41
  export declare function resolveArchiveSourceFromEnv(value?: string | undefined): BrokerArchiveSource;
@@ -39,9 +52,20 @@ export declare class BrokerExecutionArchiver {
39
52
  private readonly flushIntervalMs;
40
53
  private readonly forwarderTimeoutMs;
41
54
  private readonly queue;
55
+ private readonly enqueueTimes;
42
56
  private readonly stats;
43
57
  private flushTimer;
44
58
  private flushInFlight;
59
+ private inFlightBatch;
60
+ private inFlightStartedAtMs;
61
+ private lastFailureAtMs;
62
+ private lastShedAtMs;
63
+ private lastSuccessAtMs;
64
+ private lastFailureEventSequence;
65
+ private lastShedEventSequence;
66
+ private lastSuccessEventSequence;
67
+ private lastSinkLatencyMs;
68
+ private healthEventSequence;
45
69
  private lastShedWarnAtMs;
46
70
  private closing;
47
71
  private closed;
@@ -61,13 +85,19 @@ export declare class BrokerExecutionArchiver {
61
85
  close(): Promise<void>;
62
86
  getStats(): Readonly<ArchiverStats>;
63
87
  getQueueDepth(): number;
88
+ getHealthSnapshot(): Readonly<BrokerExecutionArchiveHealthSnapshot>;
89
+ private oldestPendingEnqueueAtMs;
90
+ private recordHealthEvent;
91
+ private emitArchiveHealthMetrics;
64
92
  private closeLossJournal;
65
93
  private enforceQueueBound;
66
94
  private appendLossRecords;
67
95
  private flushBatch;
96
+ private clearInFlightBatch;
68
97
  private recordFlushHealth;
69
98
  private recordArchiveMetric;
70
99
  private recordArchiveGauge;
100
+ private recordArchiveObservableGauge;
71
101
  private emitOtelLog;
72
102
  private postToForwarder;
73
103
  }