Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions javascript/examples/custom-observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"dependencies": {
"@langwatch/scenario": "workspace:*",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/sdk-trace-base": "^1.30.0",
"@opentelemetry/sdk-trace-node": "^1.30.0",
"@opentelemetry/sdk-trace-base": "^2.7.1",
"@opentelemetry/sdk-trace-node": "^2.7.1",
"tsx": "^4.19.0"
}
}
2 changes: 1 addition & 1 deletion javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@ag-ui/core": "^0.0.28",
"@ai-sdk/openai": "^3.0.26",
"@openai/agents": "^0.3.3",
"@opentelemetry/sdk-node": "0.212.0",
"@opentelemetry/sdk-node": "0.217.0",
"ai": "^6.0.0",
"chalk": "^5.6.2",
"langwatch": "0.16.1",
Expand Down
570 changes: 234 additions & 336 deletions javascript/pnpm-lock.yaml

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions javascript/src/agents/judge/judge-span-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,16 @@ export class JudgeSpanCollector implements SpanProcessor {
}

/**
* Extracts the parent span ID from a ReadableSpan, handling both OTel SDK v2
* (parentSpanId: string) and v1 (parentSpanContext: SpanContext) interfaces.
* The LangWatch SDK's internal spans still use the v1 parentSpanContext field.
* Extracts the parent span ID from a ReadableSpan.
* In OTel SDK v2, `parentSpanId` was removed from the ReadableSpan interface;
* the canonical accessor is now `parentSpanContext?.spanId`.
* Falls back to the legacy `parentSpanId` property (v1) when present at runtime.
*/
function getParentSpanId(span: ReadableSpan): string | undefined {
if (span.parentSpanId) return span.parentSpanId;
// Fall back to v1 API used by LangWatch SDK's span implementation
const legacy = (span as unknown as Record<string, unknown>).parentSpanContext as
| { spanId?: string }
| undefined;
return legacy?.spanId;
const id =
(span as unknown as Record<string, unknown>).parentSpanId ??
span.parentSpanContext?.spanId;
return typeof id === "string" ? id : undefined;
}

/**
Expand Down
16 changes: 8 additions & 8 deletions javascript/src/agents/judge/judge-span-digest-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,16 @@ export class JudgeSpanDigestFormatter {
}

/**
* Extracts the parent span ID from a ReadableSpan, handling both OTel SDK v2
* (parentSpanId: string) and v1 (parentSpanContext: SpanContext) interfaces.
* The LangWatch SDK's internal spans still use the v1 parentSpanContext field.
* Extracts the parent span ID from a ReadableSpan.
* In OTel SDK v2, `parentSpanId` was removed from the ReadableSpan interface;
* the canonical accessor is now `parentSpanContext?.spanId`.
* Falls back to the legacy `parentSpanId` property (v1) when present at runtime.
*/
function getParentSpanId(span: ReadableSpan): string | undefined {
if (span.parentSpanId) return span.parentSpanId;
const legacy = (span as unknown as Record<string, unknown>).parentSpanContext as
| { spanId?: string }
| undefined;
return legacy?.spanId;
const id =
(span as unknown as Record<string, unknown>).parentSpanId ??
span.parentSpanContext?.spanId;
return typeof id === "string" ? id : undefined;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions javascript/src/agents/judge/span-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,16 @@ export function indexSpans(spans: ReadableSpan[]): SpanNode[] {
}

/**
* Extracts the parent span ID from a ReadableSpan, handling both OTel SDK v2
* (parentSpanId: string) and v1 (parentSpanContext: SpanContext) interfaces.
* Extracts the parent span ID from a ReadableSpan.
* In OTel SDK v2, `parentSpanId` was removed from the ReadableSpan interface;
* the canonical accessor is now `parentSpanContext?.spanId`.
* Falls back to the legacy `parentSpanId` property (v1) when present at runtime.
*/
export function getParentSpanId(span: ReadableSpan): string | undefined {
if (span.parentSpanId) return span.parentSpanId;
const legacy = (span as unknown as Record<string, unknown>)
.parentSpanContext as { spanId?: string } | undefined;
return legacy?.spanId;
const id =
(span as unknown as Record<string, unknown>).parentSpanId ??
span.parentSpanContext?.spanId;
return typeof id === "string" ? id : undefined;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
},
"dependencies": {
"@opentelemetry/sdk-node": "^0.212.0",
"@opentelemetry/sdk-node": "^0.217.0",
"langwatch": "^0.16.1"
}
}
Loading