Launch Week 3: Five days of launches

Group Users by Customer

Group end users by account, organization, or tenant

Overview

Use customers to group end users that belong to the same account, organization, or tenant. Setting a customer on a trace lets you filter and compare activity, quality, usage, and cost by customer in Confident AI.

Customer IDs come from your application. They do not need to be domains or Confident AI organization IDs.

Set Customers at Runtime

Use a trace context when you know the customer before an auto-instrumented call starts:

main.py
from confident_trace import trace_context

def llm_app(query: str, customer_id: str):
    with trace_context(customer_id=customer_id):
        return agent.invoke(query)

Set Customer Fields

Use the customer_id / customerId shorthand when you only need the ID. Use the structured customer object to set an ID and display name together:

main.py
with trace_context(customer={"id": "customer-42", "name": "Acme Corp"}):
    return agent.invoke(query)

Use one form or the other — the customer_id / customerId shorthand, or a customer object with id and name. Both fields are available on turn(), update_trace() / updateTrace(), and trace_context() / traceContext(). Python also accepts them when creating a span(); inside a TypeScript span() or withSpan() callback, call updateTrace().

Associate a User with a Customer

Set the customer and user on the same trace:

main.py
with trace_context(
    customer={"id": "customer-42", "name": "Acme Corp"},
    user={"id": "user-7", "name": "Marta"},
):
    agent.invoke(query)

The IDs should be stable identifiers from your application. Avoid putting secrets or credentials in IDs or names.

Next Steps

Ready to monitor AI in production?Connect traces, alerts, dashboards, and evals in one production workflowBook a demo

Last updated on

Built byConfident AI