class SentryTracesSampleRate

Job middleware that overrides the Sentry trace sampling decision for the job's transaction.

When applied to a job, this middleware re-samples the transaction at the given rate, allowing you to control trace volume for specific jobs independently of the global sample rate.

If the transaction was not sampled by the global traces_sample_rate or traces_sampler, this middleware will not force-enable it — it can only downsample, not upsample.

A job that runs within another transaction, such as one dispatched synchronously during a request, leaves that transaction's sampling decision unchanged.

Usage:

public function middleware(): array
{
    return [
        new SentryTracesSampleRate(0.1), // Sample 10% of this job's traces
    ];
}

Methods

__construct(float $sampleRate)

Create a new middleware instance.

void
handle(object $job, Closure $next)

Handle the queued job.

Details

at line 39
__construct(float $sampleRate)

Create a new middleware instance.

Parameters

float $sampleRate

A value between 0.0 (never sampled) and 1.0 (always sampled)

at line 50
void handle(object $job, Closure $next)

Handle the queued job.

Parameters

object $job
Closure $next

Return Value

void