class QueueIntegration extends Feature

Traits

Track pushed scopes and spans using coroutine-local storage.

Constants

private QUEUE_SPAN_OP_QUEUE_PUBLISH

private QUEUE_PAYLOAD_BAGGAGE_DATA

private QUEUE_PAYLOAD_TRACE_PARENT_DATA

private QUEUE_PAYLOAD_PUBLISH_TIME

private QUEUE_PAYLOAD_DESTINATION_NAME

private QUEUE_SPAN_DATA_ARGUMENTS

private JOB_FRAMES_CONTEXT_KEY

Methods

__construct(Container $container)

Create a new feature instance.

from  Feature
bool
isApplicable()

Indicate if the feature is applicable to the current environment.

void
register()

Register the feature in the environment.

from  Feature
void
onBoot()

Set up the feature in the environment.

void
onBootInactive()

Set up the feature in the environment in an inactive state (when no DSN was set).

from  Feature
void
boot()

Initialize the feature.

from  Feature
void
bootInactive()

Initialize the feature in an inactive state (when no DSN was set).

from  Feature
array
getUserConfig()

Retrieve the user configuration.

from  Feature
bool
shouldSendDefaultPii()

Determine if default PII should be sent.

from  Feature
bool
shouldCollectGenAiInputs()

Determine whether AI inputs may be collected.

from  Feature
bool
shouldCollectGenAiOutputs()

Determine whether AI outputs may be collected.

from  Feature
bool
isTracingFeatureEnabled(string $feature, bool $default = true)

Indicate if the given feature is enabled for tracing.

from  Feature
bool
isBreadcrumbFeatureEnabled(string $feature, bool $default = true)

Indicate if the given feature is enabled for breadcrumbs.

from  Feature
bool
canRecordSpans()

Determine if the active SDK client can record spans.

from  Feature
bool
canRecordBreadcrumbs()

Determine if the active SDK client can record breadcrumbs.

from  Feature
void
pushSpan(Span $span)

Push a span onto the coroutine-local stack and set it as current on the hub.

Scope
pushScope()

Push a scope for the job with fresh breadcrumbs and propagation context.

void
trackLocalSpan(string $key, Span $span)

Track an operation-local span without making it current on the Hub.

Span|null
maybePopSpan()

Pop a span from the coroutine-local stack and restore the parent span.

void
maybePopScope()

Pop a scope from the hub if one was pushed in this coroutine.

Span|null
maybeFinishSpan(SpanStatus|null $status = null)

Finish the current span if one exists on the coroutine-local stack.

Span|null
maybeFinishLocalSpan(string $key, SpanStatus|null $status = null)

Finish an operation-local span by key if one exists.

Span|null
getParentSpanIfSampled()

Get the current span if it is sampled.

void
withParentSpanIfSampled(callable $callback)

Call the callback with the current span if it is sampled.

SpanStatus|null
cancellationStatus(Throwable $cancellation, Throwable|null $exception = null)

Get the status of an operation that cancellation stopped.

void
handleJobQueueingEvent(JobQueueing $event)

Start a publish span for the job being queued.

void
handleJobQueuedEvent(JobQueued $event)

Finish the publish span of the queued job.

void
handleJobQueueingFailedEvent(JobQueueingFailed $event)

Finish the publish span of the job that failed to queue.

void
handleJobQueueingCanceledEvent(JobQueueingCanceled $event)

Finish the publish span of the job whose queueing was canceled.

void
handleJobProcessedQueueEvent(JobProcessed $event)

Finish the process span and pop the scope of the processed job.

void
handleJobProcessingQueueEvent(JobProcessing $event)

Push a scope and start a process span or transaction for the job being processed.

void
handleJobFailedEvent(JobFailed $event)

Handle a permanently failed job.

void
handleJobAttemptedEvent(JobAttempted $event)

Mark the job attempt as ended.

void
handleWorkerStoppingQueueEvent(WorkerStopping $event)

Drain pending events before the worker stops gracefully.

void
handleJobExceptionOccurredQueueEvent(JobExceptionOccurred $event)

Finish the process span of the job that threw an exception.

static Transaction|null
currentJobTransaction()

Get the transaction started for the job running in this coroutine.

Details

in Feature at line 35
__construct(Container $container)

Create a new feature instance.

Parameters

Container $container

at line 69
bool isApplicable()

Indicate if the feature is applicable to the current environment.

Return Value

bool

in Feature at line 48
void register()

Register the feature in the environment.

Return Value

void

at line 77
void onBoot()

Set up the feature in the environment.

Return Value

void

in Feature at line 64
void onBootInactive()

Set up the feature in the environment in an inactive state (when no DSN was set).

Return Value

void

in Feature at line 71
void boot()

Initialize the feature.

Return Value

void

in Feature at line 81
void bootInactive()

Initialize the feature in an inactive state (when no DSN was set).

Return Value

void

in Feature at line 91
protected array getUserConfig()

Retrieve the user configuration.

Return Value

array

in Feature at line 99
protected bool shouldSendDefaultPii()

Determine if default PII should be sent.

Return Value

bool

