Tagging traces
Tags allow you to categorize and filter traces. You can tag traces only from the Langfuse SDKs or from the Langfuse UI. To tag a trace, add a list of tags to the tags field of the trace object. Tags are strings and a trace may have multiple tags.
Decorators
from langfuse.decorators import langfuse_context, observe
@observe()
def fn():
langfuse_context.update_current_trace(
tags=["my-first-tag", "even-better-tag"]
)
fn()
Low-level SDK
from langfuse import Langfuse
langfuse = Langfuse()
trace = langfuse.trace(
tags=["my-first-tag", "even-better-tag"]
)
Working with tags
Tags enable you to flexibly add metadata to your traces. You can filter for tags in the Langfuse UI and GET API (opens in a new tab).
When choosing tags, consider what aspects of the traces you might want to filter for or group by in your analysis. You may use tags to indicate specific versions of your app ('app-v1', 'app-v2'), specific LLM techniques you used ('rag', 'one-shot', 'few-shot'), or the environment of your app ('local', 'staging', 'prod').