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
  • Laravel Octane
  • Errors
  • Adding custom context
  • Customising error grouping
  • Handling errors
  • Linking to errors
  • Reporting errors
  • Sending logs to Flare
  • Performance
  • Introduction
  • Sampling
  • Limits
  • Modify spans and span events
  • Data Collection
  • Application info
  • 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
  • Jobs and queues
  • Laravel context
  • Livewire
  • Logs
  • Queries
  • Redis commands
  • Requests
  • Server info
  • Solutions
  • Spans
  • Stacktrace arguments
  • Views
  • Older Packages
  • Laravel Flare V1
  • Ignition

Queries

Flare can collect information about the queries being executed in your application. This includes:

  • The query
  • The query bindings
  • The database name
  • The database driver
  • The laravel connection

This functionality is enabled by default, but you can disable it by ignoring the Queries collect in config.php:

use Spatie\FlareClient\Enums\CollectType;

'collects' => FlareConfig::defaultCollects(
    ignore: [CollectType::Queries],
),

You can configure the maximum number of queries tracked while collecting data in the case of an error as such:

'collects' => FlareConfig::defaultCollects(
    extra: [
        CollectType::Queries->value => [
            'max_items_with_errors' => 10,
        ],
    ]
),

Collection of queries will happen automatically, but it is possible to configure the collection.

Finding the origin

Database queries sometimes become a bit tricky to debug. You can find the origin of the query by setting the findOrigin parameter to true:

'collects' => FlareConfig::defaultCollects(
    extra: [
        CollectType::Queries->value => [
            'find_origin' => true,
        ],
    ]
),

Now, every query will include the file and line number where the query was executed.

If you only want to find the origins of slow queries, you can pass a findOriginThreshold parameter to the collectQueries method in milliseconds:

use Spatie\FlareClient\Time\TimeHelper;

'collects' => FlareConfig::defaultCollects(
    extra: [
        CollectType::Queries->value => [
            'find_origin_threshold' => TimeHelper::millisecond(100),
        ],
    ]
),

Now, only queries that take longer than 100 milliseconds will include the file and line number where the query was executed. By default, queries slower than 300 milliseconds will be collected.

Be careful not to set this threshold too low, as it can cause a lot of overhead in your application.

Bindings

When you're passing bindings alongside your query, Flare will automatically collect them.

It is possible to disable sending query bindings as such:

'collects' => FlareConfig::defaultCollects(
    extra: [
        CollectType::Queries->value => [
            'include_bindings' => false,
        ],
    ]
),
Logs Redis commands
  • On this page
  • Finding the origin
  • Bindings

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