fix(langfuse): v4 가 옛 ingestion 을 거부 — OTLP/HTTP JSON(/api/public/otel/v1/traces)으로 전환, 로컬 Langfuse 실측 통과. 사용자·세션 속성은 자식 span 에도 복사
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
0321050053
commit
55f2e8fb60
@@ -256,13 +256,14 @@ async def _finalize(session: ChatSession, state: TurnState, started: float, *, f
|
||||
tid = f"{session.id}-{int(started * 1000)}"
|
||||
user_email = await sync_to_async(lambda: session.user.email)()
|
||||
meta = {"failed": failed} if failed else {}
|
||||
t0 = datetime.fromtimestamp(started, timezone.utc).isoformat()
|
||||
root = langfuse.trace(tid, "chat", userId=user_email, sessionId=session.id, input=state.user_text,
|
||||
output=content, metadata=meta, tags=["codeassist"], start=t0, end=langfuse.now_iso())
|
||||
langfuse.send_later([
|
||||
langfuse.trace(tid, "chat", userId=user_email, sessionId=session.id, input=state.user_text,
|
||||
output=content, metadata=meta, tags=["codeassist"]),
|
||||
root,
|
||||
langfuse.generation(
|
||||
tid, "opencode-turn",
|
||||
startTime=datetime.fromtimestamp(started, timezone.utc).isoformat(),
|
||||
endTime=langfuse.now_iso(),
|
||||
tid, "opencode-turn", parent=root,
|
||||
startTime=t0, endTime=langfuse.now_iso(),
|
||||
input=state.user_text, output=content,
|
||||
usage=langfuse.usage_of(usage["input"], usage["output"]) if usage else None,
|
||||
level="ERROR" if failed else "DEFAULT", statusMessage=failed or "",
|
||||
|
||||
Reference in New Issue
Block a user