Documentation Index
Fetch the complete documentation index at: https://docs.bentolabs.ai/llms.txt
Use this file to discover all available pages before exploring further.
Most apps should set identity once at
bento.init(...) — see Configuration → Identity getters. The helpers on this page cover the rare cases where init-time getters aren’t enough.user_id, session_id, and tags is the getter callables on bento.init() — they fire on every span, including ones captured by an integration. The helpers on this page exist for the cases where init-time getters aren’t a good fit:
- Identity becomes known mid-flow (e.g. after authentication inside an open trajectory).
- A worker received identity over a queue and you want to scope it to one handler invocation.
- You want to patch arbitrary attributes onto the currently-active span without restructuring the call site.
update_current_trace
Patch the OPEN trajectory’s root span. Use this when identity is known mid-flow and you want it reflected at the trace level (traces.user_id, traces.session_id, traces.tags).
gen_ai.user.id, gen_ai.conversation.id, langfuse.tags); you supply values.
Sets
gen_ai.user.id on the trajectory root.Sets
gen_ai.conversation.id on the trajectory root.Sets
langfuse.tags on the trajectory root.Arbitrary custom dimensions, written through
_coerce_property_value so types are preserved.No-op when no
bento.begin(...) is open in the current task. If you’re emitting bare track_ai calls, pass the values directly to track_ai instead.update_current_span
Set attributes on the currently active OTel span — the innermost open span, which may or may not be the trajectory root.Keys/values written to the currently active span. Same type-fidelity rules as
track_ai(properties=...) — see Properties.propagate_attributes
Scoped identity override for the current task. Per-task overrides take precedence over the global getters registered atinit().
Three-value kwargs
Each kwarg accepts three distinct values:| Pass | Effect |
|---|---|
| (omitted) | Inherit from any outer propagate_attributes scope or the global source. |
A value (e.g. user_id="u_42") | Use this value for the scope. |
Explicit None | Clear the field for the scope, shadowing any outer override and skipping the global source. |
init() resume after the block.
How they compose
The SDK resolves identity in this order, highest priority first:- Explicit kwarg on the call —
bento.track_ai(user_id="x", ...)orbento.begin(user_id="x", ...)always wins. update_current_trace(...)patches set on the trajectory root.propagate_attributes(...)scope active in the current task.- Init-time getters —
bento.init(user_id=lambda: ...)resolved per span.
None value at span-emit time is the one that lands in the dashboard.
See also
Integrations
Identity getters at
init() — the zero-code path.Trajectories
Open a
begin() block to host update_current_trace patches.