Add support for custom tags via CC_LANGFUSE_TAGS - #37
Conversation
|
Hi @choonchernlim — I needed this exact capability and ended up building on your PR, so credit where it's due: the option name, the placement in get_trace_tags() and even the make_plain_assistant_row test helper here are yours. I've opened #61 as a superset, and filed #62 for the underlying need. Four gaps it closes, in case you'd rather fold them in here — I'd genuinely prefer that, and would close mine:
One thing I hit that isn't obvious: if you add a warning for malformed input, it can't be logged from the constant. CUSTOM_TAGS is evaluated at import time, before info() and _get_logger() exist — and _get_logger() swallows exceptions, so an inline log call there doesn't crash, it silently does nothing. _resolve_state_dir() already solves this by returning (value, warning) and letting main() emit it. |
Add support for custom tags via
CC_LANGFUSE_TAGSSummary
Adds an optional
CC_LANGFUSE_TAGSenvironment variable that lets users append custom, static tags to every trace produced by the Langfuse hook - useful for filtering/grouping traces by environment, team, project, etc. in Langfuse. This is very similar to Codex'sLANGFUSE_CODEX_TAGS(link)Changes
hooks/langfuse_hook.py: ReadsCC_LANGFUSE_TAGSas a comma-separated list, trims whitespace, and drops empty entries. The resultingCUSTOM_TAGSlist is appended to the base"claude-code"tag inget_trace_tags(), before anyskill-derived tags.
.claude-plugin/plugin.json: RegistersCC_LANGFUSE_TAGSas an optional string config option with a title and description.README.md: Documents the new environment variable in the configuration table.tests/unit/test_skill_tags.py: Adds coverage for:Usage
Every trace will then be tagged
["claude-code", "env:prod", "team:platform", ...], with any skill tags appended after.Test plan
pytest tests/unit/test_skill_tags.py- all new and existing tests passCC_LANGFUSE_TAGSset) leaves trace tags unchanged