@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.
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
@@ -27,7 +27,7 @@ import {
27
27
  getCurrentTrace,
28
28
  reseedFromRegistry,
29
29
  seedFromRegistry
30
- } from "./chunk-5QG5ZNU6.js";
30
+ } from "./chunk-F5ZFL5W6.js";
31
31
  import "./chunk-YWXQM6J3.js";
32
32
  import {
33
33
  BITFAB_PROGRESS_PREFIX,
@@ -36,7 +36,7 @@ import {
36
36
  ReplayError,
37
37
  reportReplayProgress,
38
38
  serializeReplayResult
39
- } from "./chunk-N5S3P2Y5.js";
39
+ } from "./chunk-PXNFY22G.js";
40
40
  import {
41
41
  BitfabError,
42
42
  DEFAULT_SERVICE_URL,
@@ -44,7 +44,7 @@ import {
44
44
  MixedTracingError,
45
45
  __version__,
46
46
  flushTraces
47
- } from "./chunk-JAD7I5FM.js";
47
+ } from "./chunk-A7NX4OKG.js";
48
48
  import "./chunk-MT36GJMW.js";
49
49
  export {
50
50
  AssertionCategoriesClient,
package/dist/node.cjs CHANGED
@@ -88,7 +88,7 @@ var __version__, __packageName__;
88
88
  var init_version_generated = __esm({
89
89
  "src/version.generated.ts"() {
90
90
  "use strict";
91
- __version__ = "0.64.12";
91
+ __version__ = "0.64.14";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -2744,6 +2744,12 @@ var init_http = __esm({
2744
2744
  const response = await this.get(endpoint);
2745
2745
  return response.span;
2746
2746
  }
2747
+ async getSpan(spanId) {
2748
+ const response = await this.get(
2749
+ `/api/sdk/spans/${encodeURIComponent(spanId)}`
2750
+ );
2751
+ return response.span;
2752
+ }
2747
2753
  /**
2748
2754
  * GET a JSON endpoint on the service with the client's API key. Throws a
2749
2755
  * `BitfabError` carrying the status text for any non-2xx response.
@@ -4648,7 +4654,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4648
4654
  dbBranchTimings: dbBranchTimings ?? null
4649
4655
  };
4650
4656
  }
4651
- async function waitForReplayPersistence(httpClient, experimentId, replayedTraceIds) {
4657
+ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceIds, replayLabels = {}, warn2 = console.warn) {
4652
4658
  const deferredSettled = await httpClient.settleDeferredWork(
4653
4659
  REPLAY_PERSISTENCE_TIMEOUT_MS
4654
4660
  );
@@ -4681,7 +4687,7 @@ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceI
4681
4687
  return readBackTraceIds;
4682
4688
  }
4683
4689
  const deadline = Date.now() + REPLAY_PERSISTENCE_TIMEOUT_MS;
4684
- let missing = Object.keys(expectedSpanCounts).length;
4690
+ let missing = Object.keys(expectedSpanCounts);
4685
4691
  while (true) {
4686
4692
  const status = await httpClient.getReplayStatus(
4687
4693
  experimentId,
@@ -4691,8 +4697,8 @@ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceI
4691
4697
  Object.assign(readBackTraceIds, ready);
4692
4698
  missing = Object.keys(expectedSpanCounts).filter(
4693
4699
  (traceId) => ready[traceId] === void 0
4694
- ).length;
4695
- if (missing === 0) {
4700
+ );
4701
+ if (missing.length === 0) {
4696
4702
  return readBackTraceIds;
4697
4703
  }
4698
4704
  if (Date.now() >= deadline) {
@@ -4702,10 +4708,19 @@ async function waitForReplayPersistence(httpClient, experimentId, replayedTraceI
4702
4708
  Math.min(100, Math.max(0, deadline - Date.now()))
4703
4709
  );
4704
4710
  }
4705
- const cause = flushed ? "" : " Delivery was also not confirmed before the flush deadline, so the spans likely never reached the server.";
4706
- throw new BitfabError(
4707
- `Replay traces were not fully persisted before the delivery deadline (experiment ${experimentId}, missing ${missing} of ${Object.keys(expectedSpanCounts).length} trace(s)).${cause}`
4708
- );
4711
+ for (const traceId of missing) {
4712
+ warn2(
4713
+ unconfirmedReplayWarning(
4714
+ replayLabels[traceId] ?? traceId,
4715
+ REPLAY_PERSISTENCE_TIMEOUT_MS / 1e3,
4716
+ flushed
4717
+ )
4718
+ );
4719
+ }
4720
+ return readBackTraceIds;
4721
+ }
4722
+ function unconfirmedReplayWarning(label, seconds, flushed) {
4723
+ 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."}`;
4709
4724
  }
4710
4725
  function sleepForReplayPersistence(ms) {
4711
4726
  return new Promise((resolve) => {
@@ -5108,7 +5123,17 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
5108
5123
  }
5109
5124
  throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
5110
5125
  const deliveredTraceIds = await preserveReplayFailure(
5111
- () => waitForReplayPersistence(httpClient, experimentId, replayedTraceIds),
5126
+ () => waitForReplayPersistence(
5127
+ httpClient,
5128
+ experimentId,
5129
+ replayedTraceIds,
5130
+ Object.fromEntries(
5131
+ workItems.map(({ serverItem, attempt }, index) => [
5132
+ replayedTraceIds[index],
5133
+ `${serverItem.originalTraceId ?? serverItem.sourceTraceId}#${attempt}`
5134
+ ])
5135
+ )
5136
+ ),
5112
5137
  resultItems,
5113
5138
  experimentId,
5114
5139
  fullExperimentUrl
@@ -11472,6 +11497,12 @@ var Bitfab = class {
11472
11497
  }
11473
11498
  return this.httpClient.getTraceSpan(traceId, lookup);
11474
11499
  }
11500
+ async getSpan(spanId) {
11501
+ if (typeof spanId !== "string" || spanId.trim().length === 0) {
11502
+ throw new BitfabError("spanId must be a non-empty string");
11503
+ }
11504
+ return this.httpClient.getSpan(spanId);
11505
+ }
11475
11506
  /**
11476
11507
  * Get a function wrapper for a specific trace function key.
11477
11508
  *