Skip to content

feat(libs_langfuse): Add UpdateTrace api#698

Open
kayoch1n wants to merge 7 commits intocloudwego:mainfrom
kayoch1n:feat/langfuse-update-trace
Open

feat(libs_langfuse): Add UpdateTrace api#698
kayoch1n wants to merge 7 commits intocloudwego:mainfrom
kayoch1n:feat/langfuse-update-trace

Conversation

@kayoch1n
Copy link
Copy Markdown
Contributor

@kayoch1n kayoch1n commented Feb 26, 2026

What type of PR is this?

feat: A new feature

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

langfuse 增加一个名为 UpdateTrace 的 API

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en: There is no event type named "trace-update". According to the langfuse api docs the only way to update a trace is to fire an event of type "trace-create" again with the same body id, while using a separate event id.

zh(optional): langfuse并没有名为 trace-update 的API;langfuse的官方文档建议用同样的trace id调用 trace-create 来达到更新trace的目的。所以这里新添加的 UpdateTrace 其实调用的还是 trace-create

The event.body.id is the ID of the actual trace and will be used for updates and will be visible within the Langfuse App. I.e. if you want to update a trace, you'd use the same body id, but separate event IDs.

(Optional) Which issue(s) this PR fixes:

#533 有关。在当前PR添加了UpdateTrace api之后,后续PR就能使用这个接口函数更新trace的input和output。

至于为什么不直接使用 CreateTrace,是考虑到单元测试中已经存在mock CreateTrace;直接用 CreateTrace会对单测有影响,而且也不够直观。

callbacks 更新trace input和output的代码已经实现了,需要在这个 pr 合入之后再提pr

(optional) The PR that updates user documentation:

@kayoch1n
Copy link
Copy Markdown
Contributor Author

kayoch1n commented Mar 2, 2026

Hi, @mrh997 是否方便review一下?目前langfuse上面的trace不显示 input和output;这里添加UpdateTrace之后,后续就可以更新 trace 的 input和output了

@shentongmartin shentongmartin added C-enhancement This is a PR that adds a new feature or fixes a bug. D-tracing Domain: this issue relates to tracing capability based on callback mechanism labels Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-enhancement This is a PR that adds a new feature or fixes a bug. D-tracing Domain: this issue relates to tracing capability based on callback mechanism

Development

Successfully merging this pull request may close these issues.

2 participants