Flare by Spatie
  • Features
  • Pricing
  • Docs
  • Blog
  • LOG IN
  • START TRACKING
  • Home
  • Features
  • Pricing
  • Docs
  • Blog
    • Try Flare for free
    • Sign in
Flare Flare Laravel Laravel PHP PHP JavaScript JavaScript
  • General
  • Introduction
  • Installation
  • Censoring collected data
  • Ignoring collected data
  • Errors
  • Adding custom context
  • Customising error grouping
  • Handling errors
  • Linking to errors
  • Reporting errors
  • Performance
  • Introduction
  • Sampling
  • Limits
  • Modify spans and events
  • Data Collection
  • Application info
  • Application lifecycle
  • Cache events
  • Console commands
  • Customise error report
  • Database transactions
  • Dumps
  • Errors when tracing
  • Exception context
  • External http requests
  • Filesystem operations
  • Git information
  • Glows
  • Identifying users
  • Logs
  • Queries
  • Redis commands
  • Requests
  • Routing
  • Server info
  • Solutions
  • Spans
  • Stacktrace arguments
  • Views
  • Older Packages
  • Flare Client PHP V1

Sampling

Flare will sample traces based upon a sampling rate. Only a certain percentage of traces will be sent to Flare. The default sampling rate is 10%, which means that of all traces, 10% will be sent to Flare.

It is possible to change the sampling rate by calling the sampleRate method on the Flare config:

$config->sampleRate(0.5); // 50% of all traces will be sent to Flare

If you always want to sample, you can set the sample rate to 1.0:

$config->sampleRate(1.0); // 100% of all traces will be sent to Flare

By default, Flare uses the RateSampler, but creating your own sampler is possible. You can do this by implementing the Sampler interface, which should return a boolean value indicating whether the trace should be sampled or not:

use Spatie\FlareClient\Sampling\Sampler;

class AlwaysSampler implements Sampler
{
    public function __construct(protected array $config) {}

    public function shouldSample(array $context): bool
    {
        return true
    }
}

The sampler then can be registered in the Flare config as such:

$config->sampler(AlwaysSampler::class, $config);

It is possible to pass a config array to the sampler, which will be injected into the sampler's constructor.

Introduction Limits

Monitor your web apps and sites from errors to slowdowns with Flare, the easiest application monitoring platform for Laravel, PHP & Javascript.

  • Platform
  • Error Tracking
  • Performance Monitoring
  • Pricing
  • Support
  • Resources
  • Blog
  • Changelog
  • Documentation
  • Affiliate program
  • Service status
  • Terms of use
  • DPA
  • Privacy & Cookie Policy
Flare