bitfab 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.
package/dist/index.d.cts CHANGED
@@ -668,6 +668,7 @@ declare class HttpClient {
668
668
  lookupFunction<T>(name: string): Promise<T>;
669
669
  getSimulationPlan(): Promise<SimulationPlanResponse>;
670
670
  getTraceSpan(traceId: string, lookup: SpanLookup): Promise<CapturedSpan | null>;
671
+ getSpan(spanId: string): Promise<CapturedSpan | null>;
671
672
  /**
672
673
  * GET a JSON endpoint on the service with the client's API key. Throws a
673
674
  * `BitfabError` carrying the status text for any non-2xx response.
@@ -3684,6 +3685,7 @@ declare class Bitfab {
3684
3685
  * as `"first"` or a zero-based index to select a different match.
3685
3686
  */
3686
3687
  getTraceSpan(traceId: string, lookup: SpanLookup): Promise<CapturedSpan | null>;
3688
+ getSpan(spanId: string): Promise<CapturedSpan | null>;
3687
3689
  /**
3688
3690
  * Get a function wrapper for a specific trace function key.
3689
3691
  *
@@ -3996,7 +3998,7 @@ interface CommitRef {
3996
3998
  /**
3997
3999
  * SDK version from package.json (injected at build time)
3998
4000
  */
3999
- declare const __version__ = "0.64.12";
4001
+ declare const __version__ = "0.64.14";
4000
4002
 
4001
4003
  /**
4002
4004
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -668,6 +668,7 @@ declare class HttpClient {
668
668
  lookupFunction<T>(name: string): Promise<T>;
669
669
  getSimulationPlan(): Promise<SimulationPlanResponse>;
670
670
  getTraceSpan(traceId: string, lookup: SpanLookup): Promise<CapturedSpan | null>;
671
+ getSpan(spanId: string): Promise<CapturedSpan | null>;
671
672
  /**
672
673
  * GET a JSON endpoint on the service with the client's API key. Throws a
673
674
  * `BitfabError` carrying the status text for any non-2xx response.
@@ -3684,6 +3685,7 @@ declare class Bitfab {
3684
3685
  * as `"first"` or a zero-based index to select a different match.
3685
3686
  */
3686
3687
  getTraceSpan(traceId: string, lookup: SpanLookup): Promise<CapturedSpan | null>;
3688
+ getSpan(spanId: string): Promise<CapturedSpan | null>;
3687
3689
  /**
3688
3690
  * Get a function wrapper for a specific trace function key.
3689
3691
  *
@@ -3996,7 +3998,7 @@ interface CommitRef {
3996
3998
  /**
3997
3999
  * SDK version from package.json (injected at build time)
3998
4000
  */
3999
- declare const __version__ = "0.64.12";
4001
+ declare const __version__ = "0.64.14";
4000
4002
 
4001
4003
  /**
4002
4004
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  getCurrentTrace,
37
37
  reseedFromRegistry,
38
38
  seedFromRegistry
39
- } from "./chunk-ENDINEUP.js";
39
+ } from "./chunk-6XEU55WF.js";
40
40
  import "./chunk-YWXQM6J3.js";
41
41
  import {
42
42
  BITFAB_PROGRESS_PREFIX,
@@ -45,7 +45,7 @@ import {
45
45
  ReplayError,
46
46
  reportReplayProgress,
47
47
  serializeReplayResult
48
- } from "./chunk-N63C4XC6.js";
48
+ } from "./chunk-YYSL4RYF.js";
49
49
  import {
50
50
  BitfabError,
51
51
  DEFAULT_SERVICE_URL,
@@ -53,7 +53,7 @@ import {
53
53
  MixedTracingError,
54
54
  __version__,
55
55
  flushTraces
56
- } from "./chunk-3T32S5N7.js";
56
+ } from "./chunk-DLH4OESM.js";
57
57
  import "./chunk-MT36GJMW.js";
58
58
  export {
59
59
  AssertionCategoriesClient,
package/dist/node.cjs CHANGED
@@ -97,7 +97,7 @@ var __version__, __packageName__;
97
97
  var init_version_generated = __esm({
98
98
  "src/version.generated.ts"() {
99
99
  "use strict";
100
- __version__ = "0.64.12";
100
+ __version__ = "0.64.14";
101
101
  __packageName__ = "bitfab";
102
102
  }
103
103
  });
@@ -2753,6 +2753,12 @@ var init_http = __esm({
2753
2753
  const response = await this.get(endpoint);
2754
2754
  return response.span;
2755
2755
  }
2756
+ async getSpan(spanId) {
2757
+ const response = await this.get(
2758
+ `/api/sdk/spans/${encodeURIComponent(spanId)}`
2759
+ );
2760
+ return response.span;
2761
+ }
2756
2762
  /**
2757
2763
  * GET a JSON endpoint on the service with the client's API key. Throws a
2758
2764
  * `BitfabError` carrying the status text for any non-2xx response.
@@ -4657,7 +4663,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4657
4663
  dbBranchTimings: dbBranchTimings ?? null
4658
4664
  };
4659
4665
  }
4660
- async function waitForReplayPersistence(httpClient, experimentId, replayedTraceIds) {
4666
+ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceIds, replayLabels = {}, warn2 = console.warn) {
4661
4667
  const deferredSettled = await httpClient.settleDeferredWork(
4662
4668
  REPLAY_PERSISTENCE_TIMEOUT_MS
4663
4669
  );
@@ -4690,7 +4696,7 @@ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceI
4690
4696
  return readBackTraceIds;
4691
4697
  }
4692
4698
  const deadline = Date.now() + REPLAY_PERSISTENCE_TIMEOUT_MS;
4693
- let missing = Object.keys(expectedSpanCounts).length;
4699
+ let missing = Object.keys(expectedSpanCounts);
4694
4700
  while (true) {
4695
4701
  const status = await httpClient.getReplayStatus(
4696
4702
  experimentId,
@@ -4700,8 +4706,8 @@ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceI
4700
4706
  Object.assign(readBackTraceIds, ready);
4701
4707
  missing = Object.keys(expectedSpanCounts).filter(
4702
4708
  (traceId) => ready[traceId] === void 0
4703
- ).length;
4704
- if (missing === 0) {
4709
+ );
4710
+ if (missing.length === 0) {
4705
4711
  return readBackTraceIds;
4706
4712
  }
4707
4713
  if (Date.now() >= deadline) {
@@ -4711,10 +4717,19 @@ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceI
4711
4717
  Math.min(100, Math.max(0, deadline - Date.now()))
4712
4718
  );
4713
4719
  }
4714
- const cause = flushed ? "" : " Delivery was also not confirmed before the flush deadline, so the spans likely never reached the server.";
4715
- throw new BitfabError(
4716
- `Replay traces were not fully persisted before the delivery deadline (experiment ${experimentId}, missing ${missing} of ${Object.keys(expectedSpanCounts).length} trace(s)).${cause}`
4717
- );
4720
+ for (const traceId of missing) {
4721
+ warn2(
4722
+ unconfirmedReplayWarning(
4723
+ replayLabels[traceId] ?? traceId,
4724
+ REPLAY_PERSISTENCE_TIMEOUT_MS / 1e3,
4725
+ flushed
4726
+ )
4727
+ );
4728
+ }
4729
+ return readBackTraceIds;
4730
+ }
4731
+ function unconfirmedReplayWarning(label, seconds, flushed) {
4732
+ 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."}`;
4718
4733
  }
4719
4734
  function sleepForReplayPersistence(ms) {
4720
4735
  return new Promise((resolve) => {
@@ -5117,7 +5132,17 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
5117
5132
  }
5118
5133
  throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
5119
5134
  const deliveredTraceIds = await preserveReplayFailure(
5120
- () => waitForReplayPersistence(httpClient, experimentId, replayedTraceIds),
5135
+ () => waitForReplayPersistence(
5136
+ httpClient,
5137
+ experimentId,
5138
+ replayedTraceIds,
5139
+ Object.fromEntries(
5140
+ workItems.map(({ serverItem, attempt }, index) => [
5141
+ replayedTraceIds[index],
5142
+ `${serverItem.originalTraceId ?? serverItem.sourceTraceId}#${attempt}`
5143
+ ])
5144
+ )
5145
+ ),
5121
5146
  resultItems,
5122
5147
  experimentId,
5123
5148
  fullExperimentUrl
@@ -11481,6 +11506,12 @@ var Bitfab = class {
11481
11506
  }
11482
11507
  return this.httpClient.getTraceSpan(traceId, lookup);
11483
11508
  }
11509
+ async getSpan(spanId) {
11510
+ if (typeof spanId !== "string" || spanId.trim().length === 0) {
11511
+ throw new BitfabError("spanId must be a non-empty string");
11512
+ }
11513
+ return this.httpClient.getSpan(spanId);
11514
+ }
11484
11515
  /**
11485
11516
  * Get a function wrapper for a specific trace function key.
11486
11517
  *