Repository navigation
feat(hook): accept caller trace tags via CC_LANGFUSE_TRACE_TAGS - #87
Merged
hassiebp merged 2 commits intoSep 9, 2026
Conversation
…de-the-hook-operator-tags
This was referenced Oct 15, 2026
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.
What
CC_LANGFUSE_TRACE_TAGSadds a caller's own tags to every trace, next toclaude-codeand theskill:*tags. The value is either a JSON array (["lane:review","env:prod"]) or a comma-separated list (lane:review,env:prod).Blank and duplicate entries are dropped; entries over 200 characters, and anything past the first 20, are dropped with a log line.
Refs #62 and the tag half of #69. Neither is closed by this PR — see the two notes below.
Why one variable serves both issues
#69 asks for a JSON array. #62 asks for a comma-separated list and argues for tags over metadata. The reference both issues point at, the sibling
codex-observability-plugin, already accepts both shapes in one variable: it parses JSON when the value starts with[and falls back to comma splitting. This PR does the same.Two decisions a reviewer should confirm
Tags only. The metadata half of #69 is left out on purpose. Measured against the live API:
?tags=lane:reviewfilters correctly, while?metadata={"lane":"review"}is silently ignored and returns unfiltered results.Verification
End to end against a live Langfuse, same transcript and same environment variable in each run, only the hook differs:
CC_LANGFUSE_TRACE_TAGSmain["lane:review","env:prod"]['claude-code']["lane:review","env:prod"]['claude-code', 'env:prod', 'lane:review']lane:executor,env:staging['claude-code', 'env:staging', 'lane:executor']{"lane":"review"}['claude-code'], with a diagnosticThe before run had the variable set as well; the old hook simply does not read it. In every run the trace still exported, including the rejected one, so telemetry stays best-effort.
The lane use case from #69, checked server-side:
?tags=lane:review,?tags=lane:executorand?tags=lane:scheduledeach return only their own session, and?tags=env:prodreturns all of them. No use of the deploymentenvironmentfield.Tests: 247 pass, up from 228. All 19 new tests fail without the change.
Linear: LFE-16088