bitfab 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-CAE7HE4C.js → chunk-6IMGAODW.js} +2 -2
- package/dist/{chunk-CAE7HE4C.js.map → chunk-6IMGAODW.js.map} +1 -1
- package/dist/{chunk-3D7FNJ5R.js → chunk-CBRO6BP7.js} +2 -2
- package/dist/{chunk-3D7FNJ5R.js.map → chunk-CBRO6BP7.js.map} +1 -1
- package/dist/{chunk-3QXNM62Y.js → chunk-DTC6SIXW.js} +3 -3
- package/dist/{chunk-ZUD7OFYB.js → chunk-E5BLYL5X.js} +81 -34
- package/dist/chunk-E5BLYL5X.js.map +1 -0
- package/dist/{chunk-EMRHO6YW.js → chunk-SCXR43UF.js} +160 -33
- package/dist/chunk-SCXR43UF.js.map +1 -0
- package/dist/{chunk-6DRFQJ75.js → chunk-SJKWUQ3G.js} +2 -2
- package/dist/{http-UQT6QVBC.js → http-KP7DVTOD.js} +2 -2
- package/dist/{http-Q6UEKZRF.js → http-SEN3PUXX.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-UVSZFZW7.js → replay-Y5RIJOWE.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-DTC6SIXW.js.map} +0 -0
- /package/dist/{chunk-6DRFQJ75.js.map → chunk-SJKWUQ3G.js.map} +0 -0
- /package/dist/{http-Q6UEKZRF.js.map → http-KP7DVTOD.js.map} +0 -0
- /package/dist/{http-UQT6QVBC.js.map → http-SEN3PUXX.js.map} +0 -0
- /package/dist/{replay-UVSZFZW7.js.map → replay-Y5RIJOWE.js.map} +0 -0
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
getCurrentTrace,
|
|
29
29
|
reseedFromRegistry,
|
|
30
30
|
seedFromRegistry
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-SCXR43UF.js";
|
|
32
|
+
import "./chunk-E5BLYL5X.js";
|
|
33
33
|
import {
|
|
34
34
|
BITFAB_PROGRESS_PREFIX,
|
|
35
35
|
DbBranchReplayError,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
ReplayError,
|
|
38
38
|
reportReplayProgress,
|
|
39
39
|
serializeReplayResult
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-SJKWUQ3G.js";
|
|
41
41
|
import {
|
|
42
42
|
BitfabError,
|
|
43
43
|
DEFAULT_SERVICE_URL,
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
MixedTracingError,
|
|
46
46
|
__version__,
|
|
47
47
|
flushTraces
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-6IMGAODW.js";
|
|
49
49
|
import "./chunk-H6LZRFMN.js";
|
|
50
50
|
export {
|
|
51
51
|
BITFAB_PROGRESS_PREFIX,
|
package/dist/node.cjs
CHANGED
|
@@ -97,7 +97,7 @@ var __version__, __packageName__;
|
|
|
97
97
|
var init_version_generated = __esm({
|
|
98
98
|
"src/version.generated.ts"() {
|
|
99
99
|
"use strict";
|
|
100
|
-
__version__ = "0.
|
|
100
|
+
__version__ = "0.53.0";
|
|
101
101
|
__packageName__ = "bitfab";
|
|
102
102
|
}
|
|
103
103
|
});
|
|
@@ -4221,19 +4221,18 @@ init_asyncStorage();
|
|
|
4221
4221
|
// src/autoTrace.ts
|
|
4222
4222
|
init_asyncStorage();
|
|
4223
4223
|
var autoTraceGlobal = globalThis;
|
|
4224
|
-
var autoTraceState = autoTraceGlobal.
|
|
4224
|
+
var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
|
|
4225
4225
|
storage: null,
|
|
4226
4226
|
browserScope: void 0,
|
|
4227
4227
|
capturePolicies: /* @__PURE__ */ new WeakMap(),
|
|
4228
4228
|
activeRoots: 0
|
|
4229
4229
|
};
|
|
4230
|
-
autoTraceGlobal.
|
|
4230
|
+
autoTraceGlobal.__bitfabAutoTraceStateV4 = autoTraceState;
|
|
4231
4231
|
function initializeAutoTraceStorage() {
|
|
4232
4232
|
autoTraceState.storage ?? (autoTraceState.storage = createAsyncLocalStorage());
|
|
4233
4233
|
}
|
|
4234
|
-
function
|
|
4234
|
+
function runWithAutoTraceScope(scope, fn) {
|
|
4235
4235
|
initializeAutoTraceStorage();
|
|
4236
|
-
const scope = { context, depth };
|
|
4237
4236
|
if (autoTraceState.storage) {
|
|
4238
4237
|
return autoTraceState.storage.run(scope, fn);
|
|
4239
4238
|
}
|
|
@@ -4245,41 +4244,65 @@ function runWithAutoTraceContext(context, fn, depth = 0) {
|
|
|
4245
4244
|
autoTraceState.browserScope = previous;
|
|
4246
4245
|
}
|
|
4247
4246
|
}
|
|
4247
|
+
function currentAutoTraceEntries() {
|
|
4248
|
+
return currentAutoTraceScope()?.entries ?? [];
|
|
4249
|
+
}
|
|
4250
|
+
function replaceEntry(entries, previous, updated) {
|
|
4251
|
+
return entries.map((entry) => entry === previous ? updated : entry);
|
|
4252
|
+
}
|
|
4253
|
+
function runWithAutoTraceEntry(previous, updated, fn) {
|
|
4254
|
+
const result = runWithAutoTraceScope(
|
|
4255
|
+
{ entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
|
|
4256
|
+
fn
|
|
4257
|
+
);
|
|
4258
|
+
if (isAutoTraceAsyncGenerator(result)) {
|
|
4259
|
+
return wrapAutoTraceEntryAsyncGenerator(previous, updated, result);
|
|
4260
|
+
}
|
|
4261
|
+
return result;
|
|
4262
|
+
}
|
|
4263
|
+
function wrapAutoTraceEntryAsyncGenerator(previous, updated, source) {
|
|
4264
|
+
const step = (method, value) => runWithAutoTraceScope(
|
|
4265
|
+
{ entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
|
|
4266
|
+
() => source[method](value)
|
|
4267
|
+
);
|
|
4268
|
+
const wrapped = {
|
|
4269
|
+
next: (value) => step("next", value),
|
|
4270
|
+
return: (value) => step("return", value),
|
|
4271
|
+
throw: (error) => step("throw", error),
|
|
4272
|
+
[Symbol.asyncIterator]: () => wrapped
|
|
4273
|
+
};
|
|
4274
|
+
return wrapped;
|
|
4275
|
+
}
|
|
4276
|
+
function clearAutoTraceNodeConfiguration(fn) {
|
|
4277
|
+
return runWithAutoTraceScope({ entries: currentAutoTraceEntries() }, fn);
|
|
4278
|
+
}
|
|
4248
4279
|
function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
|
|
4249
4280
|
const scope = currentAutoTraceScope();
|
|
4250
|
-
if (!scope) {
|
|
4281
|
+
if (!scope || scope.entries.length === 0) {
|
|
4251
4282
|
return fn();
|
|
4252
4283
|
}
|
|
4253
|
-
const
|
|
4254
|
-
let result;
|
|
4255
|
-
if (autoTraceState.storage) {
|
|
4256
|
-
result = autoTraceState.storage.run(configuredScope, fn);
|
|
4257
|
-
} else {
|
|
4258
|
-
const previous = autoTraceState.browserScope;
|
|
4259
|
-
autoTraceState.browserScope = configuredScope;
|
|
4260
|
-
try {
|
|
4261
|
-
result = fn();
|
|
4262
|
-
} finally {
|
|
4263
|
-
autoTraceState.browserScope = previous;
|
|
4264
|
-
}
|
|
4265
|
-
}
|
|
4284
|
+
const result = runWithAutoTraceScope({ ...scope, nodeConfiguration }, fn);
|
|
4266
4285
|
if (isAutoTraceAsyncGenerator(result)) {
|
|
4267
4286
|
return wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, result);
|
|
4268
4287
|
}
|
|
4269
4288
|
return result;
|
|
4270
4289
|
}
|
|
4271
|
-
function runWithAutoTraceRootContext(context, fn) {
|
|
4290
|
+
function runWithAutoTraceRootContext(context, spanStack, fn) {
|
|
4272
4291
|
autoTraceState.activeRoots += 1;
|
|
4292
|
+
const entries = [
|
|
4293
|
+
...currentAutoTraceEntries(),
|
|
4294
|
+
{ context, depth: 0, spanStack }
|
|
4295
|
+
];
|
|
4273
4296
|
let result;
|
|
4274
4297
|
try {
|
|
4275
|
-
result =
|
|
4298
|
+
result = runWithAutoTraceScope({ entries }, fn);
|
|
4276
4299
|
} catch (error) {
|
|
4277
4300
|
autoTraceState.activeRoots -= 1;
|
|
4278
4301
|
throw error;
|
|
4279
4302
|
}
|
|
4280
4303
|
if (isAutoTraceAsyncGenerator(result)) {
|
|
4281
4304
|
autoTraceState.activeRoots -= 1;
|
|
4282
|
-
return wrapAutoTraceAsyncGenerator(context, result);
|
|
4305
|
+
return wrapAutoTraceAsyncGenerator(context, spanStack, result);
|
|
4283
4306
|
}
|
|
4284
4307
|
if (result instanceof Promise) {
|
|
4285
4308
|
return result.finally(() => {
|
|
@@ -4289,6 +4312,15 @@ function runWithAutoTraceRootContext(context, fn) {
|
|
|
4289
4312
|
autoTraceState.activeRoots -= 1;
|
|
4290
4313
|
return result;
|
|
4291
4314
|
}
|
|
4315
|
+
function invokeThroughAutoTraceEntries(entries, step, fn) {
|
|
4316
|
+
let run = fn;
|
|
4317
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
4318
|
+
const entry = entries[index];
|
|
4319
|
+
const next = run;
|
|
4320
|
+
run = () => step(entry, next);
|
|
4321
|
+
}
|
|
4322
|
+
return run();
|
|
4323
|
+
}
|
|
4292
4324
|
function isAutoTraceAsyncGenerator(value) {
|
|
4293
4325
|
if (value === null || typeof value !== "object") {
|
|
4294
4326
|
return false;
|
|
@@ -4296,8 +4328,8 @@ function isAutoTraceAsyncGenerator(value) {
|
|
|
4296
4328
|
const candidate = value;
|
|
4297
4329
|
return typeof candidate.next === "function" && typeof candidate.return === "function" && typeof candidate.throw === "function" && typeof candidate[Symbol.asyncIterator] === "function";
|
|
4298
4330
|
}
|
|
4299
|
-
function wrapAutoTraceAsyncGenerator(context, source) {
|
|
4300
|
-
const step = (method, value) => runWithAutoTraceRootContext(context, () => source[method](value));
|
|
4331
|
+
function wrapAutoTraceAsyncGenerator(context, spanStack, source) {
|
|
4332
|
+
const step = (method, value) => runWithAutoTraceRootContext(context, spanStack, () => source[method](value));
|
|
4301
4333
|
const wrapped = {
|
|
4302
4334
|
next: (value) => step("next", value),
|
|
4303
4335
|
return: (value) => step("return", value),
|
|
@@ -4323,7 +4355,7 @@ function __bitfabAutoTraceActive() {
|
|
|
4323
4355
|
if (autoTraceState.activeRoots === 0) {
|
|
4324
4356
|
return false;
|
|
4325
4357
|
}
|
|
4326
|
-
return
|
|
4358
|
+
return currentAutoTraceEntries().length > 0;
|
|
4327
4359
|
}
|
|
4328
4360
|
function currentAutoTraceScope() {
|
|
4329
4361
|
initializeAutoTraceStorage();
|
|
@@ -6869,6 +6901,26 @@ var DEFAULT_AUTO_TRACE_MAX_SPANS = 500;
|
|
|
6869
6901
|
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
6870
6902
|
var AUTO_TRACE_POLICY_REFRESH_MS = 6e4;
|
|
6871
6903
|
var AUTO_TRACE_POLICY_RETRY_MS = 1e4;
|
|
6904
|
+
function spanOwnerName(receiver) {
|
|
6905
|
+
if (typeof receiver === "function") {
|
|
6906
|
+
return receiver.name !== "" ? receiver.name : void 0;
|
|
6907
|
+
}
|
|
6908
|
+
if (typeof receiver !== "object" || receiver === null) {
|
|
6909
|
+
return void 0;
|
|
6910
|
+
}
|
|
6911
|
+
const owner = receiver.constructor;
|
|
6912
|
+
if (typeof owner !== "function" || owner === Object || owner.name === "") {
|
|
6913
|
+
return void 0;
|
|
6914
|
+
}
|
|
6915
|
+
return owner.name;
|
|
6916
|
+
}
|
|
6917
|
+
function qualifiedSpanName(receiver, functionName) {
|
|
6918
|
+
if (functionName === void 0) {
|
|
6919
|
+
return void 0;
|
|
6920
|
+
}
|
|
6921
|
+
const owner = spanOwnerName(receiver);
|
|
6922
|
+
return owner === void 0 ? functionName : `${owner}.${functionName}`;
|
|
6923
|
+
}
|
|
6872
6924
|
function autoTraceLimit(value, fallback) {
|
|
6873
6925
|
return value !== void 0 && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
|
|
6874
6926
|
}
|
|
@@ -7071,16 +7123,21 @@ var Bitfab = class {
|
|
|
7071
7123
|
);
|
|
7072
7124
|
const excluded = new Set(options.exclude ?? []);
|
|
7073
7125
|
const includeWrappers = options.includeWrappers ?? false;
|
|
7126
|
+
const rootNameFor = (receiver) => options.name ?? (fn.name !== "" ? qualifiedSpanName(receiver, name) ?? name : name);
|
|
7074
7127
|
const rootOptions = {
|
|
7075
|
-
name: options.name
|
|
7128
|
+
name: options.name,
|
|
7129
|
+
nameFor: rootNameFor,
|
|
7076
7130
|
type: options.type ?? "custom",
|
|
7077
7131
|
surface: "opt-out"
|
|
7078
7132
|
};
|
|
7079
|
-
const
|
|
7133
|
+
const buildTracedRoot = (spanOptions) => this.withSpan(
|
|
7080
7134
|
traceFunctionKey,
|
|
7081
|
-
|
|
7135
|
+
spanOptions,
|
|
7082
7136
|
function(...args) {
|
|
7083
|
-
const capturePolicy = getAutoTraceCapturePolicy(
|
|
7137
|
+
const capturePolicy = getAutoTraceCapturePolicy(
|
|
7138
|
+
self,
|
|
7139
|
+
traceFunctionKey
|
|
7140
|
+
);
|
|
7084
7141
|
self.refreshAutoTraceCapturePolicy(traceFunctionKey);
|
|
7085
7142
|
let spansUsed = 0;
|
|
7086
7143
|
let truncated = false;
|
|
@@ -7101,19 +7158,54 @@ var Bitfab = class {
|
|
|
7101
7158
|
`"${traceFunctionKey}" hit an automatic subtree capture limit (maxDepth=${maxDepth}, maxSpans=${maxSpans}); its trace is incomplete. Raise the limits or narrow the subtree with exclude.`
|
|
7102
7159
|
);
|
|
7103
7160
|
};
|
|
7161
|
+
const spanStackOf = (entry) => entry.spanStack;
|
|
7162
|
+
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
7163
|
+
const runInside = () => runWithAutoTraceEntry(
|
|
7164
|
+
entry,
|
|
7165
|
+
{
|
|
7166
|
+
context: autoTraceContext,
|
|
7167
|
+
depth: entry.depth + 1,
|
|
7168
|
+
spanStack: getSpanStack()
|
|
7169
|
+
},
|
|
7170
|
+
invokeFn
|
|
7171
|
+
);
|
|
7172
|
+
return runWithSpanStack(spanStackOf(entry), () => {
|
|
7173
|
+
if (isAsync) {
|
|
7174
|
+
const tracedAsyncChild = self.withSpan(
|
|
7175
|
+
traceFunctionKey,
|
|
7176
|
+
childOptions,
|
|
7177
|
+
async (..._inputs) => await runInside()
|
|
7178
|
+
);
|
|
7179
|
+
return tracedAsyncChild(...inputs);
|
|
7180
|
+
}
|
|
7181
|
+
const tracedChild = self.withSpan(
|
|
7182
|
+
traceFunctionKey,
|
|
7183
|
+
childOptions,
|
|
7184
|
+
(..._inputs) => runInside()
|
|
7185
|
+
);
|
|
7186
|
+
return tracedChild(...inputs);
|
|
7187
|
+
});
|
|
7188
|
+
};
|
|
7189
|
+
const overBudget = (entry) => {
|
|
7190
|
+
if (entry.depth < maxDepth && spansUsed < maxSpans) {
|
|
7191
|
+
return false;
|
|
7192
|
+
}
|
|
7193
|
+
runWithSpanStack(spanStackOf(entry), warnTruncated);
|
|
7194
|
+
return true;
|
|
7195
|
+
};
|
|
7104
7196
|
const autoTraceContext = {
|
|
7105
|
-
|
|
7197
|
+
traceFunctionKey,
|
|
7198
|
+
invoke(definition, inputs, invokeFn, entry, nodeConfiguration) {
|
|
7106
7199
|
const nameParts = definition.name.split(".");
|
|
7107
7200
|
const simpleName = nameParts[nameParts.length - 1];
|
|
7108
|
-
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() :
|
|
7201
|
+
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() : clearAutoTraceNodeConfiguration(invokeFn);
|
|
7109
7202
|
if (excluded.has(definition.name) || simpleName !== void 0 && excluded.has(simpleName) || nodeConfiguration === void 0 && definition.wrapper === true && !includeWrappers) {
|
|
7110
7203
|
return invokeWithoutNode();
|
|
7111
7204
|
}
|
|
7112
7205
|
if (nodeConfiguration?.capture === false) {
|
|
7113
|
-
return
|
|
7206
|
+
return clearAutoTraceNodeConfiguration(invokeFn);
|
|
7114
7207
|
}
|
|
7115
|
-
if (
|
|
7116
|
-
warnTruncated();
|
|
7208
|
+
if (overBudget(entry)) {
|
|
7117
7209
|
return invokeWithoutNode();
|
|
7118
7210
|
}
|
|
7119
7211
|
spansUsed += 1;
|
|
@@ -7136,34 +7228,82 @@ var Bitfab = class {
|
|
|
7136
7228
|
finalize: nodeConfiguration.finalize
|
|
7137
7229
|
}
|
|
7138
7230
|
};
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
const tracedAsyncChild = self.withSpan(
|
|
7142
|
-
traceFunctionKey,
|
|
7143
|
-
childOptions,
|
|
7144
|
-
async (..._inputs) => await invokeWithAutoTraceContext()
|
|
7145
|
-
);
|
|
7146
|
-
return tracedAsyncChild(...inputs);
|
|
7147
|
-
}
|
|
7148
|
-
const tracedChild = self.withSpan(
|
|
7149
|
-
traceFunctionKey,
|
|
7231
|
+
return openChild(
|
|
7232
|
+
entry,
|
|
7150
7233
|
childOptions,
|
|
7151
|
-
|
|
7234
|
+
inputs,
|
|
7235
|
+
definition.async === true,
|
|
7236
|
+
invokeFn
|
|
7152
7237
|
);
|
|
7153
|
-
|
|
7238
|
+
},
|
|
7239
|
+
invokeNestedRoot(nestedName, nestedFunctionName, inputs, invokeFn, entry, link) {
|
|
7240
|
+
if (excluded.has(nestedName) || excluded.has(nestedFunctionName) || overBudget(entry)) {
|
|
7241
|
+
return invokeFn();
|
|
7242
|
+
}
|
|
7243
|
+
spansUsed += 1;
|
|
7244
|
+
const childOptions = {
|
|
7245
|
+
name: nestedName,
|
|
7246
|
+
type: "function",
|
|
7247
|
+
captureWhen: "nested",
|
|
7248
|
+
surface: "opt-out",
|
|
7249
|
+
captureContent: true,
|
|
7250
|
+
...link !== void 0 && { nestedTrace: link }
|
|
7251
|
+
};
|
|
7252
|
+
return openChild(entry, childOptions, inputs, false, invokeFn);
|
|
7154
7253
|
}
|
|
7155
7254
|
};
|
|
7156
7255
|
return runWithAutoTraceRootContext(
|
|
7157
7256
|
autoTraceContext,
|
|
7257
|
+
getSpanStack(),
|
|
7158
7258
|
() => fn.apply(this, args)
|
|
7159
7259
|
);
|
|
7160
7260
|
}
|
|
7161
7261
|
);
|
|
7262
|
+
const tracedRoot = buildTracedRoot(rootOptions);
|
|
7162
7263
|
const autoTraceRoot = function(...args) {
|
|
7163
7264
|
if (!self.shouldRecord()) {
|
|
7164
7265
|
return fn.apply(this, args);
|
|
7165
7266
|
}
|
|
7166
|
-
|
|
7267
|
+
const enclosing = currentAutoTraceEntries();
|
|
7268
|
+
if (enclosing.length === 0) {
|
|
7269
|
+
return tracedRoot.apply(this, args);
|
|
7270
|
+
}
|
|
7271
|
+
const link = getReplayContext() || inSeedScope() ? void 0 : { traceFunctionKey };
|
|
7272
|
+
const rootName = rootNameFor(this);
|
|
7273
|
+
return invokeThroughAutoTraceEntries(
|
|
7274
|
+
enclosing,
|
|
7275
|
+
(entry, next) => entry.context.invokeNestedRoot(
|
|
7276
|
+
rootName,
|
|
7277
|
+
name,
|
|
7278
|
+
args,
|
|
7279
|
+
next,
|
|
7280
|
+
entry,
|
|
7281
|
+
link
|
|
7282
|
+
),
|
|
7283
|
+
() => {
|
|
7284
|
+
if (link === void 0) {
|
|
7285
|
+
return fn.apply(this, args);
|
|
7286
|
+
}
|
|
7287
|
+
const innermost = enclosing[enclosing.length - 1];
|
|
7288
|
+
const innermostNow = currentAutoTraceEntries().find(
|
|
7289
|
+
(entry) => entry.context === innermost.context
|
|
7290
|
+
) ?? innermost;
|
|
7291
|
+
const innermostStack = innermostNow.spanStack;
|
|
7292
|
+
const copy = innermostStack[innermostStack.length - 1];
|
|
7293
|
+
const detachedRoot = buildTracedRoot({
|
|
7294
|
+
...rootOptions,
|
|
7295
|
+
...copy !== void 0 && {
|
|
7296
|
+
enclosingTrace: {
|
|
7297
|
+
traceId: copy.traceId,
|
|
7298
|
+
spanId: copy.spanId,
|
|
7299
|
+
traceFunctionKey: innermost.context.traceFunctionKey,
|
|
7300
|
+
link
|
|
7301
|
+
}
|
|
7302
|
+
}
|
|
7303
|
+
});
|
|
7304
|
+
return runWithSpanStack([], () => detachedRoot.apply(this, args));
|
|
7305
|
+
}
|
|
7306
|
+
);
|
|
7167
7307
|
};
|
|
7168
7308
|
Object.defineProperty(autoTraceRoot, "_bitfabTraceFunctionKey", {
|
|
7169
7309
|
value: traceFunctionKey
|
|
@@ -7752,6 +7892,10 @@ var Bitfab = class {
|
|
|
7752
7892
|
const spanId = randomUuid();
|
|
7753
7893
|
const parentSpanId = parentContext?.spanId ?? null;
|
|
7754
7894
|
const isRootSpan = parentSpanId === null;
|
|
7895
|
+
if (options.enclosingTrace !== void 0) {
|
|
7896
|
+
options.enclosingTrace.link.traceId = traceId;
|
|
7897
|
+
options.enclosingTrace.link.rootSpanId = spanId;
|
|
7898
|
+
}
|
|
7755
7899
|
const requestedSurface = options.surface ?? DEFAULT_SURFACE;
|
|
7756
7900
|
const surface = resolveSurface(requestedSurface, parentContext?.surface);
|
|
7757
7901
|
assertSurfacesCompatible(
|
|
@@ -7792,7 +7936,7 @@ var Bitfab = class {
|
|
|
7792
7936
|
const baseSpanParams = {
|
|
7793
7937
|
traceFunctionKey,
|
|
7794
7938
|
functionName,
|
|
7795
|
-
spanName: options.name ?? functionName ?? traceFunctionKey,
|
|
7939
|
+
spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionName) ?? traceFunctionKey,
|
|
7796
7940
|
traceId,
|
|
7797
7941
|
spanId,
|
|
7798
7942
|
parentSpanId,
|
|
@@ -7801,7 +7945,9 @@ var Bitfab = class {
|
|
|
7801
7945
|
spanType: options.type ?? "custom",
|
|
7802
7946
|
functionId: options.functionId,
|
|
7803
7947
|
captureContent: options.captureContent ?? true,
|
|
7804
|
-
autoTraceDefinition: options.autoTraceDefinition
|
|
7948
|
+
autoTraceDefinition: options.autoTraceDefinition,
|
|
7949
|
+
nestedTrace: options.nestedTrace,
|
|
7950
|
+
enclosingTrace: options.enclosingTrace
|
|
7805
7951
|
};
|
|
7806
7952
|
const sendSpan = async (params) => {
|
|
7807
7953
|
const replayCtx = getReplayContext();
|
|
@@ -8311,6 +8457,16 @@ var Bitfab = class {
|
|
|
8311
8457
|
function_line: params.autoTraceDefinition.line,
|
|
8312
8458
|
function_column: params.autoTraceDefinition.column
|
|
8313
8459
|
},
|
|
8460
|
+
...params.nestedTrace?.traceId !== void 0 && {
|
|
8461
|
+
nested_trace_id: params.nestedTrace.traceId,
|
|
8462
|
+
nested_trace_function_key: params.nestedTrace.traceFunctionKey,
|
|
8463
|
+
nested_root_span_id: params.nestedTrace.rootSpanId
|
|
8464
|
+
},
|
|
8465
|
+
...params.enclosingTrace !== void 0 && {
|
|
8466
|
+
enclosing_trace_id: params.enclosingTrace.traceId,
|
|
8467
|
+
enclosing_trace_function_key: params.enclosingTrace.traceFunctionKey,
|
|
8468
|
+
enclosing_span_id: params.enclosingTrace.spanId
|
|
8469
|
+
},
|
|
8314
8470
|
...serializedInputs !== void 0 && {
|
|
8315
8471
|
input: serializedInputs.json,
|
|
8316
8472
|
...serializedInputs.meta !== void 0 && {
|