@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.
@@ -6,7 +6,7 @@ import {
6
6
  flushTraces,
7
7
  parseRetryAfterMs,
8
8
  serializePayloadBody
9
- } from "./chunk-E4W3LSVL.js";
9
+ } from "./chunk-3LJVTDD5.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-ZI4BQTKT.js.map
19
+ //# sourceMappingURL=http-NG5NP6PH.js.map
@@ -6,7 +6,7 @@ import {
6
6
  flushTraces,
7
7
  parseRetryAfterMs,
8
8
  serializePayloadBody
9
- } from "./chunk-WVFMRMV4.js";
9
+ } from "./chunk-ZLAFCSCP.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-ARGY6JF2.js.map
20
+ //# sourceMappingURL=http-XTSUPZEC.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.58.3";
45
+ __version__ = "0.58.4";
46
46
  __packageName__ = "@bitfab/sdk";
47
47
  }
48
48
  });
@@ -9809,13 +9809,23 @@ var Bitfab = class {
9809
9809
  traceFunctionKey
9810
9810
  );
9811
9811
  const openAiAgentsSpanIds = openAiAgentsSpanChain();
9812
+ const functionNameAtOpen = fn.name !== "" ? fn.name : void 0;
9812
9813
  const newContext = {
9813
9814
  traceId,
9814
9815
  spanId,
9815
9816
  contexts: [],
9817
+ spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionNameAtOpen) ?? traceFunctionKey,
9818
+ rootTraceFunctionKey: rootTraceFunctionKeyOfTrace(
9819
+ traceId,
9820
+ traceFunctionKey
9821
+ ),
9822
+ instrumentation: options.instrumentation ?? "span",
9823
+ declaredNode: options.declaredNode === true,
9824
+ isRoot: isRootSpan,
9816
9825
  ...surface !== void 0 && { surface },
9817
9826
  ...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
9818
9827
  };
9828
+ const nearestCapturedAncestorSpanId = self.nearestCapturedAncestorSpanIdOf(currentStack);
9819
9829
  newStack = [...currentStack, newContext];
9820
9830
  const inputs = args;
9821
9831
  const startedAt = nowIsoTimestamp();
@@ -9842,19 +9852,16 @@ var Bitfab = class {
9842
9852
  }
9843
9853
  self.httpClient.traceCompletion.start(traceId, spanId);
9844
9854
  startedSpan = { traceId, spanId };
9845
- const functionName = fn.name !== "" ? fn.name : void 0;
9846
- const rootTraceFunctionKey = rootTraceFunctionKeyOfTrace(
9847
- traceId,
9848
- traceFunctionKey
9849
- );
9855
+ const functionName = functionNameAtOpen;
9850
9856
  const baseSpanParams = {
9851
9857
  traceFunctionKey,
9852
- rootTraceFunctionKey,
9858
+ rootTraceFunctionKey: newContext.rootTraceFunctionKey,
9853
9859
  functionName,
9854
- spanName: options.name ?? options.nameFor?.(this) ?? qualifiedSpanName(this, functionName) ?? traceFunctionKey,
9860
+ spanName: newContext.spanName,
9855
9861
  traceId,
9856
9862
  spanId,
9857
9863
  parentSpanId,
9864
+ nearestCapturedAncestorSpanId,
9858
9865
  inputs,
9859
9866
  startedAt,
9860
9867
  spanType: options.type ?? "custom",
@@ -10373,6 +10380,21 @@ var Bitfab = class {
10373
10380
  ...params.testRunId && { testRunId: params.testRunId }
10374
10381
  });
10375
10382
  }
10383
+ sendsSpanOnCompletion(context) {
10384
+ return context.isRoot || context.declaredNode || isFrameworkInstrumentation(context.instrumentation) || !this.simulationPlan.contentOffNow(
10385
+ context.rootTraceFunctionKey,
10386
+ context.spanName
10387
+ );
10388
+ }
10389
+ nearestCapturedAncestorSpanIdOf(stack) {
10390
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
10391
+ const candidate = stack[index];
10392
+ if (candidate !== void 0 && this.sendsSpanOnCompletion(candidate)) {
10393
+ return candidate.spanId;
10394
+ }
10395
+ }
10396
+ return null;
10397
+ }
10376
10398
  contentOffBySimulationPlan(params) {
10377
10399
  if (params.rootTraceFunctionKey === void 0 || isFrameworkInstrumentation(params.instrumentation)) {
10378
10400
  return false;
@@ -10449,6 +10471,9 @@ var Bitfab = class {
10449
10471
  if (params.parentSpanId) {
10450
10472
  externalSpan.parent_id = params.parentSpanId;
10451
10473
  }
10474
+ if (params.nearestCapturedAncestorSpanId !== void 0 && params.nearestCapturedAncestorSpanId !== null && params.nearestCapturedAncestorSpanId !== params.parentSpanId) {
10475
+ externalSpan.nearest_captured_ancestor_id = params.nearestCapturedAncestorSpanId;
10476
+ }
10452
10477
  if (params.inputSourceSpanId) {
10453
10478
  externalSpan.input_source_span_id = params.inputSourceSpanId;
10454
10479
  }