@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
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WIBQUZPU.js";
|
|
10
10
|
import "./chunk-H6LZRFMN.js";
|
|
11
11
|
export {
|
|
12
12
|
BitfabError,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
parseRetryAfterMs,
|
|
18
18
|
serializePayloadBody
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=http-
|
|
20
|
+
//# sourceMappingURL=http-C4CWGASW.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-E3O64PDG.js";
|
|
10
10
|
export {
|
|
11
11
|
BitfabError,
|
|
12
12
|
HttpClient,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
parseRetryAfterMs,
|
|
17
17
|
serializePayloadBody
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=http-
|
|
19
|
+
//# sourceMappingURL=http-NLURGVPA.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var __version__, __packageName__;
|
|
|
42
42
|
var init_version_generated = __esm({
|
|
43
43
|
"src/version.generated.ts"() {
|
|
44
44
|
"use strict";
|
|
45
|
-
__version__ = "0.
|
|
45
|
+
__version__ = "0.53.0";
|
|
46
46
|
__packageName__ = "@bitfab/sdk";
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -4198,19 +4198,18 @@ init_asyncStorage();
|
|
|
4198
4198
|
// src/autoTrace.ts
|
|
4199
4199
|
init_asyncStorage();
|
|
4200
4200
|
var autoTraceGlobal = globalThis;
|
|
4201
|
-
var autoTraceState = autoTraceGlobal.
|
|
4201
|
+
var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
|
|
4202
4202
|
storage: null,
|
|
4203
4203
|
browserScope: void 0,
|
|
4204
4204
|
capturePolicies: /* @__PURE__ */ new WeakMap(),
|
|
4205
4205
|
activeRoots: 0
|
|
4206
4206
|
};
|
|
4207
|
-
autoTraceGlobal.
|
|
4207
|
+
autoTraceGlobal.__bitfabAutoTraceStateV4 = autoTraceState;
|
|
4208
4208
|
function initializeAutoTraceStorage() {
|
|
4209
4209
|
autoTraceState.storage ?? (autoTraceState.storage = createAsyncLocalStorage());
|
|
4210
4210
|
}
|
|
4211
|
-
function
|
|
4211
|
+
function runWithAutoTraceScope(scope, fn) {
|
|
4212
4212
|
initializeAutoTraceStorage();
|
|
4213
|
-
const scope = { context, depth };
|
|
4214
4213
|
if (autoTraceState.storage) {
|
|
4215
4214
|
return autoTraceState.storage.run(scope, fn);
|
|
4216
4215
|
}
|
|
@@ -4222,41 +4221,65 @@ function runWithAutoTraceContext(context, fn, depth = 0) {
|
|
|
4222
4221
|
autoTraceState.browserScope = previous;
|
|
4223
4222
|
}
|
|
4224
4223
|
}
|
|
4224
|
+
function currentAutoTraceEntries() {
|
|
4225
|
+
return currentAutoTraceScope()?.entries ?? [];
|
|
4226
|
+
}
|
|
4227
|
+
function replaceEntry(entries, previous, updated) {
|
|
4228
|
+
return entries.map((entry) => entry === previous ? updated : entry);
|
|
4229
|
+
}
|
|
4230
|
+
function runWithAutoTraceEntry(previous, updated, fn) {
|
|
4231
|
+
const result = runWithAutoTraceScope(
|
|
4232
|
+
{ entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
|
|
4233
|
+
fn
|
|
4234
|
+
);
|
|
4235
|
+
if (isAutoTraceAsyncGenerator(result)) {
|
|
4236
|
+
return wrapAutoTraceEntryAsyncGenerator(previous, updated, result);
|
|
4237
|
+
}
|
|
4238
|
+
return result;
|
|
4239
|
+
}
|
|
4240
|
+
function wrapAutoTraceEntryAsyncGenerator(previous, updated, source) {
|
|
4241
|
+
const step = (method, value) => runWithAutoTraceScope(
|
|
4242
|
+
{ entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
|
|
4243
|
+
() => source[method](value)
|
|
4244
|
+
);
|
|
4245
|
+
const wrapped = {
|
|
4246
|
+
next: (value) => step("next", value),
|
|
4247
|
+
return: (value) => step("return", value),
|
|
4248
|
+
throw: (error) => step("throw", error),
|
|
4249
|
+
[Symbol.asyncIterator]: () => wrapped
|
|
4250
|
+
};
|
|
4251
|
+
return wrapped;
|
|
4252
|
+
}
|
|
4253
|
+
function clearAutoTraceNodeConfiguration(fn) {
|
|
4254
|
+
return runWithAutoTraceScope({ entries: currentAutoTraceEntries() }, fn);
|
|
4255
|
+
}
|
|
4225
4256
|
function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
|
|
4226
4257
|
const scope = currentAutoTraceScope();
|
|
4227
|
-
if (!scope) {
|
|
4258
|
+
if (!scope || scope.entries.length === 0) {
|
|
4228
4259
|
return fn();
|
|
4229
4260
|
}
|
|
4230
|
-
const
|
|
4231
|
-
let result;
|
|
4232
|
-
if (autoTraceState.storage) {
|
|
4233
|
-
result = autoTraceState.storage.run(configuredScope, fn);
|
|
4234
|
-
} else {
|
|
4235
|
-
const previous = autoTraceState.browserScope;
|
|
4236
|
-
autoTraceState.browserScope = configuredScope;
|
|
4237
|
-
try {
|
|
4238
|
-
result = fn();
|
|
4239
|
-
} finally {
|
|
4240
|
-
autoTraceState.browserScope = previous;
|
|
4241
|
-
}
|
|
4242
|
-
}
|
|
4261
|
+
const result = runWithAutoTraceScope({ ...scope, nodeConfiguration }, fn);
|
|
4243
4262
|
if (isAutoTraceAsyncGenerator(result)) {
|
|
4244
4263
|
return wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, result);
|
|
4245
4264
|
}
|
|
4246
4265
|
return result;
|
|
4247
4266
|
}
|
|
4248
|
-
function runWithAutoTraceRootContext(context, fn) {
|
|
4267
|
+
function runWithAutoTraceRootContext(context, spanStack, fn) {
|
|
4249
4268
|
autoTraceState.activeRoots += 1;
|
|
4269
|
+
const entries = [
|
|
4270
|
+
...currentAutoTraceEntries(),
|
|
4271
|
+
{ context, depth: 0, spanStack }
|
|
4272
|
+
];
|
|
4250
4273
|
let result;
|
|
4251
4274
|
try {
|
|
4252
|
-
result =
|
|
4275
|
+
result = runWithAutoTraceScope({ entries }, fn);
|
|
4253
4276
|
} catch (error) {
|
|
4254
4277
|
autoTraceState.activeRoots -= 1;
|
|
4255
4278
|
throw error;
|
|
4256
4279
|
}
|
|
4257
4280
|
if (isAutoTraceAsyncGenerator(result)) {
|
|
4258
4281
|
autoTraceState.activeRoots -= 1;
|
|
4259
|
-
return wrapAutoTraceAsyncGenerator(context, result);
|
|
4282
|
+
return wrapAutoTraceAsyncGenerator(context, spanStack, result);
|
|
4260
4283
|
}
|
|
4261
4284
|
if (result instanceof Promise) {
|
|
4262
4285
|
return result.finally(() => {
|
|
@@ -4266,6 +4289,15 @@ function runWithAutoTraceRootContext(context, fn) {
|
|
|
4266
4289
|
autoTraceState.activeRoots -= 1;
|
|
4267
4290
|
return result;
|
|
4268
4291
|
}
|
|
4292
|
+
function invokeThroughAutoTraceEntries(entries, step, fn) {
|
|
4293
|
+
let run = fn;
|
|
4294
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
4295
|
+
const entry = entries[index];
|
|
4296
|
+
const next = run;
|
|
4297
|
+
run = () => step(entry, next);
|
|
4298
|
+
}
|
|
4299
|
+
return run();
|
|
4300
|
+
}
|
|
4269
4301
|
function isAutoTraceAsyncGenerator(value) {
|
|
4270
4302
|
if (value === null || typeof value !== "object") {
|
|
4271
4303
|
return false;
|
|
@@ -4273,8 +4305,8 @@ function isAutoTraceAsyncGenerator(value) {
|
|
|
4273
4305
|
const candidate = value;
|
|
4274
4306
|
return typeof candidate.next === "function" && typeof candidate.return === "function" && typeof candidate.throw === "function" && typeof candidate[Symbol.asyncIterator] === "function";
|
|
4275
4307
|
}
|
|
4276
|
-
function wrapAutoTraceAsyncGenerator(context, source) {
|
|
4277
|
-
const step = (method, value) => runWithAutoTraceRootContext(context, () => source[method](value));
|
|
4308
|
+
function wrapAutoTraceAsyncGenerator(context, spanStack, source) {
|
|
4309
|
+
const step = (method, value) => runWithAutoTraceRootContext(context, spanStack, () => source[method](value));
|
|
4278
4310
|
const wrapped = {
|
|
4279
4311
|
next: (value) => step("next", value),
|
|
4280
4312
|
return: (value) => step("return", value),
|
|
@@ -4300,7 +4332,7 @@ function __bitfabAutoTraceActive() {
|
|
|
4300
4332
|
if (autoTraceState.activeRoots === 0) {
|
|
4301
4333
|
return false;
|
|
4302
4334
|
}
|
|
4303
|
-
return
|
|
4335
|
+
return currentAutoTraceEntries().length > 0;
|
|
4304
4336
|
}
|
|
4305
4337
|
function currentAutoTraceScope() {
|
|
4306
4338
|
initializeAutoTraceStorage();
|
|
@@ -6846,6 +6878,26 @@ var DEFAULT_AUTO_TRACE_MAX_SPANS = 500;
|
|
|
6846
6878
|
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
6847
6879
|
var AUTO_TRACE_POLICY_REFRESH_MS = 6e4;
|
|
6848
6880
|
var AUTO_TRACE_POLICY_RETRY_MS = 1e4;
|
|
6881
|
+
function spanOwnerName(receiver) {
|
|
6882
|
+
if (typeof receiver === "function") {
|
|
6883
|
+
return receiver.name !== "" ? receiver.name : void 0;
|
|
6884
|
+
}
|
|
6885
|
+
if (typeof receiver !== "object" || receiver === null) {
|
|
6886
|
+
return void 0;
|
|
6887
|
+
}
|
|
6888
|
+
const owner = receiver.constructor;
|
|
6889
|
+
if (typeof owner !== "function" || owner === Object || owner.name === "") {
|
|
6890
|
+
return void 0;
|
|
6891
|
+
}
|
|
6892
|
+
return owner.name;
|
|
6893
|
+
}
|
|
6894
|
+
function qualifiedSpanName(receiver, functionName) {
|
|
6895
|
+
if (functionName === void 0) {
|
|
6896
|
+
return void 0;
|
|
6897
|
+
}
|
|
6898
|
+
const owner = spanOwnerName(receiver);
|
|
6899
|
+
return owner === void 0 ? functionName : `${owner}.${functionName}`;
|
|
6900
|
+
}
|
|
6849
6901
|
function autoTraceLimit(value, fallback) {
|
|
6850
6902
|
return value !== void 0 && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
|
|
6851
6903
|
}
|
|
@@ -7048,16 +7100,21 @@ var Bitfab = class {
|
|
|
7048
7100
|
);
|
|
7049
7101
|
const excluded = new Set(options.exclude ?? []);
|
|
7050
7102
|
const includeWrappers = options.includeWrappers ?? false;
|
|
7103
|
+
const rootNameFor = (receiver) => options.name ?? (fn.name !== "" ? qualifiedSpanName(receiver, name) ?? name : name);
|
|
7051
7104
|
const rootOptions = {
|
|
7052
|
-
name: options.name
|
|
7105
|
+
name: options.name,
|
|
7106
|
+
nameFor: rootNameFor,
|
|
7053
7107
|
type: options.type ?? "custom",
|
|
7054
7108
|
surface: "opt-out"
|
|
7055
7109
|
};
|
|
7056
|
-
const
|
|
7110
|
+
const buildTracedRoot = (spanOptions) => this.withSpan(
|
|
7057
7111
|
traceFunctionKey,
|
|
7058
|
-
|
|
7112
|
+
spanOptions,
|
|
7059
7113
|
function(...args) {
|
|
7060
|
-
const capturePolicy = getAutoTraceCapturePolicy(
|
|
7114
|
+
const capturePolicy = getAutoTraceCapturePolicy(
|
|
7115
|
+
self,
|
|
7116
|
+
traceFunctionKey
|
|
7117
|
+
);
|
|
7061
7118
|
self.refreshAutoTraceCapturePolicy(traceFunctionKey);
|
|
7062
7119
|
let spansUsed = 0;
|
|
7063
7120
|
let truncated = false;
|
|
@@ -7078,19 +7135,54 @@ var Bitfab = class {
|
|
|
7078
7135
|
`"${traceFunctionKey}" hit an automatic subtree capture limit (maxDepth=${maxDepth}, maxSpans=${maxSpans}); its trace is incomplete. Raise the limits or narrow the subtree with exclude.`
|
|
7079
7136
|
);
|
|
7080
7137
|
};
|
|
7138
|
+
const spanStackOf = (entry) => entry.spanStack;
|
|
7139
|
+
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
7140
|
+
const runInside = () => runWithAutoTraceEntry(
|
|
7141
|
+
entry,
|
|
7142
|
+
{
|
|
7143
|
+
context: autoTraceContext,
|
|
7144
|
+
depth: entry.depth + 1,
|
|
7145
|
+
spanStack: getSpanStack()
|
|
7146
|
+
},
|
|
7147
|
+
invokeFn
|
|
7148
|
+
);
|
|
7149
|
+
return runWithSpanStack(spanStackOf(entry), () => {
|
|
7150
|
+
if (isAsync) {
|
|
7151
|
+
const tracedAsyncChild = self.withSpan(
|
|
7152
|
+
traceFunctionKey,
|
|
7153
|
+
childOptions,
|
|
7154
|
+
async (..._inputs) => await runInside()
|
|
7155
|
+
);
|
|
7156
|
+
return tracedAsyncChild(...inputs);
|
|
7157
|
+
}
|
|
7158
|
+
const tracedChild = self.withSpan(
|
|
7159
|
+
traceFunctionKey,
|
|
7160
|
+
childOptions,
|
|
7161
|
+
(..._inputs) => runInside()
|
|
7162
|
+
);
|
|
7163
|
+
return tracedChild(...inputs);
|
|
7164
|
+
});
|
|
7165
|
+
};
|
|
7166
|
+
const overBudget = (entry) => {
|
|
7167
|
+
if (entry.depth < maxDepth && spansUsed < maxSpans) {
|
|
7168
|
+
return false;
|
|
7169
|
+
}
|
|
7170
|
+
runWithSpanStack(spanStackOf(entry), warnTruncated);
|
|
7171
|
+
return true;
|
|
7172
|
+
};
|
|
7081
7173
|
const autoTraceContext = {
|
|
7082
|
-
|
|
7174
|
+
traceFunctionKey,
|
|
7175
|
+
invoke(definition, inputs, invokeFn, entry, nodeConfiguration) {
|
|
7083
7176
|
const nameParts = definition.name.split(".");
|
|
7084
7177
|
const simpleName = nameParts[nameParts.length - 1];
|
|
7085
|
-
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() :
|
|
7178
|
+
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() : clearAutoTraceNodeConfiguration(invokeFn);
|
|
7086
7179
|
if (excluded.has(definition.name) || simpleName !== void 0 && excluded.has(simpleName) || nodeConfiguration === void 0 && definition.wrapper === true && !includeWrappers) {
|
|
7087
7180
|
return invokeWithoutNode();
|
|
7088
7181
|
}
|
|
7089
7182
|
if (nodeConfiguration?.capture === false) {
|
|
7090
|
-
return
|
|
7183
|
+
return clearAutoTraceNodeConfiguration(invokeFn);
|
|
7091
7184
|
}
|
|
7092
|
-
if (
|
|
7093
|
-
warnTruncated();
|
|
7185
|
+
if (overBudget(entry)) {
|
|
7094
7186
|
return invokeWithoutNode();
|
|
7095
7187
|
}
|
|
7096
7188
|
spansUsed += 1;
|
|
@@ -7113,34 +7205,82 @@ var Bitfab = class {
|
|
|
7113
7205
|
finalize: nodeConfiguration.finalize
|
|
7114
7206
|
}
|
|
7115
7207
|
};
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
const tracedAsyncChild = self.withSpan(
|
|
7119
|
-
traceFunctionKey,
|
|
7120
|
-
childOptions,
|
|
7121
|
-
async (..._inputs) => await invokeWithAutoTraceContext()
|
|
7122
|
-
);
|
|
7123
|
-
return tracedAsyncChild(...inputs);
|
|
7124
|
-
}
|
|
7125
|
-
const tracedChild = self.withSpan(
|
|
7126
|
-
traceFunctionKey,
|
|
7208
|
+
return openChild(
|
|
7209
|
+
entry,
|
|
7127
7210
|
childOptions,
|
|
7128
|
-
|
|
7211
|
+
inputs,
|
|
7212
|
+
definition.async === true,
|
|
7213
|
+
invokeFn
|
|
7129
7214
|
);
|
|
7130
|
-
|
|
7215
|
+
},
|
|
7216
|
+
invokeNestedRoot(nestedName, nestedFunctionName, inputs, invokeFn, entry, link) {
|
|
7217
|
+
if (excluded.has(nestedName) || excluded.has(nestedFunctionName) || overBudget(entry)) {
|
|
7218
|
+
return invokeFn();
|
|
7219
|
+
}
|
|
7220
|
+
spansUsed += 1;
|
|
7221
|
+
const childOptions = {
|
|
7222
|
+
name: nestedName,
|
|
7223
|
+
type: "function",
|
|
7224
|
+
captureWhen: "nested",
|
|
7225
|
+
surface: "opt-out",
|
|
7226
|
+
captureContent: true,
|
|
7227
|
+
...link !== void 0 && { nestedTrace: link }
|
|
7228
|
+
};
|
|
7229
|
+
return openChild(entry, childOptions, inputs, false, invokeFn);
|
|
7131
7230
|
}
|
|
7132
7231
|
};
|
|
7133
7232
|
return runWithAutoTraceRootContext(
|
|
7134
7233
|
autoTraceContext,
|
|
7234
|
+
getSpanStack(),
|
|
7135
7235
|
() => fn.apply(this, args)
|
|
7136
7236
|
);
|
|
7137
7237
|
}
|
|
7138
7238
|
);
|
|
7239
|
+
const tracedRoot = buildTracedRoot(rootOptions);
|
|
7139
7240
|
const autoTraceRoot = function(...args) {
|
|
7140
7241
|
if (!self.shouldRecord()) {
|
|
7141
7242
|
return fn.apply(this, args);
|
|
7142
7243
|
}
|
|
7143
|
-
|
|
7244
|
+
const enclosing = currentAutoTraceEntries();
|
|
7245
|
+
if (enclosing.length === 0) {
|
|
7246
|
+
return tracedRoot.apply(this, args);
|
|
7247
|
+
}
|
|
7248
|
+
const link = getReplayContext() || inSeedScope() ? void 0 : { traceFunctionKey };
|
|
7249
|
+
const rootName = rootNameFor(this);
|
|
7250
|
+
return invokeThroughAutoTraceEntries(
|
|
7251
|
+
enclosing,
|
|
7252
|
+
(entry, next) => entry.context.invokeNestedRoot(
|
|
7253
|
+
rootName,
|
|
7254
|
+
name,
|
|
7255
|
+
args,
|
|
7256
|
+
next,
|
|
7257
|
+
entry,
|
|
7258
|
+
link
|
|
7259
|
+
),
|
|
7260
|
+
() => {
|
|
7261
|
+
if (link === void 0) {
|
|
7262
|
+
return fn.apply(this, args);
|
|
7263
|
+
}
|
|
7264
|
+
const innermost = enclosing[enclosing.length - 1];
|
|
7265
|
+
const innermostNow = currentAutoTraceEntries().find(
|
|
7266
|
+
(entry) => entry.context === innermost.context
|
|
7267
|
+
) ?? innermost;
|
|
7268
|
+
const innermostStack = innermostNow.spanStack;
|
|
7269
|
+
const copy = innermostStack[innermostStack.length - 1];
|
|
7270
|
+
const detachedRoot = buildTracedRoot({
|
|
7271
|
+
...rootOptions,
|
|
7272
|
+
...copy !== void 0 && {
|
|
7273
|
+
enclosingTrace: {
|
|
7274
|
+
traceId: copy.traceId,
|
|
7275
|
+
spanId: copy.spanId,
|
|
7276
|
+
traceFunctionKey: innermost.context.traceFunctionKey,
|
|
7277
|
+
link
|
|
7278
|
+
}
|
|
7279
|
+
}
|
|
7280
|
+
});
|
|
7281
|
+
return runWithSpanStack([], () => detachedRoot.apply(this, args));
|
|
7282
|
+
}
|
|
7283
|
+
);
|
|
7144
7284
|
};
|
|
7145
7285
|
Object.defineProperty(autoTraceRoot, "_bitfabTraceFunctionKey", {
|
|
7146
7286
|
value: traceFunctionKey
|
|
@@ -7729,6 +7869,10 @@ var Bitfab = class {
|
|
|
7729
7869
|
const spanId = randomUuid();
|
|
7730
7870
|
const parentSpanId = parentContext?.spanId ?? null;
|
|
7731
7871
|
const isRootSpan = parentSpanId === null;
|
|
7872
|
+
if (options.enclosingTrace !== void 0) {
|
|
7873
|
+
options.enclosingTrace.link.traceId = traceId;
|
|
7874
|
+
options.enclosingTrace.link.rootSpanId = spanId;
|
|
7875
|
+
}
|
|
7732
7876
|
const requestedSurface = options.surface ?? DEFAULT_SURFACE;
|
|
7733
7877
|
const surface = resolveSurface(requestedSurface, parentContext?.surface);
|
|
7734
7878
|
assertSurfacesCompatible(
|
|
@@ -7769,7 +7913,7 @@ var Bitfab = class {
|
|
|
7769
7913
|
const baseSpanParams = {
|
|
7770
7914
|
traceFunctionKey,
|
|
7771
7915
|
functionName,
|
|
7772
|
-
spanName: options.name ?? functionName ?? traceFunctionKey,
|
|
7916
|
+
spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionName) ?? traceFunctionKey,
|
|
7773
7917
|
traceId,
|
|
7774
7918
|
spanId,
|
|
7775
7919
|
parentSpanId,
|
|
@@ -7778,7 +7922,9 @@ var Bitfab = class {
|
|
|
7778
7922
|
spanType: options.type ?? "custom",
|
|
7779
7923
|
functionId: options.functionId,
|
|
7780
7924
|
captureContent: options.captureContent ?? true,
|
|
7781
|
-
autoTraceDefinition: options.autoTraceDefinition
|
|
7925
|
+
autoTraceDefinition: options.autoTraceDefinition,
|
|
7926
|
+
nestedTrace: options.nestedTrace,
|
|
7927
|
+
enclosingTrace: options.enclosingTrace
|
|
7782
7928
|
};
|
|
7783
7929
|
const sendSpan = async (params) => {
|
|
7784
7930
|
const replayCtx = getReplayContext();
|
|
@@ -8288,6 +8434,16 @@ var Bitfab = class {
|
|
|
8288
8434
|
function_line: params.autoTraceDefinition.line,
|
|
8289
8435
|
function_column: params.autoTraceDefinition.column
|
|
8290
8436
|
},
|
|
8437
|
+
...params.nestedTrace?.traceId !== void 0 && {
|
|
8438
|
+
nested_trace_id: params.nestedTrace.traceId,
|
|
8439
|
+
nested_trace_function_key: params.nestedTrace.traceFunctionKey,
|
|
8440
|
+
nested_root_span_id: params.nestedTrace.rootSpanId
|
|
8441
|
+
},
|
|
8442
|
+
...params.enclosingTrace !== void 0 && {
|
|
8443
|
+
enclosing_trace_id: params.enclosingTrace.traceId,
|
|
8444
|
+
enclosing_trace_function_key: params.enclosingTrace.traceFunctionKey,
|
|
8445
|
+
enclosing_span_id: params.enclosingTrace.spanId
|
|
8446
|
+
},
|
|
8291
8447
|
...serializedInputs !== void 0 && {
|
|
8292
8448
|
input: serializedInputs.json,
|
|
8293
8449
|
...serializedInputs.meta !== void 0 && {
|