langsmith 0.3.23 → 0.3.24

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.cjs CHANGED
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "RunTree", { enumerable: true, get: function () {
8
8
  var fetch_js_1 = require("./singletons/fetch.cjs");
9
9
  Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true, get: function () { return fetch_js_1.overrideFetchImplementation; } });
10
10
  // Update using yarn bump-version
11
- exports.__version__ = "0.3.23";
11
+ exports.__version__ = "0.3.24";
package/dist/index.d.ts CHANGED
@@ -2,4 +2,4 @@ export { Client, type ClientConfig, type LangSmithTracingClientInterface, } from
2
2
  export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, } from "./schemas.js";
3
3
  export { RunTree, type RunTreeConfig } from "./run_trees.js";
4
4
  export { overrideFetchImplementation } from "./singletons/fetch.js";
5
- export declare const __version__ = "0.3.23";
5
+ export declare const __version__ = "0.3.24";
package/dist/index.js CHANGED
@@ -2,4 +2,4 @@ export { Client, } from "./client.js";
2
2
  export { RunTree } from "./run_trees.js";
3
3
  export { overrideFetchImplementation } from "./singletons/fetch.js";
4
4
  // Update using yarn bump-version
5
- export const __version__ = "0.3.23";
5
+ export const __version__ = "0.3.24";
package/dist/vercel.cjs CHANGED
@@ -183,6 +183,11 @@ const RESERVED_METADATA_KEYS = [
183
183
  TRACE_METADATA_KEY.output,
184
184
  BAGGAGE_METADATA_KEY.output,
185
185
  ];
186
+ function getParentSpanId(span) {
187
+ // Backcompat shim to support OTEL 1.x and 2.x
188
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
189
+ return (span.parentSpanId ?? span.parentSpanContext?.spanId ?? undefined);
190
+ }
186
191
  /**
187
192
  * OpenTelemetry trace exporter for Vercel AI SDK.
188
193
  *
@@ -289,9 +294,12 @@ class AISDKExporter {
289
294
  return { ...rest, isEnabled: rest.isEnabled ?? defaultEnabled, metadata };
290
295
  }
291
296
  /** @internal */
