alexeyshockov/guzzle-timeline-middleware

Timeline reports for profiling Guzzle concurrency

dev-master 2020-01-21 08:21 UTC

This package is auto-updated.

Last update: 2024-04-21 20:00:31 UTC


README

A simple helper for profiling async requests.

Basic timeline report

This report shows all the requests on a global timeline (example).

Execution flow reports

If you want to profile Guzzle's concurrency feature, then the execution flow report can help you a lot. It arranges all the requests by virtual "threads", so you are able to see (for example) how good the resource utilization is. An example report.

In your code

Install as usual, with Composer: composer require --dev alexeyshockov/guzzle-timeline-middleware

Basic usage

Just add appropriate middleware to your stack:

$handler = HandlerStack::create();
// For basic timeline report
$handler->push(TimelineReporter::middleware(__DIR__ . '/timeline.html'), 'timeline_report');
// For execution flow report
$handler->push(ExecutionFlowTimelineReporter::middleware(__DIR__ . '/ex_flow.html'), 'ex_flow_report');

$client = new \GuzzleHttp\Client([
    'handler' => $handler,
]);

Splitting a huge report into chunks

If you profile a long living process with a lot of HTTP requests, it's possible to split the report into chunks. Just use ${NUMBER} placeholder in your report file name template and pass the max number of entries per report chunk.

$handler = HandlerStack::create();
$handler->push(TimelineReporter::middleware(__DIR__ . '/timeline_${NUMBER}.html', null, 250), 'timeline_report');

$client = new \GuzzleHttp\Client([
    'handler' => $handler,
]);