Add Tags to Traces
Adding tags to your traces for better visibility on Confident AI
Overview
Unlike metadata, which can contain complex structured data, tags are simple string labels that make it easy to group related traces together, and cannot be applied to spans.
Add Tags to Traces
Tags are applied at the trace level, making them visible for all spans within that trace. Open a trace context around the work you want to tag:
from langchain_openai import ChatOpenAI
from confident_trace import init, trace_context
init()
model = ChatOpenAI(model="gpt-4o")
def llm_app(query: str):
with trace_context(tags=["Causal Chit-Chat"]):
return model.invoke(query)import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { init, traceContext } from "confident-trace";
init();
const llmApp = (query: string) =>
traceContext({ tags: ["Causal Chit-Chat"] }, () =>
generateText({ model: openai("gpt-4o"), prompt: query }),
);Run your entry point with the Node preload so the Vercel AI SDK call is instrumented.
A trace context supplies defaults to traces started inside it and never overwrites tags already set on a trace. Tag lists are not merged, so provide every tag you want in one list. See Update Trace Properties for the full behavior.
Next Steps
Metadata
Attach structured, JSON-serializable data to traces and spans when a string label isn't enough.
Threads
Group traces into conversations and tag the whole thread instead of a single trace.
Last updated on