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.
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
@@ -31,7 +31,7 @@ import {
31
31
  getCurrentTrace,
32
32
  reseedFromRegistry,
33
33
  seedFromRegistry
34
- } from "./chunk-34VY4J27.js";
34
+ } from "./chunk-IVF7JQHF.js";
35
35
  import "./chunk-RCHSYWKI.js";
36
36
  import {
37
37
  BITFAB_PROGRESS_PREFIX,
@@ -40,7 +40,7 @@ import {
40
40
  ReplayError,
41
41
  reportReplayProgress,
42
42
  serializeReplayResult
43
- } from "./chunk-HJLWJ3L2.js";
43
+ } from "./chunk-NSD5YKCE.js";
44
44
  import {
45
45
  BitfabError,
46
46
  DEFAULT_SERVICE_URL,
@@ -48,7 +48,7 @@ import {
48
48
  MixedTracingError,
49
49
  __version__,
50
50
  flushTraces
51
- } from "./chunk-EIWNY3FF.js";
51
+ } from "./chunk-KADON3SF.js";
52
52
  import "./chunk-VCRFFCLY.js";
53
53
  export {
54
54
  AssertionCategoriesClient,
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.58.3";
100
+ __version__ = "0.58.4";
101
101
  __packageName__ = "bitfab";
102
102
  }
103
103
  });
@@ -9832,13 +9832,23 @@ var Bitfab = class {
9832
9832
  traceFunctionKey
9833
9833
  );
9834
9834
  const openAiAgentsSpanIds = openAiAgentsSpanChain();
9835
+ const functionNameAtOpen = fn.name !== "" ? fn.name : void 0;
9835
9836
  const newContext = {
9836
9837
  traceId,
9837
9838
  spanId,
9838
9839
  contexts: [],
9840
+ spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionNameAtOpen) ?? traceFunctionKey,
9841
+ rootTraceFunctionKey: rootTraceFunctionKeyOfTrace(
9842
+ traceId,
9843
+ traceFunctionKey
9844
+ ),
9845
+ instrumentation: options.instrumentation ?? "span",
9846
+ declaredNode: options.declaredNode === true,
9847
+ isRoot: isRootSpan,
9839
9848
  ...surface !== void 0 && { surface },
9840
9849
  ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
9841
9850
  };
9851
+ const nearestCapturedAncestorSpanId = self.nearestCapturedAncestorSpanIdOf(currentStack);
9842
9852
  newStack = [...currentStack, newContext];
9843
9853
  const inputs = args;
9844
9854
  const startedAt = nowIsoTimestamp();
@@ -9865,19 +9875,16 @@ var Bitfab = class {
9865
9875
  }
9866
9876
  self.httpClient.traceCompletion.start(traceId, spanId);
9867
9877
  startedSpan = { traceId, spanId };
9868
- const functionName = fn.name !== "" ? fn.name : void 0;
9869
- const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
9870
- traceId,
9871
- traceFunctionKey
9872
- );
9878
+ const functionName = functionNameAtOpen;
9873
9879
  const baseSpanParams = {
9874
9880
  traceFunctionKey,
9875
- rootTraceFunctionKey,
9881
+ rootTraceFunctionKey: newContext.rootTraceFunctionKey,
9876
9882
  functionName,
9877
- spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionName) ?? traceFunctionKey,
9883
+ spanName: newContext.spanName,
9878
9884
  traceId,
9879
9885
  spanId,
9880
9886
  parentSpanId,
9887
+ nearestCapturedAncestorSpanId,
9881
9888
  inputs,
9882
9889
  startedAt,
9883
9890
  spanType: options.type ?? "custom",
@@ -10396,6 +10403,21 @@ var Bitfab = class {
10396
10403
  ...params.testRunId && { testRunId: params.testRunId }
10397
10404
  });
10398
10405
  }
10406
+ sendsSpanOnCompletion(context) {
10407
+ return context.isRoot || context.declaredNode || isFrameworkInstrumentation(context.instrumentation) || !this.simulationPlan.contentOffNow(
10408
+ context.rootTraceFunctionKey,
10409
+ context.spanName
10410
+ );
10411
+ }
10412
+ nearestCapturedAncestorSpanIdOf(stack) {
10413
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
10414
+ const candidate = stack[index];
10415
+ if (candidate !== void 0 && this.sendsSpanOnCompletion(candidate)) {
10416
+ return candidate.spanId;
10417
+ }
10418
+ }
10419
+ return null;
10420
+ }
10399
10421
  contentOffBySimulationPlan(params) {
10400
10422
  if (params.rootTraceFunctionKey === void 0 || isFrameworkInstrumentation(params.instrumentation)) {
10401
10423
  return false;
@@ -10472,6 +10494,9 @@ var Bitfab = class {
10472
10494
  if (params.parentSpanId) {
10473
10495
  externalSpan.parent_id = params.parentSpanId;
10474
10496
  }
10497
+ if (params.nearestCapturedAncestorSpanId !== void 0 && params.nearestCapturedAncestorSpanId !== null && params.nearestCapturedAncestorSpanId !== params.parentSpanId) {
10498
+ externalSpan.nearest_captured_ancestor_id = params.nearestCapturedAncestorSpanId;
10499
+ }
10475
10500
  if (params.inputSourceSpanId) {
10476
10501
  externalSpan.input_source_span_id = params.inputSourceSpanId;
10477
10502
  }