bitfab 0.36.13 → 0.38.0

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.cjs CHANGED
@@ -51,7 +51,7 @@ var __version__;
51
51
  var init_version_generated = __esm({
52
52
  "src/version.generated.ts"() {
53
53
  "use strict";
54
- __version__ = "0.36.13";
54
+ __version__ = "0.38.0";
55
55
  }
56
56
  });
57
57
 
@@ -2534,12 +2534,15 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2534
2534
  let lease = includeDbBranchLease ? serverItem.dbBranchLease : void 0;
2535
2535
  let leaseError = includeDbBranchLease ? serverItem.dbBranchLeaseError : void 0;
2536
2536
  let dbSnapshotRef = serverItem.dbSnapshotRef;
2537
+ let dbBranchTimings = includeDbBranchLease ? serverItem.dbBranchTimings : void 0;
2537
2538
  let inputs = [];
2538
2539
  let originalOutput;
2539
2540
  let result;
2540
2541
  let error = null;
2541
2542
  let traceError = null;
2542
2543
  let replayError = null;
2544
+ let replayDurationMs = null;
2545
+ let replayStarted = null;
2543
2546
  const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
2544
2547
  const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
2545
2548
  try {
@@ -2562,6 +2565,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2562
2565
  lease = resolved.lease ?? void 0;
2563
2566
  leaseError = resolved.leaseError ?? void 0;
2564
2567
  dbSnapshotRef = resolved.dbSnapshotRef ?? dbSnapshotRef;
2568
+ dbBranchTimings = resolved.timings ?? dbBranchTimings;
2565
2569
  }
2566
2570
  if (leaseError) {
2567
2571
  throw new DbBranchReplayError(
@@ -2622,6 +2626,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2622
2626
  return pending;
2623
2627
  } : void 0;
2624
2628
  try {
2629
+ replayStarted = performance.now();
2625
2630
  const maybePromise = runWithReplayContext(
2626
2631
  {
2627
2632
  testRunId,
@@ -2634,16 +2639,24 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2634
2639
  mockStrategy,
2635
2640
  mockOverrides: hasOverrides ? resolvedOverrides : void 0,
2636
2641
  fetchSpanOutput,
2637
- dbBranchLease: lease
2642
+ dbBranchLease: lease,
2643
+ dbBranchTimings
2638
2644
  },
2639
2645
  () => fn(...inputs)
2640
2646
  );
2641
2647
  result = maybePromise instanceof Promise ? await maybePromise : maybePromise;
2648
+ replayDurationMs = Math.round(performance.now() - replayStarted);
2642
2649
  } catch (e) {
2650
+ if (replayStarted !== null) {
2651
+ replayDurationMs = Math.round(performance.now() - replayStarted);
2652
+ }
2643
2653
  traceError = e;
2644
2654
  error = errorMessage(e);
2645
2655
  }
2646
2656
  } catch (e) {
2657
+ if (replayStarted !== null) {
2658
+ replayDurationMs = Math.round(performance.now() - replayStarted);
2659
+ }
2647
2660
  replayError = e;
2648
2661
  error = replayItemErrorMessage(e);
2649
2662
  } finally {
@@ -2660,6 +2673,8 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2660
2673
  }
2661
2674
  }
2662
2675
  }
2676
+ const originalDurationMs = serverItem.originalDurationMs ?? serverItem.durationMs ?? null;
2677
+ const originalModel = serverItem.originalModel ?? serverItem.model ?? null;
2663
2678
  return {
2664
2679
  // Written in by replay() from the complete-replay response once the server
2665
2680
  // has minted this replay trace's row. Null until then: the client-side
@@ -2676,13 +2691,17 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
2676
2691
  error,
2677
2692
  traceError,
2678
2693
  replayError,
2679
- durationMs: serverItem.durationMs ?? null,
2694
+ durationMs: replayDurationMs,
2695
+ originalDurationMs,
2696
+ originalTokens: serverItem.originalTokens ?? serverItem.tokens ?? null,
2697
+ originalModel,
2680
2698
  // Filled in by replay() from the complete-replay response once the
2681
2699
  // replay traces are persisted and their spans aggregated server-side.
2682
2700
  // Null here (and on older servers) means "replay tokens not known".
2683
2701
  tokens: null,
2684
- model: serverItem.model ?? null,
2685
- dbSnapshotRef: dbSnapshotRef ?? null
2702
+ model: originalModel,
2703
+ dbSnapshotRef: dbSnapshotRef ?? null,
2704
+ dbBranchTimings: dbBranchTimings ?? null
2686
2705
  };
2687
2706
  }
2688
2707
  async function waitForReplayPersistence(httpClient, testRunId, replayedTraceIds) {
@@ -2909,9 +2928,13 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
2909
2928
  traceError: item.traceError,
2910
2929
  replayError: item.replayError,
2911
2930
  durationMs: item.durationMs,
2931
+ originalDurationMs: item.originalDurationMs,
2932
+ originalTokens: item.originalTokens,
2933
+ originalModel: item.originalModel,
2912
2934
  tokens: item.tokens,
2913
2935
  model: item.model,
2914
- dbSnapshotRef: item.dbSnapshotRef
2936
+ dbSnapshotRef: item.dbSnapshotRef,
2937
+ dbBranchTimings: item.dbBranchTimings
2915
2938
  }
2916
2939
  });
2917
2940
  } catch {
@@ -6090,7 +6113,8 @@ var Bitfab = class {
6090
6113
  snapshotTimestamp: replayCtx.dbBranchLease.snapshotTimestamp,
6091
6114
  region: replayCtx.dbBranchLease.region,
6092
6115
  originalTraceId: replayCtx.sourceBitfabTraceId,
6093
- accessed: replayCtx.dbSnapshotAccessed === true
6116
+ accessed: replayCtx.dbSnapshotAccessed === true,
6117
+ timings: replayCtx.dbBranchTimings
6094
6118
  }
6095
6119
  }
6096
6120
  });
@@ -6422,7 +6446,13 @@ var Bitfab = class {
6422
6446
  // against servers that predate the rename.
6423
6447
  source_trace_id: params.dbSnapshotUsage.originalTraceId
6424
6448
  },
6425
- accessed: params.dbSnapshotUsage.accessed
6449
+ accessed: params.dbSnapshotUsage.accessed,
6450
+ // Echoed verbatim (camelCase inside) rather than re-cased into this
6451
+ // record's snake_case: it is the server's own object coming back, and
6452
+ // a translation layer here is one more thing to drift.
6453
+ ...params.dbSnapshotUsage.timings && {
6454
+ timings: params.dbSnapshotUsage.timings
6455
+ }
6426
6456
  };
6427
6457
  }
6428
6458
  this.httpClient.sendExternalTrace({