alexeyshockov / guzzle-timeline-middleware

Helper middleware to profile Guzzle's concurrency/parallelism

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Guzzle Timeline Reports

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,
]);

About

Helper middleware to profile Guzzle's concurrency/parallelism

License:MIT License


Languages

Language:PHP 86.2%Language:HTML 13.8%