Outsource Laravel Development Partner - $3200/Month | Bacancy

Record and Replay Requests With Laravel ChronoTrace

Last updated on by

Record and Replay Requests With Laravel ChronoTrace image

Laravel ChronoTrace

The Laravel ChronoTrace package enables you to record and replay Laravel requests deterministically and generate tests from production traces. This package can help you trace external HTTP requests made during execution, including request/response details, status codes, connection issues, and more. It also tracks database queries, cache events, queue jobs, and custom events.

After a trace is captured, you can replay it to show all the information gathered (which is configurable) during the trace:

=== TRACE INFORMATION ===
πŸ†” Trace ID: a1b2c3d4-e5f6-7890-abcd-ef1234567890
πŸ•’ Timestamp: 2024-01-15 14:30:22
🌍 Environment: local
πŸ”— Request URL: http://localhost:8000/api/users
πŸ“Š Response Status: 200
⏱️ Duration: 245ms
πŸ’Ύ Memory Usage: 18.45 KB
 
=== CAPTURED EVENTS ===
πŸ“Š DATABASE EVENTS
πŸ” [14:30:22.123] Query: SELECT * FROM users WHERE active = ? (15ms on mysql)
πŸ” [14:30:22.145] Query: SELECT * FROM roles WHERE user_id IN (?, ?, ?) (8ms on mysql)
 
πŸ—„οΈ CACHE EVENTS
❌ [14:30:22.120] Cache MISS: users:list (store: redis)
πŸ’Ύ [14:30:22.150] Cache WRITE: users:list (store: redis)
 
🌐 HTTP EVENTS
πŸ“€ [14:30:22.200] HTTP Request: GET https://api.external.com/validation
πŸ“₯ [14:30:22.230] HTTP Response: GET https://api.external.com/validation β†’ 200
 
πŸ“ˆ EVENTS SUMMARY
πŸ“Š Database events: 2
πŸ—„οΈ Cache events: 2
🌐 HTTP events: 2
βš™οΈ Job events: 0
πŸ“ Total events: 6

Another interesting feature is generating a test from a specific trace that you've recordedβ€”recording frequency can be configured as always, sample rate, error-only, etc. Once you have a trace you want to convert into a test, you can run the replay command with the --generate-test flag:

php artisan chronotrace:replay a1b2c3d4 \
--generate-test \
--test-path=tests/Integration

Main Features

  • Smart Recording – Multiple recording modes: always, sample rate, error-only, or targeted routes
  • Comprehensive Event Capture – Database queries, cache operations, HTTP requests, queue jobs, and custom events
  • Detailed Replay – View complete execution flow with timestamps and performance metrics
  • Flexible Filtering – Focus on specific event types (DB, cache, HTTP, jobs) during analysis
  • Multiple Storage Options – Local storage, S3, or custom storage adapters
  • PII Scrubbing – Automatically mask sensitive data (passwords, tokens, emails, etc.)
  • Async Storage – Queue-based storage for minimal performance impact
  • Automatic Cleanup – Configurable retention policies and automatic purging

I would recommend checking out the Basic Usage examples for real-world ideas on how to use this package. The usage examples illustrate common workflows such as development, bug investigation, and more.

You can get started with this package on GitHub: Grazulex/laravel-chronotrace.

To install this in your application (Laravel v12.x+ and PHP 8.3+) with Composer, require it as a development dependency and run the install command:

composer require --dev grazulex/laravel-chronotrace
php artisan chronotrace:install
Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
A new beta of Laravel Wayfinder just dropped image

A new beta of Laravel Wayfinder just dropped

Read article
Ben Bjurstrom: Laravel is the best Vibecoding stack for 2026 image

Ben Bjurstrom: Laravel is the best Vibecoding stack for 2026

Read article
Laravel Altitude - Opinionated Claude Code agents and commands for TALL stack development image

Laravel Altitude - Opinionated Claude Code agents and commands for TALL stack development

Read article
JSON:API Resource in Laravel 12.45 image

JSON:API Resource in Laravel 12.45

Read article
Caching With MongoDB for Faster Laravel Apps image

Caching With MongoDB for Faster Laravel Apps

Read article
Laravel 12.44 Adds HTTP Client afterResponse() Callbacks image

Laravel 12.44 Adds HTTP Client afterResponse() Callbacks

Read article