@bitfab/sdk 0.52.5 → 0.53.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/autoTrace.cjs +84 -34
- package/dist/autoTrace.cjs.map +1 -1
- package/dist/autoTrace.d.cts +19 -4
- package/dist/autoTrace.d.ts +19 -4
- package/dist/autoTrace.js +9 -3
- package/dist/{chunk-BEAGKWXY.js → chunk-3IKQHUGK.js} +160 -33
- package/dist/chunk-3IKQHUGK.js.map +1 -0
- package/dist/{chunk-VAIXHJ7O.js → chunk-E3O64PDG.js} +2 -2
- package/dist/{chunk-VAIXHJ7O.js.map → chunk-E3O64PDG.js.map} +1 -1
- package/dist/{chunk-ZUD7OFYB.js → chunk-E5BLYL5X.js} +81 -34
- package/dist/chunk-E5BLYL5X.js.map +1 -0
- package/dist/{chunk-THKLMOHS.js → chunk-KSKRPIY6.js} +2 -2
- package/dist/{chunk-ITIMJ24H.js → chunk-PAM7GY2V.js} +3 -3
- package/dist/{chunk-IHAB7SPF.js → chunk-WIBQUZPU.js} +2 -2
- package/dist/{chunk-IHAB7SPF.js.map → chunk-WIBQUZPU.js.map} +1 -1
- package/dist/{http-KZU56HZA.js → http-C4CWGASW.js} +2 -2
- package/dist/{http-6Y3IQQ2Z.js → http-NLURGVPA.js} +2 -2
- package/dist/index.cjs +206 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/node.cjs +206 -50
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +4 -4
- package/dist/{replay-LZ7DIY5L.js → replay-2Y3G4EB4.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-BEAGKWXY.js.map +0 -1
- package/dist/chunk-ZUD7OFYB.js.map +0 -1
- /package/dist/{chunk-THKLMOHS.js.map → chunk-KSKRPIY6.js.map} +0 -0
- /package/dist/{chunk-ITIMJ24H.js.map → chunk-PAM7GY2V.js.map} +0 -0
- /package/dist/{http-6Y3IQQ2Z.js.map → http-C4CWGASW.js.map} +0 -0
- /package/dist/{http-KZU56HZA.js.map → http-NLURGVPA.js.map} +0 -0
- /package/dist/{replay-LZ7DIY5L.js.map → replay-2Y3G4EB4.js.map} +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__bitfabAutoTraceActive,
|
|
3
3
|
__setBitfabAutoTraceCapturePolicy,
|
|
4
|
+
clearAutoTraceNodeConfiguration,
|
|
5
|
+
currentAutoTraceEntries,
|
|
4
6
|
getAutoTraceCapturePolicy,
|
|
5
|
-
|
|
7
|
+
invokeThroughAutoTraceEntries,
|
|
8
|
+
runWithAutoTraceEntry,
|
|
6
9
|
runWithAutoTraceNodeConfiguration,
|
|
7
10
|
runWithAutoTraceRootContext
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-E5BLYL5X.js";
|
|
9
12
|
import {
|
|
10
13
|
NO_MOCK_OVERRIDE,
|
|
11
14
|
deserializeInputs,
|
|
@@ -16,7 +19,7 @@ import {
|
|
|
16
19
|
serializeValue,
|
|
17
20
|
toJsonSafe,
|
|
18
21
|
toJsonSafeReport
|
|
19
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-KSKRPIY6.js";
|
|
20
23
|
import {
|
|
21
24
|
BitfabError,
|
|
22
25
|
DEFAULT_SERVICE_URL,
|
|
@@ -28,7 +31,7 @@ import {
|
|
|
28
31
|
recordCallerTraceMetadata,
|
|
29
32
|
retireTraceMetadata,
|
|
30
33
|
warnOnce
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-WIBQUZPU.js";
|
|
32
35
|
import {
|
|
33
36
|
__privateAdd,
|
|
34
37
|
__privateGet,
|
|
@@ -3174,6 +3177,26 @@ var DEFAULT_AUTO_TRACE_MAX_SPANS = 500;
|
|
|
3174
3177
|
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
3175
3178
|
var AUTO_TRACE_POLICY_REFRESH_MS = 6e4;
|
|
3176
3179
|
var AUTO_TRACE_POLICY_RETRY_MS = 1e4;
|
|
3180
|
+
function spanOwnerName(receiver) {
|
|
3181
|
+
if (typeof receiver === "function") {
|
|
3182
|
+
return receiver.name !== "" ? receiver.name : void 0;
|
|
3183
|
+
}
|
|
3184
|
+
if (typeof receiver !== "object" || receiver === null) {
|
|
3185
|
+
return void 0;
|
|
3186
|
+
}
|
|
3187
|
+
const owner = receiver.constructor;
|
|
3188
|
+
if (typeof owner !== "function" || owner === Object || owner.name === "") {
|
|
3189
|
+
return void 0;
|
|
3190
|
+
}
|
|
3191
|
+
return owner.name;
|
|
3192
|
+
}
|
|
3193
|
+
function qualifiedSpanName(receiver, functionName) {
|
|
3194
|
+
if (functionName === void 0) {
|
|
3195
|
+
return void 0;
|
|
3196
|
+
}
|
|
3197
|
+
const owner = spanOwnerName(receiver);
|
|
3198
|
+
return owner === void 0 ? functionName : `${owner}.${functionName}`;
|
|
3199
|
+
}
|
|
3177
3200
|
function autoTraceLimit(value, fallback) {
|
|
3178
3201
|
return value !== void 0 && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
|
|
3179
3202
|
}
|
|
@@ -3376,16 +3399,21 @@ var Bitfab = class {
|
|
|
3376
3399
|
);
|
|
3377
3400
|
const excluded = new Set(options.exclude ?? []);
|
|
3378
3401
|
const includeWrappers = options.includeWrappers ?? false;
|
|
3402
|
+
const rootNameFor = (receiver) => options.name ?? (fn.name !== "" ? qualifiedSpanName(receiver, name) ?? name : name);
|
|
3379
3403
|
const rootOptions = {
|
|
3380
|
-
name: options.name
|
|
3404
|
+
name: options.name,
|
|
3405
|
+
nameFor: rootNameFor,
|
|
3381
3406
|
type: options.type ?? "custom",
|
|
3382
3407
|
surface: "opt-out"
|
|
3383
3408
|
};
|
|
3384
|
-
const
|
|
3409
|
+
const buildTracedRoot = (spanOptions) => this.withSpan(
|
|
3385
3410
|
traceFunctionKey,
|
|
3386
|
-
|
|
3411
|
+
spanOptions,
|
|
3387
3412
|
function(...args) {
|
|
3388
|
-
const capturePolicy = getAutoTraceCapturePolicy(
|
|
3413
|
+
const capturePolicy = getAutoTraceCapturePolicy(
|
|
3414
|
+
self,
|
|
3415
|
+
traceFunctionKey
|
|
3416
|
+
);
|
|
3389
3417
|
self.refreshAutoTraceCapturePolicy(traceFunctionKey);
|
|
3390
3418
|
let spansUsed = 0;
|
|
3391
3419
|
let truncated = false;
|
|
@@ -3406,19 +3434,54 @@ var Bitfab = class {
|
|
|
3406
3434
|
`"${traceFunctionKey}" hit an automatic subtree capture limit (maxDepth=${maxDepth}, maxSpans=${maxSpans}); its trace is incomplete. Raise the limits or narrow the subtree with exclude.`
|
|
3407
3435
|
);
|
|
3408
3436
|
};
|
|
3437
|
+
const spanStackOf = (entry) => entry.spanStack;
|
|
3438
|
+
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
3439
|
+
const runInside = () => runWithAutoTraceEntry(
|
|
3440
|
+
entry,
|
|
3441
|
+
{
|
|
3442
|
+
context: autoTraceContext,
|
|
3443
|
+
depth: entry.depth + 1,
|
|
3444
|
+
spanStack: getSpanStack()
|
|
3445
|
+
},
|
|
3446
|
+
invokeFn
|
|
3447
|
+
);
|
|
3448
|
+
return runWithSpanStack(spanStackOf(entry), () => {
|
|
3449
|
+
if (isAsync) {
|
|
3450
|
+
const tracedAsyncChild = self.withSpan(
|
|
3451
|
+
traceFunctionKey,
|
|
3452
|
+
childOptions,
|
|
3453
|
+
async (..._inputs) => await runInside()
|
|
3454
|
+
);
|
|
3455
|
+
return tracedAsyncChild(...inputs);
|
|
3456
|
+
}
|
|
3457
|
+
const tracedChild = self.withSpan(
|
|
3458
|
+
traceFunctionKey,
|
|
3459
|
+
childOptions,
|
|
3460
|
+
(..._inputs) => runInside()
|
|
3461
|
+
);
|
|
3462
|
+
return tracedChild(...inputs);
|
|
3463
|
+
});
|
|
3464
|
+
};
|
|
3465
|
+
const overBudget = (entry) => {
|
|
3466
|
+
if (entry.depth < maxDepth && spansUsed < maxSpans) {
|
|
3467
|
+
return false;
|
|
3468
|
+
}
|
|
3469
|
+
runWithSpanStack(spanStackOf(entry), warnTruncated);
|
|
3470
|
+
return true;
|
|
3471
|
+
};
|
|
3409
3472
|
const autoTraceContext = {
|
|
3410
|
-
|
|
3473
|
+
traceFunctionKey,
|
|
3474
|
+
invoke(definition, inputs, invokeFn, entry, nodeConfiguration) {
|
|
3411
3475
|
const nameParts = definition.name.split(".");
|
|
3412
3476
|
const simpleName = nameParts[nameParts.length - 1];
|
|
3413
|
-
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() :
|
|
3477
|
+
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() : clearAutoTraceNodeConfiguration(invokeFn);
|
|
3414
3478
|
if (excluded.has(definition.name) || simpleName !== void 0 && excluded.has(simpleName) || nodeConfiguration === void 0 && definition.wrapper === true && !includeWrappers) {
|
|
3415
3479
|
return invokeWithoutNode();
|
|
3416
3480
|
}
|
|
3417
3481
|
if (nodeConfiguration?.capture === false) {
|
|
3418
|
-
return
|
|
3482
|
+
return clearAutoTraceNodeConfiguration(invokeFn);
|
|
3419
3483
|
}
|
|
3420
|
-
if (
|
|
3421
|
-
warnTruncated();
|
|
3484
|
+
if (overBudget(entry)) {
|
|
3422
3485
|
return invokeWithoutNode();
|
|
3423
3486
|
}
|
|
3424
3487
|
spansUsed += 1;
|
|
@@ -3441,34 +3504,82 @@ var Bitfab = class {
|
|
|
3441
3504
|
finalize: nodeConfiguration.finalize
|
|
3442
3505
|
}
|
|
3443
3506
|
};
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
const tracedAsyncChild = self.withSpan(
|
|
3447
|
-
traceFunctionKey,
|
|
3448
|
-
childOptions,
|
|
3449
|
-
async (..._inputs) => await invokeWithAutoTraceContext()
|
|
3450
|
-
);
|
|
3451
|
-
return tracedAsyncChild(...inputs);
|
|
3452
|
-
}
|
|
3453
|
-
const tracedChild = self.withSpan(
|
|
3454
|
-
traceFunctionKey,
|
|
3507
|
+
return openChild(
|
|
3508
|
+
entry,
|
|
3455
3509
|
childOptions,
|
|
3456
|
-
|
|
3510
|
+
inputs,
|
|
3511
|
+
definition.async === true,
|
|
3512
|
+
invokeFn
|
|
3457
3513
|
);
|
|
3458
|
-
|
|
3514
|
+
},
|
|
3515
|
+
invokeNestedRoot(nestedName, nestedFunctionName, inputs, invokeFn, entry, link) {
|
|
3516
|
+
if (excluded.has(nestedName) || excluded.has(nestedFunctionName) || overBudget(entry)) {
|
|
3517
|
+
return invokeFn();
|
|
3518
|
+
}
|
|
3519
|
+
spansUsed += 1;
|
|
3520
|
+
const childOptions = {
|
|
3521
|
+
name: nestedName,
|
|
3522
|
+
type: "function",
|
|
3523
|
+
captureWhen: "nested",
|
|
3524
|
+
surface: "opt-out",
|
|
3525
|
+
captureContent: true,
|
|
3526
|
+
...link !== void 0 && { nestedTrace: link }
|
|
3527
|
+
};
|
|
3528
|
+
return openChild(entry, childOptions, inputs, false, invokeFn);
|
|
3459
3529
|
}
|
|
3460
3530
|
};
|
|
3461
3531
|
return runWithAutoTraceRootContext(
|
|
3462
3532
|
autoTraceContext,
|
|
3533
|
+
getSpanStack(),
|
|
3463
3534
|
() => fn.apply(this, args)
|
|
3464
3535
|
);
|
|
3465
3536
|
}
|
|
3466
3537
|
);
|
|
3538
|
+
const tracedRoot = buildTracedRoot(rootOptions);
|
|
3467
3539
|
const autoTraceRoot = function(...args) {
|
|
3468
3540
|
if (!self.shouldRecord()) {
|
|
3469
3541
|
return fn.apply(this, args);
|
|
3470
3542
|
}
|
|
3471
|
-
|
|
3543
|
+
const enclosing = currentAutoTraceEntries();
|
|
3544
|
+
if (enclosing.length === 0) {
|
|
3545
|
+
return tracedRoot.apply(this, args);
|
|
3546
|
+
}
|
|
3547
|
+
const link = getReplayContext() || inSeedScope() ? void 0 : { traceFunctionKey };
|
|
3548
|
+
const rootName = rootNameFor(this);
|
|
3549
|
+
return invokeThroughAutoTraceEntries(
|
|
3550
|
+
enclosing,
|
|
3551
|
+
(entry, next) => entry.context.invokeNestedRoot(
|
|
3552
|
+
rootName,
|
|
3553
|
+
name,
|
|
3554
|
+
args,
|
|
3555
|
+
next,
|
|
3556
|
+
entry,
|
|
3557
|
+
link
|
|
3558
|
+
),
|
|
3559
|
+
() => {
|
|
3560
|
+
if (link === void 0) {
|
|
3561
|
+
return fn.apply(this, args);
|
|
3562
|
+
}
|
|
3563
|
+
const innermost = enclosing[enclosing.length - 1];
|
|
3564
|
+
const innermostNow = currentAutoTraceEntries().find(
|
|
3565
|
+
(entry) => entry.context === innermost.context
|
|
3566
|
+
) ?? innermost;
|
|
3567
|
+
const innermostStack = innermostNow.spanStack;
|
|
3568
|
+
const copy = innermostStack[innermostStack.length - 1];
|
|
3569
|
+
const detachedRoot = buildTracedRoot({
|
|
3570
|
+
...rootOptions,
|
|
3571
|
+
...copy !== void 0 && {
|
|
3572
|
+
enclosingTrace: {
|
|
3573
|
+
traceId: copy.traceId,
|
|
3574
|
+
spanId: copy.spanId,
|
|
3575
|
+
traceFunctionKey: innermost.context.traceFunctionKey,
|
|
3576
|
+
link
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
});
|
|
3580
|
+
return runWithSpanStack([], () => detachedRoot.apply(this, args));
|
|
3581
|
+
}
|
|
3582
|
+
);
|
|
3472
3583
|
};
|
|
3473
3584
|
Object.defineProperty(autoTraceRoot, "_bitfabTraceFunctionKey", {
|
|
3474
3585
|
value: traceFunctionKey
|
|
@@ -4057,6 +4168,10 @@ var Bitfab = class {
|
|
|
4057
4168
|
const spanId = randomUuid();
|
|
4058
4169
|
const parentSpanId = parentContext?.spanId ?? null;
|
|
4059
4170
|
const isRootSpan = parentSpanId === null;
|
|
4171
|
+
if (options.enclosingTrace !== void 0) {
|
|
4172
|
+
options.enclosingTrace.link.traceId = traceId;
|
|
4173
|
+
options.enclosingTrace.link.rootSpanId = spanId;
|
|
4174
|
+
}
|
|
4060
4175
|
const requestedSurface = options.surface ?? DEFAULT_SURFACE;
|
|
4061
4176
|
const surface = resolveSurface(requestedSurface, parentContext?.surface);
|
|
4062
4177
|
assertSurfacesCompatible(
|
|
@@ -4097,7 +4212,7 @@ var Bitfab = class {
|
|
|
4097
4212
|
const baseSpanParams = {
|
|
4098
4213
|
traceFunctionKey,
|
|
4099
4214
|
functionName,
|
|
4100
|
-
spanName: options.name ?? functionName ?? traceFunctionKey,
|
|
4215
|
+
spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionName) ?? traceFunctionKey,
|
|
4101
4216
|
traceId,
|
|
4102
4217
|
spanId,
|
|
4103
4218
|
parentSpanId,
|
|
@@ -4106,7 +4221,9 @@ var Bitfab = class {
|
|
|
4106
4221
|
spanType: options.type ?? "custom",
|
|
4107
4222
|
functionId: options.functionId,
|
|
4108
4223
|
captureContent: options.captureContent ?? true,
|
|
4109
|
-
autoTraceDefinition: options.autoTraceDefinition
|
|
4224
|
+
autoTraceDefinition: options.autoTraceDefinition,
|
|
4225
|
+
nestedTrace: options.nestedTrace,
|
|
4226
|
+
enclosingTrace: options.enclosingTrace
|
|
4110
4227
|
};
|
|
4111
4228
|
const sendSpan = async (params) => {
|
|
4112
4229
|
const replayCtx = getReplayContext();
|
|
@@ -4616,6 +4733,16 @@ var Bitfab = class {
|
|
|
4616
4733
|
function_line: params.autoTraceDefinition.line,
|
|
4617
4734
|
function_column: params.autoTraceDefinition.column
|
|
4618
4735
|
},
|
|
4736
|
+
...params.nestedTrace?.traceId !== void 0 && {
|
|
4737
|
+
nested_trace_id: params.nestedTrace.traceId,
|
|
4738
|
+
nested_trace_function_key: params.nestedTrace.traceFunctionKey,
|
|
4739
|
+
nested_root_span_id: params.nestedTrace.rootSpanId
|
|
4740
|
+
},
|
|
4741
|
+
...params.enclosingTrace !== void 0 && {
|
|
4742
|
+
enclosing_trace_id: params.enclosingTrace.traceId,
|
|
4743
|
+
enclosing_trace_function_key: params.enclosingTrace.traceFunctionKey,
|
|
4744
|
+
enclosing_span_id: params.enclosingTrace.spanId
|
|
4745
|
+
},
|
|
4619
4746
|
...serializedInputs !== void 0 && {
|
|
4620
4747
|
input: serializedInputs.json,
|
|
4621
4748
|
...serializedInputs.meta !== void 0 && {
|
|
@@ -4797,7 +4924,7 @@ var Bitfab = class {
|
|
|
4797
4924
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
4798
4925
|
} finally {
|
|
4799
4926
|
try {
|
|
4800
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
4927
|
+
const { flushTraces: flushTraces2 } = await import("./http-C4CWGASW.js");
|
|
4801
4928
|
await flushTraces2(3e4);
|
|
4802
4929
|
} finally {
|
|
4803
4930
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -4856,7 +4983,7 @@ var Bitfab = class {
|
|
|
4856
4983
|
`Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
|
|
4857
4984
|
);
|
|
4858
4985
|
}
|
|
4859
|
-
const { replay: doReplay } = await import("./replay-
|
|
4986
|
+
const { replay: doReplay } = await import("./replay-2Y3G4EB4.js");
|
|
4860
4987
|
return doReplay(
|
|
4861
4988
|
this.httpClient,
|
|
4862
4989
|
this.serviceUrl,
|
|
@@ -5140,7 +5267,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
5140
5267
|
sessionId: seedCase.sessionId
|
|
5141
5268
|
})
|
|
5142
5269
|
);
|
|
5143
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
5270
|
+
const { flushTraces: flushTraces2 } = await import("./http-C4CWGASW.js");
|
|
5144
5271
|
await flushTraces2(3e4);
|
|
5145
5272
|
return { pipeline, traceFunctionKey, traceIds };
|
|
5146
5273
|
}
|
|
@@ -5177,4 +5304,4 @@ export {
|
|
|
5177
5304
|
reseedFromRegistry,
|
|
5178
5305
|
seedFromRegistry
|
|
5179
5306
|
};
|
|
5180
|
-
//# sourceMappingURL=chunk-
|
|
5307
|
+
//# sourceMappingURL=chunk-3IKQHUGK.js.map
|