feat: configurable trace tags via config file or LANGFUSE_TAGS - #35
Open
AdJIa wants to merge 1 commit into
Open
Conversation
Add an optional 'tags' field (array of strings) to the credentials config and a LANGFUSE_TAGS environment variable (comma-separated). Both sources are merged and de-duplicated, capped at 50 tags. Tags are attached to every exported span as the 'langfuse.trace.tags' OTTL attribute, which @langfuse/core maps to Langfuse trace tags in the UI — enabling filtering traces by tool/environment in shared projects. Implementation follows the existing span-processor pattern (makeUserIdSpanProcessor / makePluginVersionSpanProcessor).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #34
What
Adds configurable Langfuse trace tags to every exported span, via:
tagsarray in~/.config/opencode/opencode-langfuse.json(same file as publicKey/secretKey/environment/userId/serviceName)LANGFUSE_TAGSenv var, comma-separated (opencode,production)Both sources are merged and de-duplicated (order-preserving), capped at 50 tags. Empty/whitespace segments are dropped.
Why
In shared Langfuse projects aggregating traces from multiple coding agents (Claude Code, OpenCode, ...), there is currently no way to filter OpenCode traces — the plugin sets no trace tags, while e.g. the Claude Code plugin hardcodes
claude-code. This makes per-agent dashboards/queries impossible without manualdist/index.jspatching (which every plugin update wipes).How
LangfuseCredentialsSchemagains an optionaltags: Array<NonEmptyString>(max 50) field — config-file path.parseTagsEnvparsesLANGFUSE_TAGSfor the env-var path.LangfuseClientServicebeforecreateLangfuseClient({ ..., tags }).makeTraceTagsSpanProcessor(tags)— a new SpanProcessor following the existingmakeUserIdSpanProcessorpattern — sets thelangfuse.trace.tagsOTTL attribute on every span, which@langfuse/coremaps to Langfuse trace tags.Testing
pnpm run build✅pnpm run lint✅pnpm run format:check✅pnpm run test:integration— 18/18 passed ✅langfuse.trace.tags=["opencode"], and the tag renders in the Langfuse UI trace list.README
Documented the
tagsconfig field andLANGFUSE_TAGSenv var with examples.