From 0d99d06f06ae34b0e043f7d803d1aee9bde61090 Mon Sep 17 00:00:00 2001 From: hhs <386998068@qq.com> Date: Sun, 21 Jun 2026 22:01:27 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E9=AA=8C=E8=AF=81=20Eino=20Graph=20?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E4=BC=A0=E9=80=92=20context.Value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/trace/eino_test.go | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 backend/internal/trace/eino_test.go diff --git a/backend/internal/trace/eino_test.go b/backend/internal/trace/eino_test.go new file mode 100644 index 0000000..c42401c --- /dev/null +++ b/backend/internal/trace/eino_test.go @@ -0,0 +1,42 @@ +package trace_test + +import ( + "context" + "testing" + + "github.com/cloudwego/eino/compose" + "github.com/hhs/camtalk/internal/trace" +) + +func TestEinoContextPropagation(t *testing.T) { + ctx := context.Background() + testTraceID := "01J5TEST123456789" + ctx = trace.WithTraceID(ctx, testTraceID) + + var capturedTraceID string + + g := compose.NewGraph[string, string]() + g.AddLambdaNode("test_node", compose.InvokableLambda( + func(ctx context.Context, input string) (string, error) { + capturedTraceID = trace.GetTraceID(ctx) + return "ok", nil + }, + )) + g.AddEdge(compose.START, "test_node") + g.AddEdge("test_node", compose.END) + + runnable, err := g.Compile(ctx) + if err != nil { + t.Fatalf("compile failed: %v", err) + } + + _, err = runnable.Invoke(ctx, "test_input") + if err != nil { + t.Fatalf("invoke failed: %v", err) + } + + if capturedTraceID != testTraceID { + t.Errorf("trace_id lost in Eino propagation: got %q, want %q", + capturedTraceID, testTraceID) + } +}