@bitfab/sdk 0.52.1 → 0.52.3
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-A5UGSRMK.js → chunk-45SK3FUL.js} +2 -7
- package/dist/chunk-45SK3FUL.js.map +1 -0
- package/dist/{chunk-6DIR65JW.js → chunk-ODF4JSYX.js} +67 -28
- package/dist/chunk-ODF4JSYX.js.map +1 -0
- package/dist/{chunk-UQLT25PG.js → chunk-QHA46TT6.js} +36 -21
- package/dist/chunk-QHA46TT6.js.map +1 -0
- package/dist/{chunk-XAT6WLCS.js → chunk-SECFVEQV.js} +11 -11
- package/dist/{chunk-XAT6WLCS.js.map → chunk-SECFVEQV.js.map} +1 -1
- package/dist/{http-B2AK43BN.js → http-3MPIPYKC.js} +2 -2
- package/dist/{http-RI4YCAS2.js → http-ZW5THLTW.js} +2 -2
- package/dist/index.cjs +70 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +3 -3
- package/dist/node.cjs +70 -36
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-24F3F5RD.js → replay-W5SAHEU5.js} +3 -3
- package/dist/replayCli.js +42 -12
- package/dist/replayCli.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6DIR65JW.js.map +0 -1
- package/dist/chunk-A5UGSRMK.js.map +0 -1
- package/dist/chunk-UQLT25PG.js.map +0 -1
- /package/dist/{http-B2AK43BN.js.map → http-3MPIPYKC.js.map} +0 -0
- /package/dist/{http-RI4YCAS2.js.map → http-ZW5THLTW.js.map} +0 -0
- /package/dist/{replay-24F3F5RD.js.map → replay-W5SAHEU5.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1656,12 +1656,16 @@ interface ReplayOptions {
|
|
|
1656
1656
|
* Maximum number of traces to replay (1-5,000, default 5). Ignored when
|
|
1657
1657
|
* `traceIds` is passed (with a warning), or when `datasetId` / `datasetIds`
|
|
1658
1658
|
* is passed, because either source already determines how many traces replay.
|
|
1659
|
+
* To replay part of a dataset selection, name the members to run in
|
|
1660
|
+
* `traceIds` rather than bounding it here.
|
|
1659
1661
|
*/
|
|
1660
1662
|
limit?: number;
|
|
1661
1663
|
attempts?: number;
|
|
1662
1664
|
/**
|
|
1663
|
-
* Optional list of specific trace IDs to replay (max 100).
|
|
1664
|
-
*
|
|
1665
|
+
* Optional list of specific trace IDs to replay (max 100). Passed alongside
|
|
1666
|
+
* `datasetId` or `datasetIds` it pins which members of that selection replay,
|
|
1667
|
+
* and the server rejects any ID none of those datasets contains. On its own
|
|
1668
|
+
* it selects by ID with no dataset attribution.
|
|
1665
1669
|
*/
|
|
1666
1670
|
traceIds?: string[];
|
|
1667
1671
|
/** Optional display name for the resulting experiment/test run. */
|
|
@@ -1719,8 +1723,9 @@ interface ReplayOptions {
|
|
|
1719
1723
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
1720
1724
|
experimentGroupId?: string;
|
|
1721
1725
|
/**
|
|
1722
|
-
* Dataset this replay runs against. Mutually exclusive with `
|
|
1723
|
-
*
|
|
1726
|
+
* Dataset this replay runs against. Mutually exclusive with `datasetIds`.
|
|
1727
|
+
* Alone it replays the dataset's full membership, and with `traceIds` it
|
|
1728
|
+
* replays only those members. When set, the resulting experiment is
|
|
1724
1729
|
* durably attributed to the dataset (stored on the test run), so it appears
|
|
1725
1730
|
* under the dataset's experiments even if the trace lineage can't be
|
|
1726
1731
|
* reconstructed. Validated server-side against the org.
|
|
@@ -3288,7 +3293,7 @@ declare class BitfabFunction {
|
|
|
3288
3293
|
/**
|
|
3289
3294
|
* SDK version from package.json (injected at build time)
|
|
3290
3295
|
*/
|
|
3291
|
-
declare const __version__ = "0.52.
|
|
3296
|
+
declare const __version__ = "0.52.3";
|
|
3292
3297
|
|
|
3293
3298
|
/**
|
|
3294
3299
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -1656,12 +1656,16 @@ interface ReplayOptions {
|
|
|
1656
1656
|
* Maximum number of traces to replay (1-5,000, default 5). Ignored when
|
|
1657
1657
|
* `traceIds` is passed (with a warning), or when `datasetId` / `datasetIds`
|
|
1658
1658
|
* is passed, because either source already determines how many traces replay.
|
|
1659
|
+
* To replay part of a dataset selection, name the members to run in
|
|
1660
|
+
* `traceIds` rather than bounding it here.
|
|
1659
1661
|
*/
|
|
1660
1662
|
limit?: number;
|
|
1661
1663
|
attempts?: number;
|
|
1662
1664
|
/**
|
|
1663
|
-
* Optional list of specific trace IDs to replay (max 100).
|
|
1664
|
-
*
|
|
1665
|
+
* Optional list of specific trace IDs to replay (max 100). Passed alongside
|
|
1666
|
+
* `datasetId` or `datasetIds` it pins which members of that selection replay,
|
|
1667
|
+
* and the server rejects any ID none of those datasets contains. On its own
|
|
1668
|
+
* it selects by ID with no dataset attribution.
|
|
1665
1669
|
*/
|
|
1666
1670
|
traceIds?: string[];
|
|
1667
1671
|
/** Optional display name for the resulting experiment/test run. */
|
|
@@ -1719,8 +1723,9 @@ interface ReplayOptions {
|
|
|
1719
1723
|
/** Group ID to associate this replay with an experiment group for live streaming in Studio. */
|
|
1720
1724
|
experimentGroupId?: string;
|
|
1721
1725
|
/**
|
|
1722
|
-
* Dataset this replay runs against. Mutually exclusive with `
|
|
1723
|
-
*
|
|
1726
|
+
* Dataset this replay runs against. Mutually exclusive with `datasetIds`.
|
|
1727
|
+
* Alone it replays the dataset's full membership, and with `traceIds` it
|
|
1728
|
+
* replays only those members. When set, the resulting experiment is
|
|
1724
1729
|
* durably attributed to the dataset (stored on the test run), so it appears
|
|
1725
1730
|
* under the dataset's experiments even if the trace lineage can't be
|
|
1726
1731
|
* reconstructed. Validated server-side against the org.
|
|
@@ -3288,7 +3293,7 @@ declare class BitfabFunction {
|
|
|
3288
3293
|
/**
|
|
3289
3294
|
* SDK version from package.json (injected at build time)
|
|
3290
3295
|
*/
|
|
3291
|
-
declare const __version__ = "0.52.
|
|
3296
|
+
declare const __version__ = "0.52.3";
|
|
3292
3297
|
|
|
3293
3298
|
/**
|
|
3294
3299
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
getCurrentSpan,
|
|
19
19
|
getCurrentTrace,
|
|
20
20
|
seedFromRegistry
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-SECFVEQV.js";
|
|
22
22
|
import "./chunk-ZUD7OFYB.js";
|
|
23
23
|
import {
|
|
24
24
|
BITFAB_PROGRESS_PREFIX,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
ReplayError,
|
|
28
28
|
reportReplayProgress,
|
|
29
29
|
serializeReplayResult
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-45SK3FUL.js";
|
|
31
31
|
import {
|
|
32
32
|
BitfabError,
|
|
33
33
|
DEFAULT_SERVICE_URL,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
MixedTracingError,
|
|
36
36
|
__version__,
|
|
37
37
|
flushTraces
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-ODF4JSYX.js";
|
|
39
39
|
import "./chunk-H6LZRFMN.js";
|
|
40
40
|
export {
|
|
41
41
|
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.52.
|
|
91
|
+
__version__ = "0.52.3";
|
|
92
92
|
__packageName__ = "@bitfab/sdk";
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -392,15 +392,18 @@ var init_payloadBudget = __esm({
|
|
|
392
392
|
});
|
|
393
393
|
|
|
394
394
|
// src/warnOnce.ts
|
|
395
|
+
function warn(message) {
|
|
396
|
+
try {
|
|
397
|
+
console.warn(`[bitfab] ${message}`);
|
|
398
|
+
} catch {
|
|
399
|
+
}
|
|
400
|
+
}
|
|
395
401
|
function warnOnce(key, message) {
|
|
396
402
|
if (warned.has(key)) {
|
|
397
403
|
return;
|
|
398
404
|
}
|
|
399
405
|
warned.add(key);
|
|
400
|
-
|
|
401
|
-
console.warn(`[bitfab] ${message}`);
|
|
402
|
-
} catch {
|
|
403
|
-
}
|
|
406
|
+
warn(message);
|
|
404
407
|
}
|
|
405
408
|
var warned;
|
|
406
409
|
var init_warnOnce = __esm({
|
|
@@ -542,6 +545,9 @@ var init_serializePayload = __esm({
|
|
|
542
545
|
});
|
|
543
546
|
|
|
544
547
|
// src/traceMetadata.ts
|
|
548
|
+
function findRecord(traceId) {
|
|
549
|
+
return activeRecords.get(traceId) ?? completedRecords.get(traceId);
|
|
550
|
+
}
|
|
545
551
|
function recordCallerTraceMetadata(traceId, metadata) {
|
|
546
552
|
if (typeof traceId !== "string" || traceId === "") {
|
|
547
553
|
return;
|
|
@@ -552,15 +558,52 @@ function recordCallerTraceMetadata(traceId, metadata) {
|
|
|
552
558
|
if (Object.keys(metadata).length === 0) {
|
|
553
559
|
return;
|
|
554
560
|
}
|
|
555
|
-
|
|
561
|
+
const existing = findRecord(traceId);
|
|
562
|
+
if (existing) {
|
|
563
|
+
Object.assign(existing.caller, metadata);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
activeRecords.set(traceId, {
|
|
567
|
+
caller: { ...metadata },
|
|
568
|
+
derived: {},
|
|
569
|
+
warnedKeys: /* @__PURE__ */ new Set()
|
|
570
|
+
});
|
|
556
571
|
}
|
|
557
572
|
function callerTraceMetadata(traceId) {
|
|
558
|
-
const
|
|
559
|
-
|
|
573
|
+
const record = findRecord(traceId);
|
|
574
|
+
if (!record || Object.keys(record.caller).length === 0) {
|
|
575
|
+
return void 0;
|
|
576
|
+
}
|
|
577
|
+
return { ...record.caller };
|
|
560
578
|
}
|
|
561
|
-
function
|
|
562
|
-
|
|
563
|
-
|
|
579
|
+
function retireTraceMetadata(traceId) {
|
|
580
|
+
const record = activeRecords.get(traceId);
|
|
581
|
+
if (!record) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
activeRecords.delete(traceId);
|
|
585
|
+
completedRecords.set(traceId, record);
|
|
586
|
+
while (completedRecords.size > RETAINED_COMPLETED_TRACES) {
|
|
587
|
+
const oldest = completedRecords.keys().next();
|
|
588
|
+
if (oldest.done) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
completedRecords.delete(oldest.value);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
function warnAboutShadowedKeys(traceId, record) {
|
|
595
|
+
const shadowed = Object.keys(record.derived).filter(
|
|
596
|
+
(key) => key in record.caller && record.caller[key] !== record.derived[key] && !record.warnedKeys.has(key)
|
|
597
|
+
).sort();
|
|
598
|
+
if (shadowed.length === 0) {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
for (const key of shadowed) {
|
|
602
|
+
record.warnedKeys.add(key);
|
|
603
|
+
}
|
|
604
|
+
warn(
|
|
605
|
+
`trace metadata key(s) ${shadowed.join(", ")} on trace ${traceId} were set both by the caller and by an integration's own trace export; the caller's value is the one kept on the trace.`
|
|
606
|
+
);
|
|
564
607
|
}
|
|
565
608
|
function mergeCallerMetadataIntoTracePayload(payload) {
|
|
566
609
|
const externalTrace = payload.externalTrace;
|
|
@@ -572,35 +615,31 @@ function mergeCallerMetadataIntoTracePayload(payload) {
|
|
|
572
615
|
if (typeof traceId !== "string" || traceId === "") {
|
|
573
616
|
return payload;
|
|
574
617
|
}
|
|
575
|
-
const
|
|
576
|
-
if (!caller) {
|
|
618
|
+
const record = findRecord(traceId);
|
|
619
|
+
if (!record || Object.keys(record.caller).length === 0) {
|
|
577
620
|
return payload;
|
|
578
621
|
}
|
|
579
|
-
const derived = derivedMetadata.get(traceId) ?? {};
|
|
580
622
|
const exported = external.metadata;
|
|
581
623
|
if (typeof exported === "object" && exported !== null) {
|
|
582
|
-
Object.assign(derived, exported);
|
|
583
|
-
}
|
|
584
|
-
derivedMetadata.set(traceId, derived);
|
|
585
|
-
const shadowed = Object.keys(derived).filter((key) => key in caller && caller[key] !== derived[key]).sort();
|
|
586
|
-
if (shadowed.length > 0) {
|
|
587
|
-
warnOnce(
|
|
588
|
-
`trace-metadata-shadowed:${shadowed.join(",")}`,
|
|
589
|
-
`trace metadata key(s) ${shadowed.join(", ")} were set both by the caller and by an integration's own trace export; the caller's value is the one kept on the trace.`
|
|
590
|
-
);
|
|
624
|
+
Object.assign(record.derived, exported);
|
|
591
625
|
}
|
|
626
|
+
warnAboutShadowedKeys(traceId, record);
|
|
592
627
|
return {
|
|
593
628
|
...payload,
|
|
594
|
-
externalTrace: {
|
|
629
|
+
externalTrace: {
|
|
630
|
+
...external,
|
|
631
|
+
metadata: { ...record.derived, ...record.caller }
|
|
632
|
+
}
|
|
595
633
|
};
|
|
596
634
|
}
|
|
597
|
-
var
|
|
635
|
+
var RETAINED_COMPLETED_TRACES, activeRecords, completedRecords;
|
|
598
636
|
var init_traceMetadata = __esm({
|
|
599
637
|
"src/traceMetadata.ts"() {
|
|
600
638
|
"use strict";
|
|
601
639
|
init_warnOnce();
|
|
602
|
-
|
|
603
|
-
|
|
640
|
+
RETAINED_COMPLETED_TRACES = 128;
|
|
641
|
+
activeRecords = /* @__PURE__ */ new Map();
|
|
642
|
+
completedRecords = /* @__PURE__ */ new Map();
|
|
604
643
|
}
|
|
605
644
|
});
|
|
606
645
|
|
|
@@ -3000,11 +3039,6 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
3000
3039
|
}
|
|
3001
3040
|
}
|
|
3002
3041
|
const datasetIds = resolveDatasetIds(options);
|
|
3003
|
-
if (options?.traceIds !== void 0 && datasetIds !== void 0) {
|
|
3004
|
-
throw new BitfabError(
|
|
3005
|
-
"traceIds and datasetIds select different replay sources and cannot be used together."
|
|
3006
|
-
);
|
|
3007
|
-
}
|
|
3008
3042
|
if (options?.limit !== void 0 && options?.traceIds !== void 0) {
|
|
3009
3043
|
try {
|
|
3010
3044
|
console.warn(
|
|
@@ -7477,7 +7511,7 @@ var Bitfab = class {
|
|
|
7477
7511
|
}
|
|
7478
7512
|
});
|
|
7479
7513
|
activeTraceStates.delete(traceId);
|
|
7480
|
-
|
|
7514
|
+
retireTraceMetadata(traceId);
|
|
7481
7515
|
}
|
|
7482
7516
|
} catch {
|
|
7483
7517
|
}
|
|
@@ -7670,7 +7704,7 @@ var Bitfab = class {
|
|
|
7670
7704
|
} catch (setupError) {
|
|
7671
7705
|
if (registeredTraceId) {
|
|
7672
7706
|
activeTraceStates.delete(registeredTraceId);
|
|
7673
|
-
|
|
7707
|
+
retireTraceMetadata(registeredTraceId);
|
|
7674
7708
|
}
|
|
7675
7709
|
if (setupError instanceof MixedTracingError) {
|
|
7676
7710
|
throw setupError;
|
|
@@ -8069,7 +8103,7 @@ var Bitfab = class {
|
|
|
8069
8103
|
});
|
|
8070
8104
|
} finally {
|
|
8071
8105
|
activeTraceStates.delete(traceId);
|
|
8072
|
-
|
|
8106
|
+
retireTraceMetadata(traceId);
|
|
8073
8107
|
}
|
|
8074
8108
|
return traceId;
|
|
8075
8109
|
}
|
|
@@ -8115,7 +8149,7 @@ var Bitfab = class {
|
|
|
8115
8149
|
await flushTraces2(3e4);
|
|
8116
8150
|
} finally {
|
|
8117
8151
|
unrecorded = activeTraceStates.delete(traceId);
|
|
8118
|
-
|
|
8152
|
+
retireTraceMetadata(traceId);
|
|
8119
8153
|
}
|
|
8120
8154
|
}
|
|
8121
8155
|
if (unrecorded) {
|