For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Trust CenterStatusSupportGet a demoPlatform
DocumentationEvals API ReferenceIntegrations & OTELPlatform SettingsSelf-HostingChangelog
DocumentationEvals API ReferenceIntegrations & OTELPlatform SettingsSelf-HostingChangelog
  • Get Started
    • Introduction
    • Setup and Installation
  • LLM Evaluation
    • Introduction
    • Experiments
  • Metrics
    • Introduction
    • Metric Collections
    • Custom Metrics
  • LLM Tracing
    • Introduction
      • Name
      • Tags
      • Metadata
      • Users
    • Signals
    • Troubleshooting
  • Human-in-the-Loop
    • Introduction
    • Collect Feedback
  • Reporting & Analytics
    • Dashboards
    • Executive Insights
  • Red Teaming
    • Introduction
    • Quickstart
    • Frameworks & Policies
    • Risk Profiles
    • Red Team Using DeepTeam
  • Resources
    • Why Confident AI
    • Support
    • Data Handling
    • LLM Use Cases
LogoLogo
Trust CenterStatusSupportGet a demoPlatform
On this page
  • Overview
  • Set Users At Runtime
LLM TracingCustomize Traces

Users

Tracking user info in your traces for observability
Was this page helpful?
Previous

Projects

Send traces to different projects on Confident AI
Next
Built with

Overview

You can track user interactions with your LLM app by setting the user ID in a trace. This allows you to track things such as how much tokens each user is costing you, who interacted with your LLM app the most, etc.

Set Users At Runtime

Python
TypeScript

You can use update_current_trace to set the user_id within traces:

main.py
1from deepeval.tracing import observe, update_current_trace
2from openai import OpenAI
3
4client = OpenAI()
5
6@observe()
7def llm_app(query: str):
8 res = client.chat.completions.create(
9 model="gpt-4o",
10 messages=[{"role": "user", "content": query}]
11 ).choices[0].message.content
12
13 update_current_trace(user_id="your-user-id")
14 return res
15
16llm_app("Write me a poem.")

The user_id can be any string, including the actual IDs of customers in your own database, or even their email addresses. Everything will be viewable and searched in the UI.