Replies: 2 comments
|
Pull request: langfuse/opencode-observability-plugin#48 |
0 replies
|
Update: I've closed the pull request for now. Our own review found it should not read the session inside hooks that OpenCode waits on, so it needs a rework before it is worth a maintainer's time. The request above still stands; a simpler version would take the user only from the session events the plugin already receives. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The problem
LANGFUSE_USER_ID(oruserIdinopencode-langfuse.json) is applied to every span the OpenCode process exports. That fits one person running OpenCode in a terminal.Under
opencode serve, one process hosts sessions for several people. Every trace is then filed under one user, or under none, so the Users view and per-user cost can't be used for a served deployment.Our case:
opencode servebehind a Slack bot, where each Slack thread is one OpenCode session owned by one person. Plugin 0.5.1, OpenCode 1.18.32.Proposal
OpenCode's session API accepts free-form
metadatawhen a session is created. When a session'smetadata.userIdis a non-empty string, use it aslangfuse.user.idon every span of that session.LANGFUSE_USER_IDstays the fallback for sessions without it, so nothing changes for existing setups and there is no new configuration.Patch
I have this working and will open a pull request on
langfuse/opencode-observability-pluginand link it here. It passes the repo's format, build, lint, knip and integration checks, and I checked the OpenCode 1 path against a realopencode serve1.18.32. The OpenCode 2 path is covered by the integration tests only.Related: the configurable trace tags idea in langfuse/opencode-observability-plugin#34 is a different attribute but the same question of process-wide versus per-session values.
All reactions