Skip to content

feat: configurable trace tags via config file or LANGFUSE_TAGS - #35

Open
AdJIa wants to merge 1 commit into
langfuse:mainfrom
AdJIa:feat/configurable-trace-tags
Open

feat: configurable trace tags via config file or LANGFUSE_TAGS#35
AdJIa wants to merge 1 commit into
langfuse:mainfrom
AdJIa:feat/configurable-trace-tags

Conversation

@AdJIa

@AdJIa AdJIa commented Aug 31, 2026

Copy link
Copy Markdown

Closes #34

What

Adds configurable Langfuse trace tags to every exported span, via:

  1. tags array in ~/.config/opencode/opencode-langfuse.json (same file as publicKey/secretKey/environment/userId/serviceName)
  2. LANGFUSE_TAGS env 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 manual dist/index.js patching (which every plugin update wipes).

How

  • LangfuseCredentialsSchema gains an optional tags: Array<NonEmptyString> (max 50) field — config-file path.
  • parseTagsEnv parses LANGFUSE_TAGS for the env-var path.
  • Both merge in LangfuseClientService before createLangfuseClient({ ..., tags }).
  • makeTraceTagsSpanProcessor(tags) — a new SpanProcessor following the existing makeUserIdSpanProcessor pattern — sets the langfuse.trace.tags OTTL attribute on every span, which @langfuse/core maps to Langfuse trace tags.
  • No tags configured → processor not added → zero behavior change for existing users.

Testing

  • pnpm run build
  • pnpm run lint
  • pnpm run format:check
  • pnpm run test:integration — 18/18 passed ✅
  • End-to-end against self-hosted Langfuse v4.15.0 (events_only mode): verified via local OTLP sniffer that exported spans contain langfuse.trace.tags = ["opencode"], and the tag renders in the Langfuse UI trace list.

README

Documented the tags config field and LANGFUSE_TAGS env var with examples.

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).
@CLAassistant

CLAassistant commented Aug 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

Feature: configurable trace tags (filter traces by agent/tool in shared projects)

2 participants