Skip to content

Conversation

@Raviguntakala
Copy link
Contributor

Summary

Adds userId and sessionId to experimental_telemetry.metadata across all AI SDK calls, enabling session-level trace grouping in observability platforms.

Motivation

Currently, OpenCode emits OTEL traces for cost and token usage tracking, but lacks user/session context. This makes it difficult to:

  • Group traces by user sessions
  • Track conversation flows end-to-end
  • Correlate multiple LLM calls within a single session

Testing

  • Tested with Langfuse ✅ - traces correctly group by session and display user attribution
  • No impact on existing functionality when OTEL is disabled

@rekram1-node rekram1-node merged commit 8326640 into anomalyco:dev Dec 9, 2025
3 of 4 checks passed
@omercnet
Copy link

@Raviguntakala how did you test this with langfuse? I'm not seeing the session/user grouping
check out https://github.com/omercnet/opencode-plugin-langfuse let me know if I'm doing something wrong

@Raviguntakala
Copy link
Contributor Author

Raviguntakala commented Jan 13, 2026

@Raviguntakala how did you test this with langfuse? I'm not seeing the session/user grouping check out https://github.com/omercnet/opencode-plugin-langfuse let me know if I'm doing something wrong

Hey @omercnet your plugin looks fine. No issue from Langfuse plugin side.

The reason you’re not seeing user/session grouping is from OpenCode side. After my PR got merged, Dax did a rework on the LLM calls and in that rework the userId and sessionId propagation got removed (not being passed into experimental_telemetry.metadata for LLM calls).

So Langfuse is receiving spans, but without userId/sessionId metadata, it can’t show user level / session level grouping.

I’ll raise another PR with the latest code changes to restore passing userId and sessionId across all LLM calls.

@Raviguntakala
Copy link
Contributor Author

@Raviguntakala how did you test this with langfuse? I'm not seeing the session/user grouping check out https://github.com/omercnet/opencode-plugin-langfuse let me know if I'm doing something wrong

Opened a follow up PR to fix this: #8195

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants