@bitfab/sdk 0.41.0 → 0.42.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/{chunk-U3AKIFW3.js → chunk-BC5OYWAM.js} +12 -5
- package/dist/chunk-BC5OYWAM.js.map +1 -0
- package/dist/{chunk-RWZYZRYI.js → chunk-BG3A5HNC.js} +42 -12
- package/dist/chunk-BG3A5HNC.js.map +1 -0
- package/dist/{chunk-VEA6JOKL.js → chunk-QJ6IFPGU.js} +15 -6
- package/dist/chunk-QJ6IFPGU.js.map +1 -0
- package/dist/{chunk-IFYX3KW6.js → chunk-UGFTBSGS.js} +15 -6
- package/dist/chunk-UGFTBSGS.js.map +1 -0
- package/dist/{http-UCJCOKW7.js → http-F5L466DI.js} +2 -2
- package/dist/{http-JSBWHPNA.js → http-NZHGC5YF.js} +2 -2
- package/dist/index.cjs +63 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +3 -3
- package/dist/node.cjs +63 -17
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-HMMWDSLB.js → replay-PLACY77M.js} +3 -3
- package/dist/replayCli.js +18 -4
- package/dist/replayCli.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-IFYX3KW6.js.map +0 -1
- package/dist/chunk-RWZYZRYI.js.map +0 -1
- package/dist/chunk-U3AKIFW3.js.map +0 -1
- package/dist/chunk-VEA6JOKL.js.map +0 -1
- /package/dist/{http-JSBWHPNA.js.map → http-F5L466DI.js.map} +0 -0
- /package/dist/{http-UCJCOKW7.js.map → http-NZHGC5YF.js.map} +0 -0
- /package/dist/{replay-HMMWDSLB.js.map → replay-PLACY77M.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -306,6 +306,7 @@ interface ReplayContext {
|
|
|
306
306
|
* customer sees in the Bitfab dashboard.
|
|
307
307
|
*/
|
|
308
308
|
sourceBitfabTraceId?: string;
|
|
309
|
+
replayAttempt?: number;
|
|
309
310
|
mockTree?: MockTree;
|
|
310
311
|
callCounters?: Map<string, number>;
|
|
311
312
|
mockStrategy?: "none" | "all" | "marked";
|
|
@@ -584,7 +585,7 @@ declare class HttpClient {
|
|
|
584
585
|
* Start a replay session by fetching historical traces.
|
|
585
586
|
* Blocking call - creates a test run and returns lightweight item references.
|
|
586
587
|
*/
|
|
587
|
-
startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetId?: string, graderIds?: string[], dbBranchSettings?: DbBranchSettings): Promise<StartReplayResponse>;
|
|
588
|
+
startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetId?: string, graderIds?: string[], dbBranchSettings?: DbBranchSettings, attempts?: number): Promise<StartReplayResponse>;
|
|
588
589
|
/**
|
|
589
590
|
* Fetch an external span by ID.
|
|
590
591
|
* Blocking GET request.
|
|
@@ -625,7 +626,7 @@ declare class HttpClient {
|
|
|
625
626
|
* snapshot + preview branch and polls operations to readiness, which
|
|
626
627
|
* can take seconds.
|
|
627
628
|
*/
|
|
628
|
-
resolveDbBranchLease(testRunId: string, traceId: string, dbBranchSettings?: DbBranchSettings): Promise<{
|
|
629
|
+
resolveDbBranchLease(testRunId: string, traceId: string, dbBranchSettings?: DbBranchSettings, attempt?: number): Promise<{
|
|
629
630
|
dbSnapshotRef: DbSnapshotRef | null;
|
|
630
631
|
lease: DbBranchLease | null;
|
|
631
632
|
leaseError: {
|
|
@@ -658,6 +659,7 @@ interface CodeChangeFile {
|
|
|
658
659
|
interface StartReplayResponse {
|
|
659
660
|
testRunId: string;
|
|
660
661
|
testRunUrl: string;
|
|
662
|
+
attempts?: number;
|
|
661
663
|
items: Array<{
|
|
662
664
|
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
663
665
|
originalTraceId?: string;
|
|
@@ -1472,6 +1474,7 @@ interface ReplayOptions {
|
|
|
1472
1474
|
* because either source already determines how many traces replay.
|
|
1473
1475
|
*/
|
|
1474
1476
|
limit?: number;
|
|
1477
|
+
attempts?: number;
|
|
1475
1478
|
/** Optional list of specific trace IDs to replay (max 100). Mutually exclusive with `datasetId`. */
|
|
1476
1479
|
traceIds?: string[];
|
|
1477
1480
|
/** Optional display name for the resulting experiment/test run. */
|
|
@@ -1624,6 +1627,7 @@ interface ReplayItemStartProgress {
|
|
|
1624
1627
|
sourceTraceId: string;
|
|
1625
1628
|
/** @deprecated alias for `originalSpanId`. */
|
|
1626
1629
|
sourceSpanId: string;
|
|
1630
|
+
attempt: number;
|
|
1627
1631
|
};
|
|
1628
1632
|
}
|
|
1629
1633
|
/** Running totals reported to {@link ReplayOptions.onItemFinish} as replay proceeds. */
|
|
@@ -1663,6 +1667,7 @@ interface ReplayProgressItem {
|
|
|
1663
1667
|
sourceTraceId: string | null;
|
|
1664
1668
|
/** @deprecated alias for `originalSpanId`. */
|
|
1665
1669
|
sourceSpanId?: string | null;
|
|
1670
|
+
attempt: number;
|
|
1666
1671
|
/** Deserialized inputs from the original trace. */
|
|
1667
1672
|
input?: unknown[];
|
|
1668
1673
|
/** The result returned by the replayed function, or undefined on error. */
|
|
@@ -1772,6 +1777,7 @@ interface ReplayItem<T> {
|
|
|
1772
1777
|
sourceTraceId: string;
|
|
1773
1778
|
/** @deprecated alias for {@link ReplayItem.originalSpanId}. */
|
|
1774
1779
|
sourceSpanId: string;
|
|
1780
|
+
attempt: number;
|
|
1775
1781
|
/** Deserialized inputs from the original trace. */
|
|
1776
1782
|
input: unknown[];
|
|
1777
1783
|
/** The result returned by the function during replay, or undefined on error. */
|
|
@@ -1850,6 +1856,7 @@ interface ReplayResult<T> {
|
|
|
1850
1856
|
testRunId: string;
|
|
1851
1857
|
/** Full URL to view the test run in the dashboard. */
|
|
1852
1858
|
testRunUrl: string;
|
|
1859
|
+
attempts: number;
|
|
1853
1860
|
}
|
|
1854
1861
|
/**
|
|
1855
1862
|
* Whole-run replay failure that preserves every item collected before the run
|
|
@@ -3100,7 +3107,7 @@ declare class BitfabFunction {
|
|
|
3100
3107
|
/**
|
|
3101
3108
|
* SDK version from package.json (injected at build time)
|
|
3102
3109
|
*/
|
|
3103
|
-
declare const __version__ = "0.
|
|
3110
|
+
declare const __version__ = "0.42.0";
|
|
3104
3111
|
|
|
3105
3112
|
/**
|
|
3106
3113
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -306,6 +306,7 @@ interface ReplayContext {
|
|
|
306
306
|
* customer sees in the Bitfab dashboard.
|
|
307
307
|
*/
|
|
308
308
|
sourceBitfabTraceId?: string;
|
|
309
|
+
replayAttempt?: number;
|
|
309
310
|
mockTree?: MockTree;
|
|
310
311
|
callCounters?: Map<string, number>;
|
|
311
312
|
mockStrategy?: "none" | "all" | "marked";
|
|
@@ -584,7 +585,7 @@ declare class HttpClient {
|
|
|
584
585
|
* Start a replay session by fetching historical traces.
|
|
585
586
|
* Blocking call - creates a test run and returns lightweight item references.
|
|
586
587
|
*/
|
|
587
|
-
startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetId?: string, graderIds?: string[], dbBranchSettings?: DbBranchSettings): Promise<StartReplayResponse>;
|
|
588
|
+
startReplay(traceFunctionKey: string, limit: number | undefined, traceIds?: string[], name?: string, codeChangeDescription?: string | null, codeChangeFiles?: CodeChangeFile[] | null, includeDbBranchLease?: boolean, experimentGroupId?: string, datasetId?: string, graderIds?: string[], dbBranchSettings?: DbBranchSettings, attempts?: number): Promise<StartReplayResponse>;
|
|
588
589
|
/**
|
|
589
590
|
* Fetch an external span by ID.
|
|
590
591
|
* Blocking GET request.
|
|
@@ -625,7 +626,7 @@ declare class HttpClient {
|
|
|
625
626
|
* snapshot + preview branch and polls operations to readiness, which
|
|
626
627
|
* can take seconds.
|
|
627
628
|
*/
|
|
628
|
-
resolveDbBranchLease(testRunId: string, traceId: string, dbBranchSettings?: DbBranchSettings): Promise<{
|
|
629
|
+
resolveDbBranchLease(testRunId: string, traceId: string, dbBranchSettings?: DbBranchSettings, attempt?: number): Promise<{
|
|
629
630
|
dbSnapshotRef: DbSnapshotRef | null;
|
|
630
631
|
lease: DbBranchLease | null;
|
|
631
632
|
leaseError: {
|
|
@@ -658,6 +659,7 @@ interface CodeChangeFile {
|
|
|
658
659
|
interface StartReplayResponse {
|
|
659
660
|
testRunId: string;
|
|
660
661
|
testRunUrl: string;
|
|
662
|
+
attempts?: number;
|
|
661
663
|
items: Array<{
|
|
662
664
|
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
663
665
|
originalTraceId?: string;
|
|
@@ -1472,6 +1474,7 @@ interface ReplayOptions {
|
|
|
1472
1474
|
* because either source already determines how many traces replay.
|
|
1473
1475
|
*/
|
|
1474
1476
|
limit?: number;
|
|
1477
|
+
attempts?: number;
|
|
1475
1478
|
/** Optional list of specific trace IDs to replay (max 100). Mutually exclusive with `datasetId`. */
|
|
1476
1479
|
traceIds?: string[];
|
|
1477
1480
|
/** Optional display name for the resulting experiment/test run. */
|
|
@@ -1624,6 +1627,7 @@ interface ReplayItemStartProgress {
|
|
|
1624
1627
|
sourceTraceId: string;
|
|
1625
1628
|
/** @deprecated alias for `originalSpanId`. */
|
|
1626
1629
|
sourceSpanId: string;
|
|
1630
|
+
attempt: number;
|
|
1627
1631
|
};
|
|
1628
1632
|
}
|
|
1629
1633
|
/** Running totals reported to {@link ReplayOptions.onItemFinish} as replay proceeds. */
|
|
@@ -1663,6 +1667,7 @@ interface ReplayProgressItem {
|
|
|
1663
1667
|
sourceTraceId: string | null;
|
|
1664
1668
|
/** @deprecated alias for `originalSpanId`. */
|
|
1665
1669
|
sourceSpanId?: string | null;
|
|
1670
|
+
attempt: number;
|
|
1666
1671
|
/** Deserialized inputs from the original trace. */
|
|
1667
1672
|
input?: unknown[];
|
|
1668
1673
|
/** The result returned by the replayed function, or undefined on error. */
|
|
@@ -1772,6 +1777,7 @@ interface ReplayItem<T> {
|
|
|
1772
1777
|
sourceTraceId: string;
|
|
1773
1778
|
/** @deprecated alias for {@link ReplayItem.originalSpanId}. */
|
|
1774
1779
|
sourceSpanId: string;
|
|
1780
|
+
attempt: number;
|
|
1775
1781
|
/** Deserialized inputs from the original trace. */
|
|
1776
1782
|
input: unknown[];
|
|
1777
1783
|
/** The result returned by the function during replay, or undefined on error. */
|
|
@@ -1850,6 +1856,7 @@ interface ReplayResult<T> {
|
|
|
1850
1856
|
testRunId: string;
|
|
1851
1857
|
/** Full URL to view the test run in the dashboard. */
|
|
1852
1858
|
testRunUrl: string;
|
|
1859
|
+
attempts: number;
|
|
1853
1860
|
}
|
|
1854
1861
|
/**
|
|
1855
1862
|
* Whole-run replay failure that preserves every item collected before the run
|
|
@@ -3100,7 +3107,7 @@ declare class BitfabFunction {
|
|
|
3100
3107
|
/**
|
|
3101
3108
|
* SDK version from package.json (injected at build time)
|
|
3102
3109
|
*/
|
|
3103
|
-
declare const __version__ = "0.
|
|
3110
|
+
declare const __version__ = "0.42.0";
|
|
3104
3111
|
|
|
3105
3112
|
/**
|
|
3106
3113
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
getCurrentSpan,
|
|
16
16
|
getCurrentTrace,
|
|
17
17
|
seedFromRegistry
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-BC5OYWAM.js";
|
|
19
19
|
import "./chunk-ZUD7OFYB.js";
|
|
20
20
|
import {
|
|
21
21
|
BITFAB_PROGRESS_PREFIX,
|
|
@@ -24,14 +24,14 @@ import {
|
|
|
24
24
|
ReplayError,
|
|
25
25
|
reportReplayProgress,
|
|
26
26
|
serializeReplayResult
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-BG3A5HNC.js";
|
|
28
28
|
import {
|
|
29
29
|
BitfabError,
|
|
30
30
|
DEFAULT_SERVICE_URL,
|
|
31
31
|
HttpClient,
|
|
32
32
|
__version__,
|
|
33
33
|
flushTraces
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-UGFTBSGS.js";
|
|
35
35
|
import "./chunk-H6LZRFMN.js";
|
|
36
36
|
export {
|
|
37
37
|
BITFAB_PROGRESS_PREFIX,
|
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.
|
|
91
|
+
__version__ = "0.42.0";
|
|
92
92
|
__packageName__ = "@bitfab/sdk";
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -1344,7 +1344,7 @@ function sourceTraceIdOf(payload) {
|
|
|
1344
1344
|
const id = rawTrace?.id;
|
|
1345
1345
|
return typeof id === "string" ? id : void 0;
|
|
1346
1346
|
}
|
|
1347
|
-
var REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS, OTLP_TRACES_ENDPOINT, RETRYABLE_STATUSES, EXIT_FLUSH_TIMEOUT_MS, DEFAULT_LIFECYCLE_TIMEOUT_MS2, pendingTracePromises, carrierSeq, HttpClient;
|
|
1347
|
+
var REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS, REPLAY_COMPLETE_REQUEST_TIMEOUT_MS, OTLP_TRACES_ENDPOINT, RETRYABLE_STATUSES, EXIT_FLUSH_TIMEOUT_MS, DEFAULT_LIFECYCLE_TIMEOUT_MS2, pendingTracePromises, carrierSeq, HttpClient;
|
|
1348
1348
|
var init_http = __esm({
|
|
1349
1349
|
"src/http.ts"() {
|
|
1350
1350
|
"use strict";
|
|
@@ -1358,6 +1358,7 @@ var init_http = __esm({
|
|
|
1358
1358
|
init_unrefTimer();
|
|
1359
1359
|
init_warnOnce();
|
|
1360
1360
|
REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS = 3e5;
|
|
1361
|
+
REPLAY_COMPLETE_REQUEST_TIMEOUT_MS = 12e4;
|
|
1361
1362
|
OTLP_TRACES_ENDPOINT = "/api/sdk/otel/v1/traces";
|
|
1362
1363
|
RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
1363
1364
|
EXIT_FLUSH_TIMEOUT_MS = 5e3;
|
|
@@ -1847,7 +1848,7 @@ var init_http = __esm({
|
|
|
1847
1848
|
* Start a replay session by fetching historical traces.
|
|
1848
1849
|
* Blocking call - creates a test run and returns lightweight item references.
|
|
1849
1850
|
*/
|
|
1850
|
-
async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId, graderIds, dbBranchSettings) {
|
|
1851
|
+
async startReplay(traceFunctionKey, limit, traceIds, name, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId, graderIds, dbBranchSettings, attempts) {
|
|
1851
1852
|
const payload = { traceFunctionKey };
|
|
1852
1853
|
if (limit !== void 0) {
|
|
1853
1854
|
payload.limit = limit;
|
|
@@ -1880,6 +1881,9 @@ var init_http = __esm({
|
|
|
1880
1881
|
if (dbBranchSettings !== void 0) {
|
|
1881
1882
|
payload.dbBranchSettings = dbBranchSettings;
|
|
1882
1883
|
}
|
|
1884
|
+
if (attempts !== void 0 && attempts > 1) {
|
|
1885
|
+
payload.attempts = attempts;
|
|
1886
|
+
}
|
|
1883
1887
|
const timeout = includeDbBranchLease ? REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS : 3e4;
|
|
1884
1888
|
return this.request("/api/sdk/replay/start", payload, {
|
|
1885
1889
|
timeout
|
|
@@ -1995,7 +1999,7 @@ var init_http = __esm({
|
|
|
1995
1999
|
return this.request(
|
|
1996
2000
|
"/api/sdk/replay/complete",
|
|
1997
2001
|
{ testRunId },
|
|
1998
|
-
{ timeout:
|
|
2002
|
+
{ timeout: REPLAY_COMPLETE_REQUEST_TIMEOUT_MS }
|
|
1999
2003
|
);
|
|
2000
2004
|
}
|
|
2001
2005
|
/**
|
|
@@ -2004,10 +2008,15 @@ var init_http = __esm({
|
|
|
2004
2008
|
* snapshot + preview branch and polls operations to readiness, which
|
|
2005
2009
|
* can take seconds.
|
|
2006
2010
|
*/
|
|
2007
|
-
async resolveDbBranchLease(testRunId, traceId, dbBranchSettings) {
|
|
2011
|
+
async resolveDbBranchLease(testRunId, traceId, dbBranchSettings, attempt) {
|
|
2008
2012
|
return this.request(
|
|
2009
2013
|
"/api/sdk/replay/resolveDbBranchLease",
|
|
2010
|
-
{
|
|
2014
|
+
{
|
|
2015
|
+
testRunId,
|
|
2016
|
+
traceId,
|
|
2017
|
+
dbBranchSettings,
|
|
2018
|
+
...attempt !== void 0 && attempt > 0 ? { attempt } : {}
|
|
2019
|
+
},
|
|
2011
2020
|
{ timeout: REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS }
|
|
2012
2021
|
);
|
|
2013
2022
|
}
|
|
@@ -2443,6 +2452,23 @@ __export(replay_exports, {
|
|
|
2443
2452
|
sleepForReplayPersistence: () => sleepForReplayPersistence,
|
|
2444
2453
|
waitForReplayPersistence: () => waitForReplayPersistence
|
|
2445
2454
|
});
|
|
2455
|
+
function expandReplayWork(serverItems, attempts) {
|
|
2456
|
+
return Array.from(
|
|
2457
|
+
{ length: attempts },
|
|
2458
|
+
(_, attempt) => serverItems.map((serverItem) => ({ serverItem, attempt }))
|
|
2459
|
+
).flat();
|
|
2460
|
+
}
|
|
2461
|
+
function resolveAttempts(attempts) {
|
|
2462
|
+
if (attempts === void 0) {
|
|
2463
|
+
return 1;
|
|
2464
|
+
}
|
|
2465
|
+
if (!Number.isInteger(attempts) || attempts < 1 || attempts > MAX_REPLAY_ATTEMPTS) {
|
|
2466
|
+
throw new BitfabError(
|
|
2467
|
+
`attempts must be an integer from 1 to ${MAX_REPLAY_ATTEMPTS} (got ${attempts}).`
|
|
2468
|
+
);
|
|
2469
|
+
}
|
|
2470
|
+
return attempts;
|
|
2471
|
+
}
|
|
2446
2472
|
function dbBranchEnabled(dbBranch) {
|
|
2447
2473
|
return dbBranch !== void 0 && dbBranch !== false;
|
|
2448
2474
|
}
|
|
@@ -2566,7 +2592,7 @@ function buildMockTree(rootNode) {
|
|
|
2566
2592
|
}
|
|
2567
2593
|
return { spans };
|
|
2568
2594
|
}
|
|
2569
|
-
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, includeDbBranchLease, dbBranchSettings, adaptInputs, dryRun) {
|
|
2595
|
+
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, attempt, includeDbBranchLease, dbBranchSettings, adaptInputs, dryRun) {
|
|
2570
2596
|
let lease = includeDbBranchLease ? serverItem.dbBranchLease : void 0;
|
|
2571
2597
|
let leaseError = includeDbBranchLease ? serverItem.dbBranchLeaseError : void 0;
|
|
2572
2598
|
let dbSnapshotRef = serverItem.dbSnapshotRef;
|
|
@@ -2588,7 +2614,8 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
2588
2614
|
resolved = await httpClient.resolveDbBranchLease(
|
|
2589
2615
|
testRunId,
|
|
2590
2616
|
originalTraceId,
|
|
2591
|
-
dbBranchSettings
|
|
2617
|
+
dbBranchSettings,
|
|
2618
|
+
attempt
|
|
2592
2619
|
);
|
|
2593
2620
|
} catch (cause) {
|
|
2594
2621
|
throw new DbBranchReplayError(
|
|
@@ -2668,6 +2695,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
2668
2695
|
originalSpanId,
|
|
2669
2696
|
sourceTraceId: originalTraceId,
|
|
2670
2697
|
sourceSpanId: originalSpanId,
|
|
2698
|
+
attempt,
|
|
2671
2699
|
input: inputs,
|
|
2672
2700
|
result: void 0,
|
|
2673
2701
|
originalOutput,
|
|
@@ -2696,6 +2724,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
2696
2724
|
inputSourceSpanId: span.id,
|
|
2697
2725
|
inputSourceTraceId: span.externalTraceId,
|
|
2698
2726
|
sourceBitfabTraceId: originalTraceId,
|
|
2727
|
+
replayAttempt: attempt,
|
|
2699
2728
|
mockTree,
|
|
2700
2729
|
callCounters: mockTree ? /* @__PURE__ */ new Map() : void 0,
|
|
2701
2730
|
mockStrategy,
|
|
@@ -2747,6 +2776,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
2747
2776
|
// Deprecated aliases for originalTraceId/originalSpanId.
|
|
2748
2777
|
sourceTraceId: originalTraceId,
|
|
2749
2778
|
sourceSpanId: originalSpanId,
|
|
2779
|
+
attempt,
|
|
2750
2780
|
input: inputs,
|
|
2751
2781
|
result,
|
|
2752
2782
|
originalOutput,
|
|
@@ -2875,6 +2905,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
2875
2905
|
} catch {
|
|
2876
2906
|
}
|
|
2877
2907
|
}
|
|
2908
|
+
const attempts = resolveAttempts(options?.attempts);
|
|
2878
2909
|
await replayContextReady;
|
|
2879
2910
|
let codeChangeDescription = options?.codeChangeDescription;
|
|
2880
2911
|
let codeChangeFiles = options?.codeChangeFiles;
|
|
@@ -2907,7 +2938,8 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
2907
2938
|
options?.experimentGroupId,
|
|
2908
2939
|
options?.datasetId,
|
|
2909
2940
|
options?.graderIds,
|
|
2910
|
-
resolveDbBranchSettings(options?.dbBranch)
|
|
2941
|
+
resolveDbBranchSettings(options?.dbBranch),
|
|
2942
|
+
attempts
|
|
2911
2943
|
);
|
|
2912
2944
|
if (serverItems.length === 0) {
|
|
2913
2945
|
try {
|
|
@@ -2924,10 +2956,11 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
2924
2956
|
...normalizeMockOverrides(options?.mockOverride),
|
|
2925
2957
|
...registeredOverrides
|
|
2926
2958
|
];
|
|
2927
|
-
const
|
|
2959
|
+
const workItems = expandReplayWork(serverItems, attempts);
|
|
2960
|
+
const replayedTraceIds = workItems.map(() => randomUuid());
|
|
2928
2961
|
httpClient.trackTraceDeliveries(replayedTraceIds);
|
|
2929
|
-
const tasks =
|
|
2930
|
-
(serverItem, index) => () => processItem(
|
|
2962
|
+
const tasks = workItems.map(
|
|
2963
|
+
({ serverItem, attempt }, index) => () => processItem(
|
|
2931
2964
|
httpClient,
|
|
2932
2965
|
serverItem,
|
|
2933
2966
|
fn,
|
|
@@ -2935,6 +2968,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
2935
2968
|
mockStrategy,
|
|
2936
2969
|
resolvedOverrides,
|
|
2937
2970
|
replayedTraceIds[index],
|
|
2971
|
+
attempt,
|
|
2938
2972
|
dbBranchEnabled(options?.dbBranch) && options?.dryRun !== true,
|
|
2939
2973
|
resolveDbBranchSettings(options?.dbBranch),
|
|
2940
2974
|
options?.adaptInputs,
|
|
@@ -3002,6 +3036,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
3002
3036
|
// Deprecated aliases for originalTraceId/originalSpanId.
|
|
3003
3037
|
sourceTraceId: item.originalTraceId ?? null,
|
|
3004
3038
|
sourceSpanId: item.originalSpanId ?? null,
|
|
3039
|
+
attempt: item.attempt,
|
|
3005
3040
|
input: item.input,
|
|
3006
3041
|
result: item.result,
|
|
3007
3042
|
originalOutput: item.originalOutput,
|
|
@@ -3023,7 +3058,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
3023
3058
|
},
|
|
3024
3059
|
options?.onItemStart ? (index) => {
|
|
3025
3060
|
started += 1;
|
|
3026
|
-
const serverItem =
|
|
3061
|
+
const { serverItem, attempt } = workItems[index];
|
|
3027
3062
|
const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
|
|
3028
3063
|
const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
|
|
3029
3064
|
try {
|
|
@@ -3039,7 +3074,8 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
3039
3074
|
originalTraceId,
|
|
3040
3075
|
originalSpanId,
|
|
3041
3076
|
sourceTraceId: originalTraceId,
|
|
3042
|
-
sourceSpanId: originalSpanId
|
|
3077
|
+
sourceSpanId: originalSpanId,
|
|
3078
|
+
attempt
|
|
3043
3079
|
}
|
|
3044
3080
|
});
|
|
3045
3081
|
} catch {
|
|
@@ -3051,7 +3087,8 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
3051
3087
|
const dryResult = {
|
|
3052
3088
|
items: resultItems,
|
|
3053
3089
|
testRunId,
|
|
3054
|
-
testRunUrl: fullTestRunUrl
|
|
3090
|
+
testRunUrl: fullTestRunUrl,
|
|
3091
|
+
attempts
|
|
3055
3092
|
};
|
|
3056
3093
|
await writeReplayResultFile(dryResult);
|
|
3057
3094
|
return dryResult;
|
|
@@ -3120,7 +3157,8 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
3120
3157
|
const result = {
|
|
3121
3158
|
items: resultItems,
|
|
3122
3159
|
testRunId,
|
|
3123
|
-
testRunUrl: fullTestRunUrl
|
|
3160
|
+
testRunUrl: fullTestRunUrl,
|
|
3161
|
+
attempts
|
|
3124
3162
|
};
|
|
3125
3163
|
await writeReplayResultFile(result);
|
|
3126
3164
|
if (!options?.onItemFinish) {
|
|
@@ -3161,7 +3199,7 @@ async function writeReplayResultFile(result) {
|
|
|
3161
3199
|
}
|
|
3162
3200
|
}
|
|
3163
3201
|
}
|
|
3164
|
-
var REPLAY_PERSISTENCE_TIMEOUT_MS, BITFAB_PROGRESS_PREFIX, ReplayError, DbBranchReplayError;
|
|
3202
|
+
var REPLAY_PERSISTENCE_TIMEOUT_MS, MAX_REPLAY_ATTEMPTS, BITFAB_PROGRESS_PREFIX, ReplayError, DbBranchReplayError;
|
|
3165
3203
|
var init_replay = __esm({
|
|
3166
3204
|
"src/replay.ts"() {
|
|
3167
3205
|
"use strict";
|
|
@@ -3173,6 +3211,7 @@ var init_replay = __esm({
|
|
|
3173
3211
|
init_replayContext();
|
|
3174
3212
|
init_serialize();
|
|
3175
3213
|
REPLAY_PERSISTENCE_TIMEOUT_MS = 3e4;
|
|
3214
|
+
MAX_REPLAY_ATTEMPTS = 100;
|
|
3176
3215
|
BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
|
|
3177
3216
|
ReplayError = class extends BitfabError {
|
|
3178
3217
|
constructor(message, items, testRunId, testRunUrl, cause) {
|
|
@@ -7026,6 +7065,9 @@ var Bitfab = class {
|
|
|
7026
7065
|
...replayCtxAtStart?.inputSourceTraceId && {
|
|
7027
7066
|
inputSourceTraceId: replayCtxAtStart.inputSourceTraceId
|
|
7028
7067
|
},
|
|
7068
|
+
...replayCtxAtStart?.replayAttempt !== void 0 && {
|
|
7069
|
+
replayAttempt: replayCtxAtStart.replayAttempt
|
|
7070
|
+
},
|
|
7029
7071
|
dbSnapshotRef
|
|
7030
7072
|
});
|
|
7031
7073
|
registeredTraceId = traceId;
|
|
@@ -7076,6 +7118,7 @@ var Bitfab = class {
|
|
|
7076
7118
|
contexts: traceState?.contexts ?? [],
|
|
7077
7119
|
testRunId: traceState?.testRunId,
|
|
7078
7120
|
inputSourceTraceId: traceState?.inputSourceTraceId,
|
|
7121
|
+
replayAttempt: traceState?.replayAttempt,
|
|
7079
7122
|
dbSnapshotRef: traceState?.dbSnapshotRef,
|
|
7080
7123
|
dropped: traceState?.dropped,
|
|
7081
7124
|
ingestionType: traceState?.ingestionType,
|
|
@@ -7473,6 +7516,9 @@ var Bitfab = class {
|
|
|
7473
7516
|
if (params.inputSourceTraceId) {
|
|
7474
7517
|
rawTrace.input_source_trace_id = params.inputSourceTraceId;
|
|
7475
7518
|
}
|
|
7519
|
+
if (params.replayAttempt !== void 0) {
|
|
7520
|
+
rawTrace.replay_attempt = params.replayAttempt;
|
|
7521
|
+
}
|
|
7476
7522
|
if (params.dbSnapshotRef) {
|
|
7477
7523
|
rawTrace.db_snapshot_ref = params.dbSnapshotRef;
|
|
7478
7524
|
}
|