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

Redis commands

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

  • The command
  • The command parameters
  • The namespace (database)
  • The Redis server IP & port

This functionality is disabled by default, but you can enable it by calling on the Flare config:

$config->collectRedisCommands();

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

$config->collectRedisCommands(maxItemsWithErrors: 10);

Collecting Redis commands

We cannot automatically collect Redis commands in the framework-agnostic version of the package. You can manually add Redis commands as such:

use Spatie\FlareClient\Time\TimeHelper;

$flare->redis()->record(
    command: 'SET',
    parameters: ['key', 'value'],
    duration: TimeHelper::microseconds(300),
    namespace: 'db0',
    serverIp: '192.168.0.1',
    serverPort: 6379,
);

The duration should be in milliseconds. When you have a start and end event within your code, for the event, you can use the recordStart and recordEnd methods:

$flare->redis()->recordStart(
    command: 'SET',
    parameters: ['key', 'value'],
    namespace: 'my-namespace',
    namespace: 'db0',
    serverIp: '192.168.0.1',
    serverPort: 6379,
);

// Do your redis command

$flare->redis()->recordEnd();

It is always possible to add extra attributes to the Redis command:

$flare->redis()->record(
    command: 'SET',
    parameters: ['key', 'value'],
    duration: TimeHelper::microseconds(300),
    namespace: 'db0',
    serverIp: '192.168.0.1',
    serverPort: 6379,
    attributes: [
        'redis.connection' => 'my-connection',
    ]
);
Queries Requests
  • On this page
  • Collecting Redis commands

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