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
2 changes: 1 addition & 1 deletion src/lib/langfuse/trace-proxy-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export async function traceProxyRequest(ctx: TraceContext): Promise<void> {
);

// Explicitly set trace-level input/output (propagateAttributes does not support these)
rootSpan.updateTrace({
rootSpan.setTraceIO({
input: actualRequestBody,
output: actualResponseBody,
});
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/langfuse/langfuse-trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const mockEventObs: any = {
end: mockEventEnd,
};

const mockUpdateTrace = vi.fn();
const mockSetTraceIO = vi.fn();

const mockRootSpan = {
startObservation: vi.fn(),
updateTrace: mockUpdateTrace,
setTraceIO: mockSetTraceIO,
end: mockSpanEnd,
};

Expand Down Expand Up @@ -537,7 +537,7 @@ describe("traceProxyRequest", () => {
(c: unknown[]) => c[0] === "llm-call"
);
expect(llmCall[1].output).toEqual(expectedOutput);
expect(mockRootSpan.updateTrace).toHaveBeenCalledWith(
expect(mockRootSpan.setTraceIO).toHaveBeenCalledWith(
expect.objectContaining({
output: expectedOutput,
})
Expand Down Expand Up @@ -575,7 +575,7 @@ describe("traceProxyRequest", () => {
(c: unknown[]) => c[0] === "llm-call"
);
expect(llmCall[1].output).toEqual(expectedOutput);
expect(mockRootSpan.updateTrace).toHaveBeenCalledWith(
expect(mockRootSpan.setTraceIO).toHaveBeenCalledWith(
expect.objectContaining({
output: expectedOutput,
})
Expand All @@ -602,7 +602,7 @@ describe("traceProxyRequest", () => {
);
});

test("should set trace-level input/output via updateTrace with actual bodies", async () => {
test("should set trace-level input/output via setTraceIO with actual bodies", async () => {
const { traceProxyRequest } = await import("@/lib/langfuse/trace-proxy-request");
const responseBody = { result: "ok" };

Expand All @@ -616,7 +616,7 @@ describe("traceProxyRequest", () => {
costUsd: "0.05",
});

expect(mockUpdateTrace).toHaveBeenCalledWith({
expect(mockSetTraceIO).toHaveBeenCalledWith({
input: expect.objectContaining({
model: "claude-sonnet-4-20250514",
messages: expect.any(Array),
Expand Down Expand Up @@ -882,8 +882,8 @@ describe("traceProxyRequest", () => {
const rootCall = mockStartObservation.mock.calls[0];
expect(rootCall[1].input).toEqual(JSON.parse(forwardedBody));

// updateTrace should also use forwarded body
expect(mockUpdateTrace).toHaveBeenCalledWith({
// setTraceIO should also use forwarded body
expect(mockSetTraceIO).toHaveBeenCalledWith({
input: JSON.parse(forwardedBody),
output: { ok: true },
});
Expand Down