@bitfab/sdk 0.64.12 → 0.64.14

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.
@@ -7,7 +7,7 @@ import {
7
7
  flushTraces,
8
8
  parseRetryAfterMs,
9
9
  serializePayloadBody
10
- } from "./chunk-6D6TGYH4.js";
10
+ } from "./chunk-GURR5AWG.js";
11
11
  export {
12
12
  BitfabError,
13
13
  HttpClient,
@@ -18,4 +18,4 @@ export {
18
18
  parseRetryAfterMs,
19
19
  serializePayloadBody
20
20
  };
21
- //# sourceMappingURL=http-UMVAAJ63.js.map
21
+ //# sourceMappingURL=http-C44ETCJK.js.map
@@ -7,7 +7,7 @@ import {
7
7
  flushTraces,
8
8
  parseRetryAfterMs,
9
9
  serializePayloadBody
10
- } from "./chunk-JAD7I5FM.js";
10
+ } from "./chunk-A7NX4OKG.js";
11
11
  import "./chunk-MT36GJMW.js";
12
12
  export {
13
13
  BitfabError,
@@ -19,4 +19,4 @@ export {
19
19
  parseRetryAfterMs,
20
20
  serializePayloadBody
21
21
  };
22
- //# sourceMappingURL=http-STSTJGRH.js.map
22
+ //# sourceMappingURL=http-QX6O4EDS.js.map
package/dist/index.cjs CHANGED
@@ -42,7 +42,7 @@ var __version__, __packageName__;
42
42
  var init_version_generated = __esm({
43
43
  "src/version.generated.ts"() {
44
44
  "use strict";
45
- __version__ = "0.64.12";
45
+ __version__ = "0.64.14";
46
46
  __packageName__ = "@bitfab/sdk";
47
47
  }
48
48
  });
@@ -2737,6 +2737,12 @@ var init_http = __esm({
2737
2737
  const response = await this.get(endpoint);
2738
2738
  return response.span;
2739
2739
  }
2740
+ async getSpan(spanId) {
2741
+ const response = await this.get(
2742
+ `/api/sdk/spans/${encodeURIComponent(spanId)}`
2743
+ );
2744
+ return response.span;
2745
+ }
2740
2746
  /**
2741
2747
  * GET a JSON endpoint on the service with the client's API key. Throws a
2742
2748
  * `BitfabError` carrying the status text for any non-2xx response.
@@ -4641,7 +4647,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4641
4647
  dbBranchTimings: dbBranchTimings ?? null
4642
4648
  };
4643
4649
  }
4644
- async function waitForReplayPersistence(httpClient, experimentId, replayedTraceIds) {
4650
+ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceIds, replayLabels = {}, warn2 = console.warn) {
4645
4651
  const deferredSettled = await httpClient.settleDeferredWork(
4646
4652
  REPLAY_PERSISTENCE_TIMEOUT_MS
4647
4653
  );
@@ -4674,7 +4680,7 @@ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceI
4674
4680
  return readBackTraceIds;
4675
4681
  }
4676
4682
  const deadline = Date.now() + REPLAY_PERSISTENCE_TIMEOUT_MS;
4677
- let missing = Object.keys(expectedSpanCounts).length;
4683
+ let missing = Object.keys(expectedSpanCounts);
4678
4684
  while (true) {
4679
4685
  const status = await httpClient.getReplayStatus(
4680
4686
  experimentId,
@@ -4684,8 +4690,8 @@ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceI
4684
4690
  Object.assign(readBackTraceIds, ready);
4685
4691
  missing = Object.keys(expectedSpanCounts).filter(
4686
4692
  (traceId) => ready[traceId] === void 0
4687
- ).length;
4688
- if (missing === 0) {
4693
+ );
4694
+ if (missing.length === 0) {
4689
4695
  return readBackTraceIds;
4690
4696
  }
4691
4697
  if (Date.now() >= deadline) {
@@ -4695,10 +4701,19 @@ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceI
4695
4701
  Math.min(100, Math.max(0, deadline - Date.now()))
4696
4702
  );
4697
4703
  }
4698
- const cause = flushed ? "" : " Delivery was also not confirmed before the flush deadline, so the spans likely never reached the server.";
4699
- throw new BitfabError(
4700
- `Replay traces were not fully persisted before the delivery deadline (experiment ${experimentId}, missing ${missing} of ${Object.keys(expectedSpanCounts).length} trace(s)).${cause}`
4701
- );
4704
+ for (const traceId of missing) {
4705
+ warn2(
4706
+ unconfirmedReplayWarning(
4707
+ replayLabels[traceId] ?? traceId,
4708
+ REPLAY_PERSISTENCE_TIMEOUT_MS / 1e3,
4709
+ flushed
4710
+ )
4711
+ );
4712
+ }
4713
+ return readBackTraceIds;
4714
+ }
4715
+ function unconfirmedReplayWarning(label, seconds, flushed) {
4716
+ return `[bitfab] replay ${label} could not confirm all spans reached Bitfab within ${seconds}s. The run continues; Bitfab will show this replay as capture incomplete.${flushed ? "" : " Some spans likely never left this process."}`;
4702
4717
  }
4703
4718
  function sleepForReplayPersistence(ms) {
4704
4719
  return new Promise((resolve) => {
@@ -5101,7 +5116,17 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
5101
5116
  }
5102
5117
  throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
5103
5118
  const deliveredTraceIds = await preserveReplayFailure(
5104
- () => waitForReplayPersistence(httpClient, experimentId, replayedTraceIds),
5119
+ () => waitForReplayPersistence(
5120
+ httpClient,
5121
+ experimentId,
5122
+ replayedTraceIds,
5123
+ Object.fromEntries(
5124
+ workItems.map(({ serverItem, attempt }, index) => [
5125
+ replayedTraceIds[index],
5126
+ `${serverItem.originalTraceId ?? serverItem.sourceTraceId}#${attempt}`
5127
+ ])
5128
+ )
5129
+ ),
5105
5130
  resultItems,
5106
5131
  experimentId,
5107
5132
  fullExperimentUrl
@@ -11458,6 +11483,12 @@ var Bitfab = class {
11458
11483
  }
11459
11484
  return this.httpClient.getTraceSpan(traceId, lookup);
11460
11485
  }
11486
+ async getSpan(spanId) {
11487
+ if (typeof spanId !== "string" || spanId.trim().length === 0) {
11488
+ throw new BitfabError("spanId must be a non-empty string");
11489
+ }
11490
+ return this.httpClient.getSpan(spanId);
11491
+ }
11461
11492
  /**
11462
11493
  * Get a function wrapper for a specific trace function key.
11463
11494
  *