Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,33 @@ class Sentry
}
```

### Lower Sample Rate for Specific Jobs

If your application processes a large number of queued jobs, tracing every job at the same rate as your HTTP requests can create more transaction volume than you need. Use the `Sentry\Laravel\Jobs\Middleware\SentryTracesSampleRate` job middleware to keep fewer traces for specific jobs while leaving your global tracing configuration unchanged.

This middleware only affects queue job transactions, so `tracing.queue_job_transactions` must stay enabled. It can only lower the sample rate for jobs that were already sampled by your global `traces_sample_rate` or `traces_sampler`; it does not upsample jobs that were excluded earlier.

```php {filename:app/Jobs/ProcessPodcast.php}
<?php

namespace App\Jobs;

use Illuminate\Contracts\Queue\ShouldQueue;
use Sentry\Laravel\Jobs\Middleware\SentryTracesSampleRate;

class ProcessPodcast implements ShouldQueue
{
public function middleware(): array
{
return [
new SentryTracesSampleRate(0.1), // Keep 10% of already-sampled traces for this job
];
}
}
```

This is useful for high-volume or lower-priority background work, such as imports, notifications, fan-out jobs, or other queue consumers where you still want representative performance data without sending every transaction.

### More Configuration

You can also configure which parts of your application are traced automatically.
Expand Down
2 changes: 2 additions & 0 deletions docs/platforms/php/guides/laravel/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ The example configuration above will transmit 100% of captured traces. Be sure t

You can also be more granular with the sample rate by using the `traces_sampler` option. Learn more in [Using Sampling to Filter Transaction Events](configuration/filtering/#using-sampling-to-filter-transaction-events).

If your queued jobs generate more traces than your web requests, you can also lower the sample rate for specific jobs with `Sentry\Laravel\Jobs\Middleware\SentryTracesSampleRate`. See [Laravel Options](configuration/laravel-options/#lower-sample-rate-for-specific-jobs).

Performance data is transmitted using a new event type called "transactions", which you can learn about in [Distributed Tracing](/product/sentry-basics/tracing/distributed-tracing/#traces-transactions-and-spans).

## Local Development and Testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ The example configuration above will transmit 100% of captured traces. Be sure t

You can also be more granular with the sample rate by using the `traces_sampler` option. Learn more in [Using Sampling to Filter Transaction Events](/platforms/php/guides/laravel/configuration/filtering/#using-sampling-to-filter-transaction-events).

If your queued jobs generate more traces than your web requests, you can also lower the sample rate for specific jobs with `Sentry\Laravel\Jobs\Middleware\SentryTracesSampleRate`. See [Laravel Options](/platforms/php/guides/laravel/configuration/laravel-options/#lower-sample-rate-for-specific-jobs).

Performance data is transmitted using a new event type called "transactions", which you can learn about in [Distributed Tracing](/product/sentry-basics/tracing/distributed-tracing/#traces-transactions-and-spans).

## Local Development and Testing
Expand Down
Loading