@bitfab/sdk 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.
package/dist/index.d.cts CHANGED
@@ -3372,6 +3372,8 @@ declare class Bitfab {
3372
3372
  * Queued on the client's span transport; delivery is the transport's job.
3373
3373
  */
3374
3374
  private sendTraceCompletion;
3375
+ private sendsSpanOnCompletion;
3376
+ private nearestCapturedAncestorSpanIdOf;
3375
3377
  private contentOffBySimulationPlan;
3376
3378
  /**
3377
3379
  * Send a wrapper span from function execution.
@@ -3657,7 +3659,7 @@ interface CommitRef {
3657
3659
  /**
3658
3660
  * SDK version from package.json (injected at build time)
3659
3661
  */
3660
- declare const __version__ = "0.58.3";
3662
+ declare const __version__ = "0.58.4";
3661
3663
 
3662
3664
  /**
3663
3665
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -3372,6 +3372,8 @@ declare class Bitfab {
3372
3372
  * Queued on the client's span transport; delivery is the transport's job.
3373
3373
  */
3374
3374
  private sendTraceCompletion;
3375
+ private sendsSpanOnCompletion;
3376
+ private nearestCapturedAncestorSpanIdOf;
3375
3377
  private contentOffBySimulationPlan;
3376
3378
  /**
3377
3379
  * Send a wrapper span from function execution.
@@ -3657,7 +3659,7 @@ interface CommitRef {
3657
3659
  /**
3658
3660
  * SDK version from package.json (injected at build time)
3659
3661
  */
3660
- declare const __version__ = "0.58.3";
3662
+ declare const __version__ = "0.58.4";
3661
3663
 
3662
3664
  /**
3663
3665
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  getCurrentTrace,
23
23
  reseedFromRegistry,
24
24
  seedFromRegistry
25
- } from "./chunk-XBZO7PFX.js";
25
+ } from "./chunk-UKJ3RWVS.js";
26
26
  import "./chunk-RCHSYWKI.js";
27
27
  import {
28
28
  BITFAB_PROGRESS_PREFIX,
@@ -31,7 +31,7 @@ import {
31
31
  ReplayError,
32
32
  reportReplayProgress,
33
33
  serializeReplayResult
34
- } from "./chunk-KOWM65AV.js";
34
+ } from "./chunk-BVUGW7BJ.js";
35
35
  import {
36
36
  BitfabError,
37
37
  DEFAULT_SERVICE_URL,
@@ -39,7 +39,7 @@ import {
39
39
  MixedTracingError,
40
40
  __version__,
41
41
  flushTraces
42
- } from "./chunk-WVFMRMV4.js";
42
+ } from "./chunk-ZLAFCSCP.js";
43
43
  import "./chunk-VCRFFCLY.js";
44
44
  export {
45
45
  AssertionCategoriesClient,
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.58.3";
91
+ __version__ = "0.58.4";
92
92
  __packageName__ = "@bitfab/sdk";
93
93
  }
94
94
  });
@@ -9823,13 +9823,23 @@ var Bitfab = class {
9823
9823
  traceFunctionKey
9824
9824
  );
9825
9825
  const openAiAgentsSpanIds = openAiAgentsSpanChain();
9826
+ const functionNameAtOpen = fn.name !== "" ? fn.name : void 0;
9826
9827
  const newContext = {
9827
9828
  traceId,
9828
9829
  spanId,
9829
9830
  contexts: [],
9831
+ spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionNameAtOpen) ?? traceFunctionKey,
9832
+ rootTraceFunctionKey: rootTraceFunctionKeyOfTrace(
9833
+ traceId,
9834
+ traceFunctionKey
9835
+ ),
9836
+ instrumentation: options.instrumentation ?? "span",
9837
+ declaredNode: options.declaredNode === true,
9838
+ isRoot: isRootSpan,
9830
9839
  ...surface !== void 0 && { surface },
9831
9840
  ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
9832
9841
  };
9842
+ const nearestCapturedAncestorSpanId = self.nearestCapturedAncestorSpanIdOf(currentStack);
9833
9843
  newStack = [...currentStack, newContext];
9834
9844
  const inputs = args;
9835
9845
  const startedAt = nowIsoTimestamp();
@@ -9856,19 +9866,16 @@ var Bitfab = class {
9856
9866
  }
9857
9867
  self.httpClient.traceCompletion.start(traceId, spanId);
9858
9868
  startedSpan = { traceId, spanId };
9859
- const functionName = fn.name !== "" ? fn.name : void 0;
9860
- const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
9861
- traceId,
9862
- traceFunctionKey
9863
- );
9869
+ const functionName = functionNameAtOpen;
9864
9870
  const baseSpanParams = {
9865
9871
  traceFunctionKey,
9866
- rootTraceFunctionKey,
9872
+ rootTraceFunctionKey: newContext.rootTraceFunctionKey,
9867
9873
  functionName,
9868
- spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionName) ?? traceFunctionKey,
9874
+ spanName: newContext.spanName,
9869
9875
  traceId,
9870
9876
  spanId,
9871
9877
  parentSpanId,
9878
+ nearestCapturedAncestorSpanId,
9872
9879
  inputs,
9873
9880
  startedAt,
9874
9881
  spanType: options.type ?? "custom",
@@ -10387,6 +10394,21 @@ var Bitfab = class {
10387
10394
  ...params.testRunId && { testRunId: params.testRunId }
10388
10395
  });
10389
10396
  }
10397
+ sendsSpanOnCompletion(context) {
10398
+ return context.isRoot || context.declaredNode || isFrameworkInstrumentation(context.instrumentation) || !this.simulationPlan.contentOffNow(
10399
+ context.rootTraceFunctionKey,
10400
+ context.spanName
10401
+ );
10402
+ }
10403
+ nearestCapturedAncestorSpanIdOf(stack) {
10404
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
10405
+ const candidate = stack[index];
10406
+ if (candidate !== void 0 && this.sendsSpanOnCompletion(candidate)) {
10407
+ return candidate.spanId;
10408
+ }
10409
+ }
10410
+ return null;
10411
+ }
10390
10412
  contentOffBySimulationPlan(params) {
10391
10413
  if (params.rootTraceFunctionKey === void 0 || isFrameworkInstrumentation(params.instrumentation)) {
10392
10414
  return false;
@@ -10463,6 +10485,9 @@ var Bitfab = class {
10463
10485
  if (params.parentSpanId) {
10464
10486
  externalSpan.parent_id = params.parentSpanId;
10465
10487
  }
10488
+ if (params.nearestCapturedAncestorSpanId !== void 0 && params.nearestCapturedAncestorSpanId !== null && params.nearestCapturedAncestorSpanId !== params.parentSpanId) {
10489
+ externalSpan.nearest_captured_ancestor_id = params.nearestCapturedAncestorSpanId;
10490
+ }
10466
10491
  if (params.inputSourceSpanId) {
10467
10492
  externalSpan.input_source_span_id = params.inputSourceSpanId;
10468
10493
  }