AiIntegration
class AiIntegration extends Feature
Constants
| private FEATURE_KEY |
|
| private FEATURE_KEY_INVOKE_AGENT |
|
| private FEATURE_KEY_CHAT |
|
| private FEATURE_KEY_EXECUTE_TOOL |
|
| private FEATURE_KEY_EMBEDDINGS |
|
Methods
Determine whether AI tracing is enabled and the optional package is present.
Register only the enabled AI listener families.
Set up the feature in the environment in an inactive state (when no DSN was set).
Indicate if the given feature is enabled for tracing.
Indicate if the given feature is enabled for breadcrumbs.
Start an invocation under the current sampled span.
Close a failed invocation after failed-turn persistence.
Close the failed attempt before another provider reuses the invocation ID.
Close an invocation whose consumer stopped before completion.
Capture resolved metadata and start the exact model step.
Record the model response and finish its step span.
Finish a failed model step, including failures during stream consumption.
Start a tool span without resolving its schema again.
Close a tool span when execution throws or is canceled.
Start an embeddings span under the current sampled span.
Complete embeddings with the returned model and input-token count.
Close a failed embeddings attempt by its exact invocation ID.
Method used so that other integrations that produce gen_ai spans can submit their spans here which will be populated with the conversation ID once it becomes available.
Set the conversation of the gen_ai spans started from now on in the current trace, replacing the current one.
Details
at line 87
bool
isApplicable()
Determine whether AI tracing is enabled and the optional package is present.
in
Feature at line 48
void
register()
Register the feature in the environment.
at line 96
void
onBoot()
Register only the enabled AI listener families.
in
Feature at line 64
void
onBootInactive()
Set up the feature in the environment in an inactive state (when no DSN was set).
in
Feature at line 71
void
boot()
Initialize the feature.
in
Feature at line 81
void
bootInactive()
Initialize the feature in an inactive state (when no DSN was set).
in
Feature at line 91
protected array
getUserConfig()
Retrieve the user configuration.
in
Feature at line 99
protected bool
shouldSendDefaultPii()
Determine if default PII should be sent.
in
Feature at line 113
protected bool
shouldCollectGenAiInputs()
Determine whether AI inputs may be collected.
in
Feature at line 121
protected bool
shouldCollectGenAiOutputs()
Determine whether AI outputs may be collected.
in
Feature at line 146
protected bool
isTracingFeatureEnabled(string $feature, bool $default = true)
Indicate if the given feature is enabled for tracing.
in
Feature at line 159
protected bool
isBreadcrumbFeatureEnabled(string $feature, bool $default = true)
Indicate if the given feature is enabled for breadcrumbs.
in
Feature at line 182
protected bool
canRecordSpans()
Determine if the active SDK client can record spans.
in
Feature at line 196
protected bool
canRecordBreadcrumbs()
Determine if the active SDK client can record breadcrumbs.
at line 156
void
handlePromptingAgentForTracing(PromptingAgent $event)
Start an invocation under the current sampled span.
at line 229
void
handleAgentPromptedForTracing(AgentPrompted $event)
Complete an invocation with response metadata.
at line 256
void
handleAgentFailedForTracing(AgentFailed $event)
Close a failed invocation after failed-turn persistence.
at line 264
void
handleAgentFailedOverForTracing(AgentFailedOver $event)
Close the failed attempt before another provider reuses the invocation ID.
at line 272
void
handleAgentStreamAbandonedForTracing(AgentStreamAbandoned $event)
Close an invocation whose consumer stopped before completion.
at line 313
void
handleStartingStepForTracing(StartingStep $event)
Capture resolved metadata and start the exact model step.
at line 385
void
handleStepCompletedForTracing(StepCompleted $event)
Record the model response and finish its step span.
at line 409
void
handleStepFailedForTracing(StepFailed $event)
Finish a failed model step, including failures during stream consumption.
at line 421
void
handleInvokingToolForTracing(InvokingTool $event)
Start a tool span without resolving its schema again.
at line 473
void
handleToolInvokedForTracing(ToolInvoked $event)
Record a tool result and restore its caller's span.
at line 496
void
handleToolFailedForTracing(ToolFailed $event)
Close a tool span when execution throws or is canceled.
at line 508
void
handleGeneratingEmbeddingsForTracing(GeneratingEmbeddings $event)
Start an embeddings span under the current sampled span.
at line 548
void
handleEmbeddingsGeneratedForTracing(EmbeddingsGenerated $event)
Complete embeddings with the returned model and input-token count.
at line 570
void
handleEmbeddingsFailedForTracing(EmbeddingsFailed $event)
Close a failed embeddings attempt by its exact invocation ID.
at line 583
void
attachSpanToConversation(Span $span)
Method used so that other integrations that produce gen_ai spans can submit their spans here which will be populated with the conversation ID once it becomes available.
at line 592
void
setCurrentConversationId(string|null $conversationId)
Set the conversation of the gen_ai spans started from now on in the current trace, replacing the current one.
Passing null forgets the current conversation.