Skip to main content
Use user_id to associate traces and sessions with a specific end user, account, organization, or tenant in your application. Unlike session_id, which groups traces into an agent lifecycle, user_id identifies who the activity belongs to. This makes it easier to filter traces, compare user experiences, and join PandaProbe data back to your own identity system.
User identifiers are strings you control. Use the same stable identifier your application already uses for the user, account, or tenant.

Context managers (scoped)

Prefer pandaprobe.user() when user attribution can be scoped to a block of code. The user is applied to all traces created inside the block and is reset when the block exits.
You can combine user and session scopes when you want both lifecycle grouping and identity attribution:

Imperative API (global)

Use set_user() when request middleware or worker setup needs to set the user once before calling into application code.
The imperative API sets the user globally for the current context. It does not automatically reset. Prefer the context manager API when possible.

Explicit parameters

Explicit parameters take precedence over scoped or global values:
Integration constructors also accept user_id: