class AiTracingScope implements NonCopyableContext

internal  
 

Own the current coroutine's AI span stack while sharing invocation lookup with its children.

Constants

CONTEXT_KEY

Methods

__construct(AiTracingState $state = new AiTracingState(), AiConversation|null $conversation = null)

Create a scope with an independent span stack.

static AiTracingScope|null
current()

Return the current tracing scope without allocating tracking state.

static AiTracingScope
getOrCreate()

Return or create tracking state for sampled AI work.

static Scope
sentryScope()

Capture the SDK scope used for parent lookup, installation and restoration.

void
push(Span $span, Scope $scope)

Install a span and retain the scope it changes.

static void
finishSpan(Span $span, AiTracingScope|null $owner, SpanStatus $status)

Finish a span and restore its owner when that owner still exists.

Details

at line 29
__construct(AiTracingState $state = new AiTracingState(), AiConversation|null $conversation = null)

Create a scope with an independent span stack.

Parameters

AiTracingState $state
AiConversation|null $conversation

at line 38
static AiTracingScope|null current()

Return the current tracing scope without allocating tracking state.

Return Value

AiTracingScope|null

at line 46
static AiTracingScope getOrCreate()

Return or create tracking state for sampled AI work.

Return Value

AiTracingScope

at line 54
static Scope sentryScope()

Capture the SDK scope used for parent lookup, installation and restoration.

Return Value

Scope

at line 69
void push(Span $span, Scope $scope)

Install a span and retain the scope it changes.

Parameters

Span $span
Scope $scope

Return Value

void

at line 82
static void finishSpan(Span $span, AiTracingScope|null $owner, SpanStatus $status)

Finish a span and restore its owner when that owner still exists.

Parameters

Span $span
AiTracingScope|null $owner
SpanStatus $status

Return Value

void