SentryTracesSampleRate
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.
Details
at line 39
__construct(float $sampleRate)
Create a new middleware instance.
at line 50
void
handle(object $job, Closure $next)
Handle the queued job.