bitfab 0.52.5 → 0.52.6
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-3QXNM62Y.js → chunk-5KVK733P.js} +3 -3
- package/dist/{chunk-6DRFQJ75.js → chunk-DRTHTSHO.js} +2 -2
- package/dist/{chunk-ZUD7OFYB.js → chunk-E5BLYL5X.js} +81 -34
- package/dist/chunk-E5BLYL5X.js.map +1 -0
- package/dist/{chunk-3D7FNJ5R.js → chunk-GJKU7VWG.js} +2 -2
- package/dist/{chunk-3D7FNJ5R.js.map → chunk-GJKU7VWG.js.map} +1 -1
- package/dist/{chunk-CAE7HE4C.js → chunk-NXC6NYIY.js} +2 -2
- package/dist/{chunk-CAE7HE4C.js.map → chunk-NXC6NYIY.js.map} +1 -1
- package/dist/{chunk-EMRHO6YW.js → chunk-P26KVTI5.js} +136 -31
- package/dist/chunk-P26KVTI5.js.map +1 -0
- package/dist/{http-UQT6QVBC.js → http-ER2NMEKI.js} +2 -2
- package/dist/{http-Q6UEKZRF.js → http-MGES3ZVX.js} +2 -2
- package/dist/index.cjs +182 -48
- 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 +182 -48
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +4 -4
- package/dist/{replay-UVSZFZW7.js → replay-5XES2LBL.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-EMRHO6YW.js.map +0 -1
- package/dist/chunk-ZUD7OFYB.js.map +0 -1
- /package/dist/{chunk-3QXNM62Y.js.map → chunk-5KVK733P.js.map} +0 -0
- /package/dist/{chunk-6DRFQJ75.js.map → chunk-DRTHTSHO.js.map} +0 -0
- /package/dist/{http-Q6UEKZRF.js.map → http-ER2NMEKI.js.map} +0 -0
- /package/dist/{http-UQT6QVBC.js.map → http-MGES3ZVX.js.map} +0 -0
- /package/dist/{replay-UVSZFZW7.js.map → replay-5XES2LBL.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-DRTHTSHO.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-NXC6NYIY.js";
|
|
32
35
|
import {
|
|
33
36
|
__privateAdd,
|
|
34
37
|
__privateGet,
|
|
@@ -3381,11 +3384,15 @@ var Bitfab = class {
|
|
|
3381
3384
|
type: options.type ?? "custom",
|
|
3382
3385
|
surface: "opt-out"
|
|
3383
3386
|
};
|
|
3384
|
-
const
|
|
3387
|
+
const rootName = options.name ?? name;
|
|
3388
|
+
const buildTracedRoot = (spanOptions) => this.withSpan(
|
|
3385
3389
|
traceFunctionKey,
|
|
3386
|
-
|
|
3390
|
+
spanOptions,
|
|
3387
3391
|
function(...args) {
|
|
3388
|
-
const capturePolicy = getAutoTraceCapturePolicy(
|
|
3392
|
+
const capturePolicy = getAutoTraceCapturePolicy(
|
|
3393
|
+
self,
|
|
3394
|
+
traceFunctionKey
|
|
3395
|
+
);
|
|
3389
3396
|
self.refreshAutoTraceCapturePolicy(traceFunctionKey);
|
|
3390
3397
|
let spansUsed = 0;
|
|
3391
3398
|
let truncated = false;
|
|
@@ -3406,19 +3413,54 @@ var Bitfab = class {
|
|
|
3406
3413
|
`"${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
3414
|
);
|
|
3408
3415
|
};
|
|
3416
|
+
const spanStackOf = (entry) => entry.spanStack;
|
|
3417
|
+
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
3418
|
+
const runInside = () => runWithAutoTraceEntry(
|
|
3419
|
+
entry,
|
|
3420
|
+
{
|
|
3421
|
+
context: autoTraceContext,
|
|
3422
|
+
depth: entry.depth + 1,
|
|
3423
|
+
spanStack: getSpanStack()
|
|
3424
|
+
},
|
|
3425
|
+
invokeFn
|
|
3426
|
+
);
|
|
3427
|
+
return runWithSpanStack(spanStackOf(entry), () => {
|
|
3428
|
+
if (isAsync) {
|
|
3429
|
+
const tracedAsyncChild = self.withSpan(
|
|
3430
|
+
traceFunctionKey,
|
|
3431
|
+
childOptions,
|
|
3432
|
+
async (..._inputs) => await runInside()
|
|
3433
|
+
);
|
|
3434
|
+
return tracedAsyncChild(...inputs);
|
|
3435
|
+
}
|
|
3436
|
+
const tracedChild = self.withSpan(
|
|
3437
|
+
traceFunctionKey,
|
|
3438
|
+
childOptions,
|
|
3439
|
+
(..._inputs) => runInside()
|
|
3440
|
+
);
|
|
3441
|
+
return tracedChild(...inputs);
|
|
3442
|
+
});
|
|
3443
|
+
};
|
|
3444
|
+
const overBudget = (entry) => {
|
|
3445
|
+
if (entry.depth < maxDepth && spansUsed < maxSpans) {
|
|
3446
|
+
return false;
|
|
3447
|
+
}
|
|
3448
|
+
runWithSpanStack(spanStackOf(entry), warnTruncated);
|
|
3449
|
+
return true;
|
|
3450
|
+
};
|
|
3409
3451
|
const autoTraceContext = {
|
|
3410
|
-
|
|
3452
|
+
traceFunctionKey,
|
|
3453
|
+
invoke(definition, inputs, invokeFn, entry, nodeConfiguration) {
|
|
3411
3454
|
const nameParts = definition.name.split(".");
|
|
3412
3455
|
const simpleName = nameParts[nameParts.length - 1];
|
|
3413
|
-
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() :
|
|
3456
|
+
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() : clearAutoTraceNodeConfiguration(invokeFn);
|
|
3414
3457
|
if (excluded.has(definition.name) || simpleName !== void 0 && excluded.has(simpleName) || nodeConfiguration === void 0 && definition.wrapper === true && !includeWrappers) {
|
|
3415
3458
|
return invokeWithoutNode();
|
|
3416
3459
|
}
|
|
3417
3460
|
if (nodeConfiguration?.capture === false) {
|
|
3418
|
-
return
|
|
3461
|
+
return clearAutoTraceNodeConfiguration(invokeFn);
|
|
3419
3462
|
}
|
|
3420
|
-
if (
|
|
3421
|
-
warnTruncated();
|
|
3463
|
+
if (overBudget(entry)) {
|
|
3422
3464
|
return invokeWithoutNode();
|
|
3423
3465
|
}
|
|
3424
3466
|
spansUsed += 1;
|
|
@@ -3441,34 +3483,81 @@ var Bitfab = class {
|
|
|
3441
3483
|
finalize: nodeConfiguration.finalize
|
|
3442
3484
|
}
|
|
3443
3485
|
};
|
|
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,
|
|
3486
|
+
return openChild(
|
|
3487
|
+
entry,
|
|
3455
3488
|
childOptions,
|
|
3456
|
-
|
|
3489
|
+
inputs,
|
|
3490
|
+
definition.async === true,
|
|
3491
|
+
invokeFn
|
|
3457
3492
|
);
|
|
3458
|
-
|
|
3493
|
+
},
|
|
3494
|
+
invokeNestedRoot(nestedName, nestedFunctionName, inputs, invokeFn, entry, link) {
|
|
3495
|
+
if (excluded.has(nestedName) || excluded.has(nestedFunctionName) || overBudget(entry)) {
|
|
3496
|
+
return invokeFn();
|
|
3497
|
+
}
|
|
3498
|
+
spansUsed += 1;
|
|
3499
|
+
const childOptions = {
|
|
3500
|
+
name: nestedName,
|
|
3501
|
+
type: "function",
|
|
3502
|
+
captureWhen: "nested",
|
|
3503
|
+
surface: "opt-out",
|
|
3504
|
+
captureContent: true,
|
|
3505
|
+
...link !== void 0 && { nestedTrace: link }
|
|
3506
|
+
};
|
|
3507
|
+
return openChild(entry, childOptions, inputs, false, invokeFn);
|
|
3459
3508
|
}
|
|
3460
3509
|
};
|
|
3461
3510
|
return runWithAutoTraceRootContext(
|
|
3462
3511
|
autoTraceContext,
|
|
3512
|
+
getSpanStack(),
|
|
3463
3513
|
() => fn.apply(this, args)
|
|
3464
3514
|
);
|
|
3465
3515
|
}
|
|
3466
3516
|
);
|
|
3517
|
+
const tracedRoot = buildTracedRoot(rootOptions);
|
|
3467
3518
|
const autoTraceRoot = function(...args) {
|
|
3468
3519
|
if (!self.shouldRecord()) {
|
|
3469
3520
|
return fn.apply(this, args);
|
|
3470
3521
|
}
|
|
3471
|
-
|
|
3522
|
+
const enclosing = currentAutoTraceEntries();
|
|
3523
|
+
if (enclosing.length === 0) {
|
|
3524
|
+
return tracedRoot.apply(this, args);
|
|
3525
|
+
}
|
|
3526
|
+
const link = getReplayContext() || inSeedScope() ? void 0 : { traceFunctionKey };
|
|
3527
|
+
return invokeThroughAutoTraceEntries(
|
|
3528
|
+
enclosing,
|
|
3529
|
+
(entry, next) => entry.context.invokeNestedRoot(
|
|
3530
|
+
rootName,
|
|
3531
|
+
name,
|
|
3532
|
+
args,
|
|
3533
|
+
next,
|
|
3534
|
+
entry,
|
|
3535
|
+
link
|
|
3536
|
+
),
|
|
3537
|
+
() => {
|
|
3538
|
+
if (link === void 0) {
|
|
3539
|
+
return fn.apply(this, args);
|
|
3540
|
+
}
|
|
3541
|
+
const innermost = enclosing[enclosing.length - 1];
|
|
3542
|
+
const innermostNow = currentAutoTraceEntries().find(
|
|
3543
|
+
(entry) => entry.context === innermost.context
|
|
3544
|
+
) ?? innermost;
|
|
3545
|
+
const innermostStack = innermostNow.spanStack;
|
|
3546
|
+
const copy = innermostStack[innermostStack.length - 1];
|
|
3547
|
+
const detachedRoot = buildTracedRoot({
|
|
3548
|
+
...rootOptions,
|
|
3549
|
+
...copy !== void 0 && {
|
|
3550
|
+
enclosingTrace: {
|
|
3551
|
+
traceId: copy.traceId,
|
|
3552
|
+
spanId: copy.spanId,
|
|
3553
|
+
traceFunctionKey: innermost.context.traceFunctionKey,
|
|
3554
|
+
link
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
});
|
|
3558
|
+
return runWithSpanStack([], () => detachedRoot.apply(this, args));
|
|
3559
|
+
}
|
|
3560
|
+
);
|
|
3472
3561
|
};
|
|
3473
3562
|
Object.defineProperty(autoTraceRoot, "_bitfabTraceFunctionKey", {
|
|
3474
3563
|
value: traceFunctionKey
|
|
@@ -4057,6 +4146,10 @@ var Bitfab = class {
|
|
|
4057
4146
|
const spanId = randomUuid();
|
|
4058
4147
|
const parentSpanId = parentContext?.spanId ?? null;
|
|
4059
4148
|
const isRootSpan = parentSpanId === null;
|
|
4149
|
+
if (options.enclosingTrace !== void 0) {
|
|
4150
|
+
options.enclosingTrace.link.traceId = traceId;
|
|
4151
|
+
options.enclosingTrace.link.rootSpanId = spanId;
|
|
4152
|
+
}
|
|
4060
4153
|
const requestedSurface = options.surface ?? DEFAULT_SURFACE;
|
|
4061
4154
|
const surface = resolveSurface(requestedSurface, parentContext?.surface);
|
|
4062
4155
|
assertSurfacesCompatible(
|
|
@@ -4106,7 +4199,9 @@ var Bitfab = class {
|
|
|
4106
4199
|
spanType: options.type ?? "custom",
|
|
4107
4200
|
functionId: options.functionId,
|
|
4108
4201
|
captureContent: options.captureContent ?? true,
|
|
4109
|
-
autoTraceDefinition: options.autoTraceDefinition
|
|
4202
|
+
autoTraceDefinition: options.autoTraceDefinition,
|
|
4203
|
+
nestedTrace: options.nestedTrace,
|
|
4204
|
+
enclosingTrace: options.enclosingTrace
|
|
4110
4205
|
};
|
|
4111
4206
|
const sendSpan = async (params) => {
|
|
4112
4207
|
const replayCtx = getReplayContext();
|
|
@@ -4616,6 +4711,16 @@ var Bitfab = class {
|
|
|
4616
4711
|
function_line: params.autoTraceDefinition.line,
|
|
4617
4712
|
function_column: params.autoTraceDefinition.column
|
|
4618
4713
|
},
|
|
4714
|
+
...params.nestedTrace?.traceId !== void 0 && {
|
|
4715
|
+
nested_trace_id: params.nestedTrace.traceId,
|
|
4716
|
+
nested_trace_function_key: params.nestedTrace.traceFunctionKey,
|
|
4717
|
+
nested_root_span_id: params.nestedTrace.rootSpanId
|
|
4718
|
+
},
|
|
4719
|
+
...params.enclosingTrace !== void 0 && {
|
|
4720
|
+
enclosing_trace_id: params.enclosingTrace.traceId,
|
|
4721
|
+
enclosing_trace_function_key: params.enclosingTrace.traceFunctionKey,
|
|
4722
|
+
enclosing_span_id: params.enclosingTrace.spanId
|
|
4723
|
+
},
|
|
4619
4724
|
...serializedInputs !== void 0 && {
|
|
4620
4725
|
input: serializedInputs.json,
|
|
4621
4726
|
...serializedInputs.meta !== void 0 && {
|
|
@@ -4797,7 +4902,7 @@ var Bitfab = class {
|
|
|
4797
4902
|
await runWithSeedContext({ traceId }, async () => target(...args));
|
|
4798
4903
|
} finally {
|
|
4799
4904
|
try {
|
|
4800
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
4905
|
+
const { flushTraces: flushTraces2 } = await import("./http-MGES3ZVX.js");
|
|
4801
4906
|
await flushTraces2(3e4);
|
|
4802
4907
|
} finally {
|
|
4803
4908
|
unrecorded = activeTraceStates.delete(traceId);
|
|
@@ -4856,7 +4961,7 @@ var Bitfab = class {
|
|
|
4856
4961
|
`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
4962
|
);
|
|
4858
4963
|
}
|
|
4859
|
-
const { replay: doReplay } = await import("./replay-
|
|
4964
|
+
const { replay: doReplay } = await import("./replay-5XES2LBL.js");
|
|
4860
4965
|
return doReplay(
|
|
4861
4966
|
this.httpClient,
|
|
4862
4967
|
this.serviceUrl,
|
|
@@ -5140,7 +5245,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
5140
5245
|
sessionId: seedCase.sessionId
|
|
5141
5246
|
})
|
|
5142
5247
|
);
|
|
5143
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
5248
|
+
const { flushTraces: flushTraces2 } = await import("./http-MGES3ZVX.js");
|
|
5144
5249
|
await flushTraces2(3e4);
|
|
5145
5250
|
return { pipeline, traceFunctionKey, traceIds };
|
|
5146
5251
|
}
|
|
@@ -5177,4 +5282,4 @@ export {
|
|
|
5177
5282
|
reseedFromRegistry,
|
|
5178
5283
|
seedFromRegistry
|
|
5179
5284
|
};
|
|
5180
|
-
//# sourceMappingURL=chunk-
|
|
5285
|
+
//# sourceMappingURL=chunk-P26KVTI5.js.map
|