bitfab 0.58.3 → 0.58.4

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.
@@ -6,7 +6,7 @@ import {
6
6
  replayContextReady,
7
7
  runWithReplayContext,
8
8
  warnOnce
9
- } from "./chunk-EIWNY3FF.js";
9
+ } from "./chunk-KADON3SF.js";
10
10
  import {
11
11
  runWithCaptureSuppressed
12
12
  } from "./chunk-VCRFFCLY.js";
@@ -1264,4 +1264,4 @@ export {
1264
1264
  sleepForReplayPersistence,
1265
1265
  replay
1266
1266
  };
1267
- //# sourceMappingURL=chunk-HJLWJ3L2.js.map
1267
+ //# sourceMappingURL=chunk-NSD5YKCE.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BitfabError
3
- } from "./chunk-YWWDW5FX.js";
3
+ } from "./chunk-32ZY3DYR.js";
4
4
 
5
5
  // src/codeChange.ts
6
6
  var NUL = String.fromCharCode(0);
@@ -234,7 +234,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
234
234
  sessionId: seedCase.sessionId
235
235
  })
236
236
  );
237
- const { flushTraces: flushTraces2 } = await import("./http-Q75A3OKB.js");
237
+ const { flushTraces: flushTraces2 } = await import("./http-XQGMIDFR.js");
238
238
  await flushTraces2(3e4);
239
239
  return { pipeline, traceFunctionKey, traceIds };
240
240
  }
@@ -782,4 +782,4 @@ export {
782
782
  runRegistryMain,
783
783
  runIfEntrypoint
784
784
  };
785
- //# sourceMappingURL=chunk-HNUEEGIB.js.map
785
+ //# sourceMappingURL=chunk-UOW7VDNB.js.map
@@ -6,7 +6,7 @@ import {
6
6
  flushTraces,
7
7
  parseRetryAfterMs,
8
8
  serializePayloadBody
9
- } from "./chunk-EIWNY3FF.js";
9
+ } from "./chunk-KADON3SF.js";
10
10
  import "./chunk-VCRFFCLY.js";
11
11
  export {
12
12
  BitfabError,
@@ -17,4 +17,4 @@ export {
17
17
  parseRetryAfterMs,
18
18
  serializePayloadBody
19
19
  };
20
- //# sourceMappingURL=http-XH36DD6T.js.map
20
+ //# sourceMappingURL=http-TIOONTDB.js.map
@@ -6,7 +6,7 @@ import {
6
6
  flushTraces,
7
7
  parseRetryAfterMs,
8
8
  serializePayloadBody
9
- } from "./chunk-YWWDW5FX.js";
9
+ } from "./chunk-32ZY3DYR.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-Q75A3OKB.js.map
19
+ //# sourceMappingURL=http-XQGMIDFR.js.map
package/dist/index.cjs CHANGED
@@ -51,7 +51,7 @@ var __version__, __packageName__;
51
51
  var init_version_generated = __esm({
52
52
  "src/version.generated.ts"() {
53
53
  "use strict";
54
- __version__ = "0.58.3";
54
+ __version__ = "0.58.4";
55
55
  __packageName__ = "bitfab";
56
56
  }
57
57
  });
@@ -9818,13 +9818,23 @@ var Bitfab = class {
9818
9818
  traceFunctionKey
9819
9819
  );
9820
9820
  const openAiAgentsSpanIds = openAiAgentsSpanChain();
9821
+ const functionNameAtOpen = fn.name !== "" ? fn.name : void 0;
9821
9822
  const newContext = {
9822
9823
  traceId,
9823
9824
  spanId,
9824
9825
  contexts: [],
9826
+ spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionNameAtOpen) ?? traceFunctionKey,
9827
+ rootTraceFunctionKey: rootTraceFunctionKeyOfTrace(
9828
+ traceId,
9829
+ traceFunctionKey
9830
+ ),
9831
+ instrumentation: options.instrumentation ?? "span",
9832
+ declaredNode: options.declaredNode === true,
9833
+ isRoot: isRootSpan,
9825
9834
  ...surface !== void 0 && { surface },
9826
9835
  ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
9827
9836
  };
9837
+ const nearestCapturedAncestorSpanId = self.nearestCapturedAncestorSpanIdOf(currentStack);
9828
9838
  newStack = [...currentStack, newContext];
9829
9839
  const inputs = args;
9830
9840
  const startedAt = nowIsoTimestamp();
@@ -9851,19 +9861,16 @@ var Bitfab = class {
9851
9861
  }
9852
9862
  self.httpClient.traceCompletion.start(traceId, spanId);
9853
9863
  startedSpan = { traceId, spanId };
9854
- const functionName = fn.name !== "" ? fn.name : void 0;
9855
- const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
9856
- traceId,
9857
- traceFunctionKey
9858
- );
9864
+ const functionName = functionNameAtOpen;
9859
9865
  const baseSpanParams = {
9860
9866
  traceFunctionKey,
9861
- rootTraceFunctionKey,
9867
+ rootTraceFunctionKey: newContext.rootTraceFunctionKey,
9862
9868
  functionName,
9863
- spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionName) ?? traceFunctionKey,
9869
+ spanName: newContext.spanName,
9864
9870
  traceId,
9865
9871
  spanId,
9866
9872
  parentSpanId,
9873
+ nearestCapturedAncestorSpanId,
9867
9874
  inputs,
9868
9875
  startedAt,
9869
9876
  spanType: options.type ?? "custom",
@@ -10382,6 +10389,21 @@ var Bitfab = class {
10382
10389
  ...params.testRunId && { testRunId: params.testRunId }
10383
10390
  });
10384
10391
  }
10392
+ sendsSpanOnCompletion(context) {
10393
+ return context.isRoot || context.declaredNode || isFrameworkInstrumentation(context.instrumentation) || !this.simulationPlan.contentOffNow(
10394
+ context.rootTraceFunctionKey,
10395
+ context.spanName
10396
+ );
10397
+ }
10398
+ nearestCapturedAncestorSpanIdOf(stack) {
10399
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
10400
+ const candidate = stack[index];
10401
+ if (candidate !== void 0 && this.sendsSpanOnCompletion(candidate)) {
10402
+ return candidate.spanId;
10403
+ }
10404
+ }
10405
+ return null;
10406
+ }
10385
10407
  contentOffBySimulationPlan(params) {
10386
10408
  if (params.rootTraceFunctionKey === void 0 || isFrameworkInstrumentation(params.instrumentation)) {
10387
10409
  return false;
@@ -10458,6 +10480,9 @@ var Bitfab = class {
10458
10480
  if (params.parentSpanId) {
10459
10481
  externalSpan.parent_id = params.parentSpanId;
10460
10482
  }
10483
+ if (params.nearestCapturedAncestorSpanId !== void 0 && params.nearestCapturedAncestorSpanId !== null && params.nearestCapturedAncestorSpanId !== params.parentSpanId) {
10484
+ externalSpan.nearest_captured_ancestor_id = params.nearestCapturedAncestorSpanId;
10485
+ }
10461
10486
  if (params.inputSourceSpanId) {
10462
10487
  externalSpan.input_source_span_id = params.inputSourceSpanId;
10463
10488
  }