Skip to main content

push_scope

Function push_scope 

Source
pub fn push_scope(params: PushScopeParams<'_>) -> Result<ScopeHandle>
Expand description

Push a new scope onto the active scope stack.

This creates a new ScopeHandle, emits a scope-start event to global and scope-local subscribers, and makes the new scope the current top of stack.

§Parameters

  • name: Human-readable scope name recorded on emitted lifecycle events.
  • scope_type: Semantic category for the new scope.
  • parent: Optional explicit parent scope. When None, the current top of stack is used as the parent.
  • attributes: Bitflags that modify scope behavior and observability.
  • data: Optional application payload stored on the returned handle.
  • metadata: Optional JSON metadata recorded on the emitted start event.
  • input: Optional JSON payload exported as the Agent Trajectory Observability Format (ATOF) data payload.
  • timestamp: Optional timestamp recorded as the handle start time and on the emitted start event. When None, the current UTC time is used.

§Returns

A Result containing the newly created ScopeHandle.

§Errors

Returns an error when the runtime owner check fails or when internal state cannot be read safely.

§Notes

The start event is queued with subscriber and sanitizer snapshots captured while the new scope is active.