DocsFeaturesMetadata

Metadata

Traces and observations (see Langfuse Data Model) can be enriched with metadata to better understand your users, application, and experiments. Metadata can be added to traces in the form of arbitrary JSON.

When using the @observe() decorator:

from langfuse.decorators import langfuse_context, observe
 
@observe()
def fn():
    langfuse_context.update_current_trace(
        metadata={"key":"value"}
    )
 
fn()

When using the low-level SDK:

from langfuse import Langfuse
langfuse = Langfuse()
 
trace = langfuse.trace(
    metadata={"key":"value"}
)

GitHub Discussions

Was this page useful?

Questions? We're here to help

Subscribe to updates