in Feature at line 113
protected bool shouldCollectGenAiInputs()

Determine whether AI inputs may be collected.

Return Value

bool

in Feature at line 121
protected bool shouldCollectGenAiOutputs()

Determine whether AI outputs may be collected.

Return Value

bool

in Feature at line 146
protected bool isTracingFeatureEnabled(string $feature, bool $default = true)

Indicate if the given feature is enabled for tracing.

Parameters

string $feature
bool $default

Return Value

bool

in Feature at line 159
protected bool isBreadcrumbFeatureEnabled(string $feature, bool $default = true)

Indicate if the given feature is enabled for breadcrumbs.

Parameters

string $feature
bool $default

Return Value

bool

in Feature at line 182
protected bool canRecordSpans()

Determine if the active SDK client can record spans.

Return Value

bool

in Feature at line 196
protected bool canRecordBreadcrumbs()

Determine if the active SDK client can record breadcrumbs.

Return Value

bool

protected void pushSpan(Span $span)

Push a span onto the coroutine-local stack and set it as current on the hub.

Parameters

Span $span

Return Value

void

at line 513
protected Scope pushScope()

Push a scope for the job with fresh breadcrumbs and propagation context.

Return Value

Scope

protected void trackLocalSpan(string $key, Span $span)

Track an operation-local span without making it current on the Hub.

Parameters

string $key
Span $span

Return Value

void

protected Span|null maybePopSpan()

Pop a span from the coroutine-local stack and restore the parent span.

Return Value

Span|null

protected void maybePopScope()

Pop a scope from the hub if one was pushed in this coroutine.

Return Value

void

protected Span|null maybeFinishSpan(SpanStatus|null $status = null)

Finish the current span if one exists on the coroutine-local stack.

Parameters

SpanStatus|null $status

Return Value

Span|null

protected Span|null maybeFinishLocalSpan(string $key, SpanStatus|null $status = null)

Finish an operation-local span by key if one exists.

Parameters

string $key
SpanStatus|null $status

Return Value

Span|null

in WorksWithSpans at line 18
protected Span|null getParentSpanIfSampled()

Get the current span if it is sampled.

Return Value

Span|null

in WorksWithSpans at line 35
protected void withParentSpanIfSampled(callable $callback)

Call the callback with the current span if it is sampled.

Parameters

callable $callback

Return Value

void

in WorksWithSpans at line 53
protected SpanStatus|null cancellationStatus(Throwable $cancellation, Throwable|null $exception = null)

Get the status of an operation that cancellation stopped.

A direct cancellation with no earlier failure leaves the status unset: it is control flow, and the SDK has no canceled status. A known failure, or a cleanup failure carrying the cancellation, is an error.

Parameters

Throwable $cancellation
Throwable|null $exception

Return Value

SpanStatus|null

at line 121
void handleJobQueueingEvent(JobQueueing $event)

Start a publish span for the job being queued.

Parameters

JobQueueing $event

Return Value

void

at line 161
void handleJobQueuedEvent(JobQueued $event)

Finish the publish span of the queued job.

Parameters

JobQueued $event

Return Value

void

at line 169
void handleJobQueueingFailedEvent(JobQueueingFailed $event)

Finish the publish span of the job that failed to queue.

Parameters

JobQueueingFailed $event

Return Value

void

at line 177
void handleJobQueueingCanceledEvent(JobQueueingCanceled $event)

Finish the publish span of the job whose queueing was canceled.

Parameters

JobQueueingCanceled $event

Return Value

void

at line 189
void handleJobProcessedQueueEvent(JobProcessed $event)

Finish the process span and pop the scope of the processed job.

Parameters

JobProcessed $event

Return Value

void

at line 212
void handleJobProcessingQueueEvent(JobProcessing $event)

Push a scope and start a process span or transaction for the job being processed.

Parameters

JobProcessing $event

Return Value

void

at line 314
void handleJobFailedEvent(JobFailed $event)

Handle a permanently failed job.

Finishes the span with an error status but does not pop the scope — breadcrumbs need to remain available for exception reporting. Once the attempt has ended, the scope is discarded when the next job starts or when the parent job completes.

Parameters

JobFailed $event

Return Value

void

at line 326
void handleJobAttemptedEvent(JobAttempted $event)

Mark the job attempt as ended.

A failed job can keep running and dispatch other jobs, so a retained scope is only discarded once its attempt has ended. A canceled attempt skipped the processed and failed events, so its span finishes here.

Parameters

JobAttempted $event

Return Value

void

at line 352
void handleWorkerStoppingQueueEvent(WorkerStopping $event)

Drain pending events before the worker stops gracefully.

Parameters

WorkerStopping $event

Return Value

void

at line 364
void handleJobExceptionOccurredQueueEvent(JobExceptionOccurred $event)

Finish the process span of the job that threw an exception.

Parameters

JobExceptionOccurred $event

Return Value

void

at line 376
static Transaction|null currentJobTransaction()

internal  
 

Get the transaction started for the job running in this coroutine.

A job that runs within another transaction, or without a span, has none.

Return Value

Transaction|null