@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
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
getCurrentTrace,
|
|
20
20
|
reseedFromRegistry,
|
|
21
21
|
seedFromRegistry
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-3IKQHUGK.js";
|
|
23
|
+
import "./chunk-E5BLYL5X.js";
|
|
24
24
|
import {
|
|
25
25
|
BITFAB_PROGRESS_PREFIX,
|
|
26
26
|
DbBranchReplayError,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
ReplayError,
|
|
29
29
|
reportReplayProgress,
|
|
30
30
|
serializeReplayResult
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-KSKRPIY6.js";
|
|
32
32
|
import {
|
|
33
33
|
BitfabError,
|
|
34
34
|
DEFAULT_SERVICE_URL,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
MixedTracingError,
|
|
37
37
|
__version__,
|
|
38
38
|
flushTraces
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-WIBQUZPU.js";
|
|
40
40
|
import "./chunk-H6LZRFMN.js";
|
|
41
41
|
export {
|
|
42
42
|
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.
|
|
91
|
+
__version__ = "0.53.0";
|
|
92
92
|
__packageName__ = "@bitfab/sdk";
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -4212,19 +4212,18 @@ init_asyncStorage();
|
|
|
4212
4212
|
// src/autoTrace.ts
|
|
4213
4213
|
init_asyncStorage();
|
|
4214
4214
|
var autoTraceGlobal = globalThis;
|
|
4215
|
-
var autoTraceState = autoTraceGlobal.
|
|
4215
|
+
var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
|
|
4216
4216
|
storage: null,
|
|
4217
4217
|
browserScope: void 0,
|
|
4218
4218
|
capturePolicies: /* @__PURE__ */ new WeakMap(),
|
|
4219
4219
|
activeRoots: 0
|
|
4220
4220
|
};
|
|
4221
|
-
autoTraceGlobal.
|
|
4221
|
+
autoTraceGlobal.__bitfabAutoTraceStateV4 = autoTraceState;
|
|
4222
4222
|
function initializeAutoTraceStorage() {
|
|
4223
4223
|
autoTraceState.storage ?? (autoTraceState.storage = createAsyncLocalStorage());
|
|
4224
4224
|
}
|
|
4225
|
-
function
|
|
4225
|
+
function runWithAutoTraceScope(scope, fn) {
|
|
4226
4226
|
initializeAutoTraceStorage();
|
|
4227
|
-
const scope = { context, depth };
|
|
4228
4227
|
if (autoTraceState.storage) {
|
|
4229
4228
|
return autoTraceState.storage.run(scope, fn);
|
|
4230
4229
|
}
|
|
@@ -4236,41 +4235,65 @@ function runWithAutoTraceContext(context, fn, depth = 0) {
|
|
|
4236
4235
|
autoTraceState.browserScope = previous;
|
|
4237
4236
|
}
|
|
4238
4237
|
}
|
|
4238
|
+
function currentAutoTraceEntries() {
|
|
4239
|
+
return currentAutoTraceScope()?.entries ?? [];
|
|
4240
|
+
}
|
|
4241
|
+
function replaceEntry(entries, previous, updated) {
|
|
4242
|
+
return entries.map((entry) => entry === previous ? updated : entry);
|
|
4243
|
+
}
|
|
4244
|
+
function runWithAutoTraceEntry(previous, updated, fn) {
|
|
4245
|
+
const result = runWithAutoTraceScope(
|
|
4246
|
+
{ entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
|
|
4247
|
+
fn
|
|
4248
|
+
);
|
|
4249
|
+
if (isAutoTraceAsyncGenerator(result)) {
|
|
4250
|
+
return wrapAutoTraceEntryAsyncGenerator(previous, updated, result);
|
|
4251
|
+
}
|
|
4252
|
+
return result;
|
|
4253
|
+
}
|
|
4254
|
+
function wrapAutoTraceEntryAsyncGenerator(previous, updated, source) {
|
|
4255
|
+
const step = (method, value) => runWithAutoTraceScope(
|
|
4256
|
+
{ entries: replaceEntry(currentAutoTraceEntries(), previous, updated) },
|
|
4257
|
+
() => source[method](value)
|
|
4258
|
+
);
|
|
4259
|
+
const wrapped = {
|
|
4260
|
+
next: (value) => step("next", value),
|
|
4261
|
+
return: (value) => step("return", value),
|
|
4262
|
+
throw: (error) => step("throw", error),
|
|
4263
|
+
[Symbol.asyncIterator]: () => wrapped
|
|
4264
|
+
};
|
|
4265
|
+
return wrapped;
|
|
4266
|
+
}
|
|
4267
|
+
function clearAutoTraceNodeConfiguration(fn) {
|
|
4268
|
+
return runWithAutoTraceScope({ entries: currentAutoTraceEntries() }, fn);
|
|
4269
|
+
}
|
|
4239
4270
|
function runWithAutoTraceNodeConfiguration(nodeConfiguration, fn) {
|
|
4240
4271
|
const scope = currentAutoTraceScope();
|
|
4241
|
-
if (!scope) {
|
|
4272
|
+
if (!scope || scope.entries.length === 0) {
|
|
4242
4273
|
return fn();
|
|
4243
4274
|
}
|
|
4244
|
-
const
|
|
4245
|
-
let result;
|
|
4246
|
-
if (autoTraceState.storage) {
|
|
4247
|
-
result = autoTraceState.storage.run(configuredScope, fn);
|
|
4248
|
-
} else {
|
|
4249
|
-
const previous = autoTraceState.browserScope;
|
|
4250
|
-
autoTraceState.browserScope = configuredScope;
|
|
4251
|
-
try {
|
|
4252
|
-
result = fn();
|
|
4253
|
-
} finally {
|
|
4254
|
-
autoTraceState.browserScope = previous;
|
|
4255
|
-
}
|
|
4256
|
-
}
|
|
4275
|
+
const result = runWithAutoTraceScope({ ...scope, nodeConfiguration }, fn);
|
|
4257
4276
|
if (isAutoTraceAsyncGenerator(result)) {
|
|
4258
4277
|
return wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, result);
|
|
4259
4278
|
}
|
|
4260
4279
|
return result;
|
|
4261
4280
|
}
|
|
4262
|
-
function runWithAutoTraceRootContext(context, fn) {
|
|
4281
|
+
function runWithAutoTraceRootContext(context, spanStack, fn) {
|
|
4263
4282
|
autoTraceState.activeRoots += 1;
|
|
4283
|
+
const entries = [
|
|
4284
|
+
...currentAutoTraceEntries(),
|
|
4285
|
+
{ context, depth: 0, spanStack }
|
|
4286
|
+
];
|
|
4264
4287
|
let result;
|
|
4265
4288
|
try {
|
|
4266
|
-
result =
|
|
4289
|
+
result = runWithAutoTraceScope({ entries }, fn);
|
|
4267
4290
|
} catch (error) {
|
|
4268
4291
|
autoTraceState.activeRoots -= 1;
|
|
4269
4292
|
throw error;
|
|
4270
4293
|
}
|
|
4271
4294
|
if (isAutoTraceAsyncGenerator(result)) {
|
|
4272
4295
|
autoTraceState.activeRoots -= 1;
|
|
4273
|
-
return wrapAutoTraceAsyncGenerator(context, result);
|
|
4296
|
+
return wrapAutoTraceAsyncGenerator(context, spanStack, result);
|
|
4274
4297
|
}
|
|
4275
4298
|
if (result instanceof Promise) {
|
|
4276
4299
|
return result.finally(() => {
|
|
@@ -4280,6 +4303,15 @@ function runWithAutoTraceRootContext(context, fn) {
|
|
|
4280
4303
|
autoTraceState.activeRoots -= 1;
|
|
4281
4304
|
return result;
|
|
4282
4305
|
}
|
|
4306
|
+
function invokeThroughAutoTraceEntries(entries, step, fn) {
|
|
4307
|
+
let run = fn;
|
|
4308
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
4309
|
+
const entry = entries[index];
|
|
4310
|
+
const next = run;
|
|
4311
|
+
run = () => step(entry, next);
|
|
4312
|
+
}
|
|
4313
|
+
return run();
|
|
4314
|
+
}
|
|
4283
4315
|
function isAutoTraceAsyncGenerator(value) {
|
|
4284
4316
|
if (value === null || typeof value !== "object") {
|
|
4285
4317
|
return false;
|
|
@@ -4287,8 +4319,8 @@ function isAutoTraceAsyncGenerator(value) {
|
|
|
4287
4319
|
const candidate = value;
|
|
4288
4320
|
return typeof candidate.next === "function" && typeof candidate.return === "function" && typeof candidate.throw === "function" && typeof candidate[Symbol.asyncIterator] === "function";
|
|
4289
4321
|
}
|
|
4290
|
-
function wrapAutoTraceAsyncGenerator(context, source) {
|
|
4291
|
-
const step = (method, value) => runWithAutoTraceRootContext(context, () => source[method](value));
|
|
4322
|
+
function wrapAutoTraceAsyncGenerator(context, spanStack, source) {
|
|
4323
|
+
const step = (method, value) => runWithAutoTraceRootContext(context, spanStack, () => source[method](value));
|
|
4292
4324
|
const wrapped = {
|
|
4293
4325
|
next: (value) => step("next", value),
|
|
4294
4326
|
return: (value) => step("return", value),
|
|
@@ -4314,7 +4346,7 @@ function __bitfabAutoTraceActive() {
|
|
|
4314
4346
|
if (autoTraceState.activeRoots === 0) {
|
|
4315
4347
|
return false;
|
|
4316
4348
|
}
|
|
4317
|
-
return
|
|
4349
|
+
return currentAutoTraceEntries().length > 0;
|
|
4318
4350
|
}
|
|
4319
4351
|
function currentAutoTraceScope() {
|
|
4320
4352
|
initializeAutoTraceStorage();
|
|
@@ -6860,6 +6892,26 @@ var DEFAULT_AUTO_TRACE_MAX_SPANS = 500;
|
|
|
6860
6892
|
var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
|
|
6861
6893
|
var AUTO_TRACE_POLICY_REFRESH_MS = 6e4;
|
|
6862
6894
|
var AUTO_TRACE_POLICY_RETRY_MS = 1e4;
|
|
6895
|
+
function spanOwnerName(receiver) {
|
|
6896
|
+
if (typeof receiver === "function") {
|
|
6897
|
+
return receiver.name !== "" ? receiver.name : void 0;
|
|
6898
|
+
}
|
|
6899
|
+
if (typeof receiver !== "object" || receiver === null) {
|
|
6900
|
+
return void 0;
|
|
6901
|
+
}
|
|
6902
|
+
const owner = receiver.constructor;
|
|
6903
|
+
if (typeof owner !== "function" || owner === Object || owner.name === "") {
|
|
6904
|
+
return void 0;
|
|
6905
|
+
}
|
|
6906
|
+
return owner.name;
|
|
6907
|
+
}
|
|
6908
|
+
function qualifiedSpanName(receiver, functionName) {
|
|
6909
|
+
if (functionName === void 0) {
|
|
6910
|
+
return void 0;
|
|
6911
|
+
}
|
|
6912
|
+
const owner = spanOwnerName(receiver);
|
|
6913
|
+
return owner === void 0 ? functionName : `${owner}.${functionName}`;
|
|
6914
|
+
}
|
|
6863
6915
|
function autoTraceLimit(value, fallback) {
|
|
6864
6916
|
return value !== void 0 && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
|
|
6865
6917
|
}
|
|
@@ -7062,16 +7114,21 @@ var Bitfab = class {
|
|
|
7062
7114
|
);
|
|
7063
7115
|
const excluded = new Set(options.exclude ?? []);
|
|
7064
7116
|
const includeWrappers = options.includeWrappers ?? false;
|
|
7117
|
+
const rootNameFor = (receiver) => options.name ?? (fn.name !== "" ? qualifiedSpanName(receiver, name) ?? name : name);
|
|
7065
7118
|
const rootOptions = {
|
|
7066
|
-
name: options.name
|
|
7119
|
+
name: options.name,
|
|
7120
|
+
nameFor: rootNameFor,
|
|
7067
7121
|
type: options.type ?? "custom",
|
|
7068
7122
|
surface: "opt-out"
|
|
7069
7123
|
};
|
|
7070
|
-
const
|
|
7124
|
+
const buildTracedRoot = (spanOptions) => this.withSpan(
|
|
7071
7125
|
traceFunctionKey,
|
|
7072
|
-
|
|
7126
|
+
spanOptions,
|
|
7073
7127
|
function(...args) {
|
|
7074
|
-
const capturePolicy = getAutoTraceCapturePolicy(
|
|
7128
|
+
const capturePolicy = getAutoTraceCapturePolicy(
|
|
7129
|
+
self,
|
|
7130
|
+
traceFunctionKey
|
|
7131
|
+
);
|
|
7075
7132
|
self.refreshAutoTraceCapturePolicy(traceFunctionKey);
|
|
7076
7133
|
let spansUsed = 0;
|
|
7077
7134
|
let truncated = false;
|
|
@@ -7092,19 +7149,54 @@ var Bitfab = class {
|
|
|
7092
7149
|
`"${traceFunctionKey}" hit an automatic subtree capture limit (maxDepth=${maxDepth}, maxSpans=${maxSpans}); its trace is incomplete. Raise the limits or narrow the subtree with exclude.`
|
|
7093
7150
|
);
|
|
7094
7151
|
};
|
|
7152
|
+
const spanStackOf = (entry) => entry.spanStack;
|
|
7153
|
+
const openChild = (entry, childOptions, inputs, isAsync, invokeFn) => {
|
|
7154
|
+
const runInside = () => runWithAutoTraceEntry(
|
|
7155
|
+
entry,
|
|
7156
|
+
{
|
|
7157
|
+
context: autoTraceContext,
|
|
7158
|
+
depth: entry.depth + 1,
|
|
7159
|
+
spanStack: getSpanStack()
|
|
7160
|
+
},
|
|
7161
|
+
invokeFn
|
|
7162
|
+
);
|
|
7163
|
+
return runWithSpanStack(spanStackOf(entry), () => {
|
|
7164
|
+
if (isAsync) {
|
|
7165
|
+
const tracedAsyncChild = self.withSpan(
|
|
7166
|
+
traceFunctionKey,
|
|
7167
|
+
childOptions,
|
|
7168
|
+
async (..._inputs) => await runInside()
|
|
7169
|
+
);
|
|
7170
|
+
return tracedAsyncChild(...inputs);
|
|
7171
|
+
}
|
|
7172
|
+
const tracedChild = self.withSpan(
|
|
7173
|
+
traceFunctionKey,
|
|
7174
|
+
childOptions,
|
|
7175
|
+
(..._inputs) => runInside()
|
|
7176
|
+
);
|
|
7177
|
+
return tracedChild(...inputs);
|
|
7178
|
+
});
|
|
7179
|
+
};
|
|
7180
|
+
const overBudget = (entry) => {
|
|
7181
|
+
if (entry.depth < maxDepth && spansUsed < maxSpans) {
|
|
7182
|
+
return false;
|
|
7183
|
+
}
|
|
7184
|
+
runWithSpanStack(spanStackOf(entry), warnTruncated);
|
|
7185
|
+
return true;
|
|
7186
|
+
};
|
|
7095
7187
|
const autoTraceContext = {
|
|
7096
|
-
|
|
7188
|
+
traceFunctionKey,
|
|
7189
|
+
invoke(definition, inputs, invokeFn, entry, nodeConfiguration) {
|
|
7097
7190
|
const nameParts = definition.name.split(".");
|
|
7098
7191
|
const simpleName = nameParts[nameParts.length - 1];
|
|
7099
|
-
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() :
|
|
7192
|
+
const invokeWithoutNode = () => nodeConfiguration === void 0 ? invokeFn() : clearAutoTraceNodeConfiguration(invokeFn);
|
|
7100
7193
|
if (excluded.has(definition.name) || simpleName !== void 0 && excluded.has(simpleName) || nodeConfiguration === void 0 && definition.wrapper === true && !includeWrappers) {
|
|
7101
7194
|
return invokeWithoutNode();
|
|
7102
7195
|
}
|
|
7103
7196
|
if (nodeConfiguration?.capture === false) {
|
|
7104
|
-
return
|
|
7197
|
+
return clearAutoTraceNodeConfiguration(invokeFn);
|
|
7105
7198
|
}
|
|
7106
|
-
if (
|
|
7107
|
-
warnTruncated();
|
|
7199
|
+
if (overBudget(entry)) {
|
|
7108
7200
|
return invokeWithoutNode();
|
|
7109
7201
|
}
|
|
7110
7202
|
spansUsed += 1;
|
|
@@ -7127,34 +7219,82 @@ var Bitfab = class {
|
|
|
7127
7219
|
finalize: nodeConfiguration.finalize
|
|
7128
7220
|
}
|
|
7129
7221
|
};
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
const tracedAsyncChild = self.withSpan(
|
|
7133
|
-
traceFunctionKey,
|
|
7134
|
-
childOptions,
|
|
7135
|
-
async (..._inputs) => await invokeWithAutoTraceContext()
|
|
7136
|
-
);
|
|
7137
|
-
return tracedAsyncChild(...inputs);
|
|
7138
|
-
}
|
|
7139
|
-
const tracedChild = self.withSpan(
|
|
7140
|
-
traceFunctionKey,
|
|
7222
|
+
return openChild(
|
|
7223
|
+
entry,
|
|
7141
7224
|
childOptions,
|
|
7142
|
-
|
|
7225
|
+
inputs,
|
|
7226
|
+
definition.async === true,
|
|
7227
|
+
invokeFn
|
|
7143
7228
|
);
|
|
7144
|
-
|
|
7229
|
+
},
|
|
7230
|
+
invokeNestedRoot(nestedName, nestedFunctionName, inputs, invokeFn, entry, link) {
|
|
7231
|
+
if (excluded.has(nestedName) || excluded.has(nestedFunctionName) || overBudget(entry)) {
|
|
7232
|
+
return invokeFn();
|
|
7233
|
+
}
|
|
7234
|
+
spansUsed += 1;
|
|
7235
|
+
const childOptions = {
|
|
7236
|
+
name: nestedName,
|
|
7237
|
+
type: "function",
|
|
7238
|
+
captureWhen: "nested",
|
|
7239
|
+
surface: "opt-out",
|
|
7240
|
+
captureContent: true,
|
|
7241
|
+
...link !== void 0 && { nestedTrace: link }
|
|
7242
|
+
};
|
|
7243
|
+
return openChild(entry, childOptions, inputs, false, invokeFn);
|
|
7145
7244
|
}
|
|
7146
7245
|
};
|
|
7147
7246
|
return runWithAutoTraceRootContext(
|
|
7148
7247
|
autoTraceContext,
|
|
7248
|
+
getSpanStack(),
|
|
7149
7249
|
() => fn.apply(this, args)
|
|
7150
7250
|
);
|
|
7151
7251
|
}
|
|
7152
7252
|
);
|
|
7253
|
+
const tracedRoot = buildTracedRoot(rootOptions);
|
|
7153
7254
|
const autoTraceRoot = function(...args) {
|
|
7154
7255
|
if (!self.shouldRecord()) {
|
|
7155
7256
|
return fn.apply(this, args);
|
|
7156
7257
|
}
|
|
7157
|
-
|
|
7258
|
+
const enclosing = currentAutoTraceEntries();
|
|
7259
|
+
if (enclosing.length === 0) {
|
|
7260
|
+
return tracedRoot.apply(this, args);
|
|
7261
|
+
}
|
|
7262
|
+
const link = getReplayContext() || inSeedScope() ? void 0 : { traceFunctionKey };
|
|
7263
|
+
const rootName = rootNameFor(this);
|
|
7264
|
+
return invokeThroughAutoTraceEntries(
|
|
7265
|
+
enclosing,
|
|
7266
|
+
(entry, next) => entry.context.invokeNestedRoot(
|
|
7267
|
+
rootName,
|
|
7268
|
+
name,
|
|
7269
|
+
args,
|
|
7270
|
+
next,
|
|
7271
|
+
entry,
|
|
7272
|
+
link
|
|
7273
|
+
),
|
|
7274
|
+
() => {
|
|
7275
|
+
if (link === void 0) {
|
|
7276
|
+
return fn.apply(this, args);
|
|
7277
|
+
}
|
|
7278
|
+
const innermost = enclosing[enclosing.length - 1];
|
|
7279
|
+
const innermostNow = currentAutoTraceEntries().find(
|
|
7280
|
+
(entry) => entry.context === innermost.context
|
|
7281
|
+
) ?? innermost;
|
|
7282
|
+
const innermostStack = innermostNow.spanStack;
|
|
7283
|
+
const copy = innermostStack[innermostStack.length - 1];
|
|
7284
|
+
const detachedRoot = buildTracedRoot({
|
|
7285
|
+
...rootOptions,
|
|
7286
|
+
...copy !== void 0 && {
|
|
7287
|
+
enclosingTrace: {
|
|
7288
|
+
traceId: copy.traceId,
|
|
7289
|
+
spanId: copy.spanId,
|
|
7290
|
+
traceFunctionKey: innermost.context.traceFunctionKey,
|
|
7291
|
+
link
|
|
7292
|
+
}
|
|
7293
|
+
}
|
|
7294
|
+
});
|
|
7295
|
+
return runWithSpanStack([], () => detachedRoot.apply(this, args));
|
|
7296
|
+
}
|
|
7297
|
+
);
|
|
7158
7298
|
};
|
|
7159
7299
|
Object.defineProperty(autoTraceRoot, "_bitfabTraceFunctionKey", {
|
|
7160
7300
|
value: traceFunctionKey
|
|
@@ -7743,6 +7883,10 @@ var Bitfab = class {
|
|
|
7743
7883
|
const spanId = randomUuid();
|
|
7744
7884
|
const parentSpanId = parentContext?.spanId ?? null;
|
|
7745
7885
|
const isRootSpan = parentSpanId === null;
|
|
7886
|
+
if (options.enclosingTrace !== void 0) {
|
|
7887
|
+
options.enclosingTrace.link.traceId = traceId;
|
|
7888
|
+
options.enclosingTrace.link.rootSpanId = spanId;
|
|
7889
|
+
}
|
|
7746
7890
|
const requestedSurface = options.surface ?? DEFAULT_SURFACE;
|
|
7747
7891
|
const surface = resolveSurface(requestedSurface, parentContext?.surface);
|
|
7748
7892
|
assertSurfacesCompatible(
|
|
@@ -7783,7 +7927,7 @@ var Bitfab = class {
|
|
|
7783
7927
|
const baseSpanParams = {
|
|
7784
7928
|
traceFunctionKey,
|
|
7785
7929
|
functionName,
|
|
7786
|
-
spanName: options.name ?? functionName ?? traceFunctionKey,
|
|
7930
|
+
spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionName) ?? traceFunctionKey,
|
|
7787
7931
|
traceId,
|
|
7788
7932
|
spanId,
|
|
7789
7933
|
parentSpanId,
|
|
@@ -7792,7 +7936,9 @@ var Bitfab = class {
|
|
|
7792
7936
|
spanType: options.type ?? "custom",
|
|
7793
7937
|
functionId: options.functionId,
|
|
7794
7938
|
captureContent: options.captureContent ?? true,
|
|
7795
|
-
autoTraceDefinition: options.autoTraceDefinition
|
|
7939
|
+
autoTraceDefinition: options.autoTraceDefinition,
|
|
7940
|
+
nestedTrace: options.nestedTrace,
|
|
7941
|
+
enclosingTrace: options.enclosingTrace
|
|
7796
7942
|
};
|
|
7797
7943
|
const sendSpan = async (params) => {
|
|
7798
7944
|
const replayCtx = getReplayContext();
|
|
@@ -8302,6 +8448,16 @@ var Bitfab = class {
|
|
|
8302
8448
|
function_line: params.autoTraceDefinition.line,
|
|
8303
8449
|
function_column: params.autoTraceDefinition.column
|
|
8304
8450
|
},
|
|
8451
|
+
...params.nestedTrace?.traceId !== void 0 && {
|
|
8452
|
+
nested_trace_id: params.nestedTrace.traceId,
|
|
8453
|
+
nested_trace_function_key: params.nestedTrace.traceFunctionKey,
|
|
8454
|
+
nested_root_span_id: params.nestedTrace.rootSpanId
|
|
8455
|
+
},
|
|
8456
|
+
...params.enclosingTrace !== void 0 && {
|
|
8457
|
+
enclosing_trace_id: params.enclosingTrace.traceId,
|
|
8458
|
+
enclosing_trace_function_key: params.enclosingTrace.traceFunctionKey,
|
|
8459
|
+
enclosing_span_id: params.enclosingTrace.spanId
|
|
8460
|
+
},
|
|
8305
8461
|
...serializedInputs !== void 0 && {
|
|
8306
8462
|
input: serializedInputs.json,
|
|
8307
8463
|
...serializedInputs.meta !== void 0 && {
|