292
- parseInteropFromMetadata(span) {
297
+ parseInteropFromMetadata(span, parentSpan) {
293
298
  if (!this.isRootRun(span))
294
299
  return undefined;
300
+ if (parentSpan?.name === "ai.toolCall") {
301
+ return undefined;
302
+ }
295
303
  const userTraceId = this.getSpanAttributeKey(span, RUN_ID_METADATA_KEY.output);
296
304
  const parentTrace = this.getSpanAttributeKey(span, TRACE_METADATA_KEY.output);
297
305
  if (parentTrace && userTraceId) {
@@ -580,12 +588,7 @@ class AISDKExporter {
580
588
  .sort((a, b) => sortByHr(a.startTime, b.startTime));
581
589
  for (const span of typedSpans) {
582
590
  const { traceId, spanId } = span.spanContext();
583
- const parentId =
584
- // Backcompat shim to support OTEL 1.x and 2.x
585
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
586
- span.parentSpanId ??
587
- span.parentSpanContext?.spanId ??
588
- undefined;
591
+ const parentId = getParentSpanId(span);
589
592
  this.traceByMap[traceId] ??= {
590
593
  childMap: {},
591
594
  nodeMap: {},
@@ -599,12 +602,15 @@ class AISDKExporter {
599
602
  const run = this.getRunCreate(span);
600
603
  traceMap.relativeExecutionOrder[parentRunId ?? ROOT] ??= -1;
601
604
  traceMap.relativeExecutionOrder[parentRunId ?? ROOT] += 1;
605
+ const parentSpan = parentId
606
+ ? typedSpans.find((i) => i.spanContext().spanId === parentId)
607
+ : undefined;
602
608
  traceMap.nodeMap[runId] ??= {
603
609
  id: runId,
604
610
  startTime: span.startTime,
605
611
  run,
606
612
  sent: false,
607
- interop: this.parseInteropFromMetadata(span),
613
+ interop: this.parseInteropFromMetadata(span, parentSpan),
608
614
  executionOrder: traceMap.relativeExecutionOrder[parentRunId ?? ROOT],
609
615
  };
610
616
  if (this.debug)
package/dist/vercel.js CHANGED
@@ -180,6 +180,11 @@ const RESERVED_METADATA_KEYS = [
180
180
  TRACE_METADATA_KEY.output,
181
181
  BAGGAGE_METADATA_KEY.output,
182
182
  ];
183
+ function getParentSpanId(span) {
184
+ // Backcompat shim to support OTEL 1.x and 2.x
185
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
+ return (span.parentSpanId ?? span.parentSpanContext?.spanId ?? undefined);
187
+ }
183
188
  /**
184
189
  * OpenTelemetry trace exporter for Vercel AI SDK.
185
190
  *
@@ -286,9 +291,12 @@ export class AISDKExporter {
286
291
  return { ...rest, isEnabled: rest.isEnabled ?? defaultEnabled, metadata };
287
292
  }
288
293
  /** @internal */
289
- parseInteropFromMetadata(span) {
294
+ parseInteropFromMetadata(span, parentSpan) {
290
295
  if (!this.isRootRun(span))
291
296
  return undefined;
297
+ if (parentSpan?.name === "ai.toolCall") {
298
+ return undefined;
299
+ }
292
300
  const userTraceId = this.getSpanAttributeKey(span, RUN_ID_METADATA_KEY.output);
293
301
  const parentTrace = this.getSpanAttributeKey(span, TRACE_METADATA_KEY.output);
294
302
  if (parentTrace && userTraceId) {
@@ -577,12 +585,7 @@ export class AISDKExporter {
577
585
  .sort((a, b) => sortByHr(a.startTime, b.startTime));
578
586
  for (const span of typedSpans) {
579
587
  const { traceId, spanId } = span.spanContext();
580
- const parentId =
581
- // Backcompat shim to support OTEL 1.x and 2.x
582
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
583
- span.parentSpanId ??
584
- span.parentSpanContext?.spanId ??
585
- undefined;
588
+ const parentId = getParentSpanId(span);
586
589
  this.traceByMap[traceId] ??= {
587
590
  childMap: {},
588
591
  nodeMap: {},
@@ -596,12 +599,15 @@ export class AISDKExporter {
596
599
  const run = this.getRunCreate(span);
597
600
  traceMap.relativeExecutionOrder[parentRunId ?? ROOT] ??= -1;
598
601
  traceMap.relativeExecutionOrder[parentRunId ?? ROOT] += 1;
602
+ const parentSpan = parentId
603
+ ? typedSpans.find((i) => i.spanContext().spanId === parentId)
604
+ : undefined;
599
605
  traceMap.nodeMap[runId] ??= {
600
606
  id: runId,
601
607
  startTime: span.startTime,
602
608
  run,
603
609
  sent: false,
604
- interop: this.parseInteropFromMetadata(span),
610
+ interop: this.parseInteropFromMetadata(span, parentSpan),
605
611
  executionOrder: traceMap.relativeExecutionOrder[parentRunId ?? ROOT],
606
612
  };
607
613
  if (this.debug)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.3.23",
3
+ "version": "0.3.24",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "packageManager": "yarn@1.22.19",
6
6
  "files": [
@@ -141,8 +141,10 @@
141
141
  "@langchain/langgraph": "^0.2.20",
142
142
  "@langchain/openai": "^0.3.11",
143
143
  "@opentelemetry/api": "^1.9.0",
144
+ "@opentelemetry/auto-instrumentations-node": "^0.58.0",
144
145
  "@opentelemetry/sdk-trace-base": "^2.0.0",
145
146
  "@opentelemetry/sdk-trace-node": "^2.0.0",
147
+ "@opentelemetry/sdk-node": "^0.200.0",
146
148
  "@tsconfig/recommended": "^1.0.2",
147
149
  "@types/jest": "^29.5.1",
148
150
  "@typescript-eslint/eslint-plugin": "^5.59.8",