Users

The Users view provides an overview of all users. It also offers an in-depth look into individual users.

It’s easy to map data in Langfuse to individual users. Just pass a unique identifier as the userId when you create a trace. This can be a username, email, or any other unique identifier. The userId is optional, but using it helps you get more from Langfuse. See the integration docs to learn more.

The v3 SDK is currently in beta. Please check out the SDK v3 for more details.

When using the @observe() decorator:

from langfuse import observe, get_client
 
langfuse = get_client()
 
@observe()
def process_user_request(user_query):
    # Add user_id to the current trace
    langfuse.update_current_trace(user_id="user_12345")
 
    # ...your processing logic...
    return result

When creating spans directly:

from langfuse import Langfuse
 
langfuse = Langfuse()
 
# You can set the user_id when creating the root span via update_trace
with langfuse.start_as_current_span(
    name="process-user-request"
) as root_span:
    # Add user_id to the trace
    root_span.update_trace(user_id="user_12345")
 
    # All spans in this trace will be associated with this user
    with root_span.start_as_current_generation(
        name="generate-response",
        model="gpt-4o"
    ) as gen:
        # ...generate response...
        pass

You can also update the user_id of the current trace without a direct reference to a span:

with langfuse.start_as_current_span(name="handle-user-interaction"):
    # Add user_id to the current trace
    langfuse.update_current_trace(user_id="user_12345")

View all users

The user list provides an overview of all users that have been tracked by Langfuse. It makes it simple to segment by overall token usage, number of traces, and user feedback.

User List

Individual user view

The individual user view provides an in-depth look into a single user. Explore aggregated metrics or view all traces and feedback for a user.

You can deep link to this view via the following URL format: https://<hostname>/project/{projectId}/users/{userId}

GitHub Discussions

Was this page useful?

Questions? We're here to help

Subscribe to updates