PHPackages                             shrikeh/guzzle-middleware-response-timer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. shrikeh/guzzle-middleware-response-timer

ActiveLibrary[HTTP &amp; Networking](/categories/http)

shrikeh/guzzle-middleware-response-timer
========================================

Measure response times in milliseconds over synchronous or asynchronous connections

0.3.3(7y ago)36.8k2[1 issues](https://github.com/shrikeh/guzzle-middleware-responsetimer/issues)[2 PRs](https://github.com/shrikeh/guzzle-middleware-responsetimer/pulls)MITPHPPHP ^7.1

Since Sep 21Pushed 6y ago1 watchersCompare

[ Source](https://github.com/shrikeh/guzzle-middleware-responsetimer)[ Packagist](https://packagist.org/packages/shrikeh/guzzle-middleware-response-timer)[ RSS](/packages/shrikeh-guzzle-middleware-response-timer/feed)WikiDiscussions develop Synced 2d ago

READMEChangelog (10)Dependencies (14)Versions (20)Used By (0)

Response timer for Guzzle
=========================

[](#response-timer-for-guzzle)

[![build_status_img](https://camo.githubusercontent.com/c13794eebe69672561f500cf0a88e4eec1a806f8bb590dc896e7a1eec2af6c14/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f736872696b65682f67757a7a6c652d6d6964646c65776172652d726573706f6e736574696d65722e7376673f7374796c653d666c61742d737175617265 "Build Status")](https://travis-ci.org/shrikeh/guzzle-middleware-responsetimer)[![sensiolabs_insight_img](https://camo.githubusercontent.com/b8cf5c9d603d16a4f67030e323790d54f6d2f8f84b3736e018191f82ba679759/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f37363965643833352d396531372d346136662d616434352d3761653063373733346363622e7376673f7374796c653d666c61742d737175617265 "SensioLabs Insight")](https://insight.sensiolabs.com/projects/769ed835-9e17-4a6f-ad45-7ae0c7734ccb)[![code_quality_img](https://camo.githubusercontent.com/5c416d1ed8fa2a332a46b0e87f3d2033ce33acf05b43af40b52a8a4c07fef871/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736872696b65682f67757a7a6c652d6d6964646c65776172652d726573706f6e736574696d65722e7376673f7374796c653d666c61742d737175617265 "Scrutinizer Code Quality")](https://scrutinizer-ci.com/g/shrikeh/guzzle-middleware-responsetimer/?branch=master)[![latest_stable_version_img](https://camo.githubusercontent.com/e8db49fd8ade66f211aca7701d40c3dbb8247ac3f87cc7bf1d434c7bc09fc1e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736872696b65682f67757a7a6c652d6d6964646c65776172652d726573706f6e73652d74696d65722e7376673f7374796c653d666c61742d737175617265 "Latest Stable Version")](https://packagist.org/packages/shrikeh/guzzle-middleware-response-timer "Latest Stable Version")[![versioneye_dependencies_img](https://camo.githubusercontent.com/88c078cfe1e39ea85a8211579964cf6e3e0064ca061e26a1165d1fff40569c3a/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3539636137393035333638623038333230666665373130662f62616467652e7376673f7374796c653d666c61742d737175617265)](https://www.versioneye.com/user/projects/59ca7905368b08320ffe710f)[![license_img](https://camo.githubusercontent.com/3700b663ece6913ff556dac6ba24a5e178fcdfc2c98579ccc8fb81fb0a1b8524/68747470733a2f2f706f7365722e707567782e6f72672f736872696b65682f67757a7a6c652d6d6964646c65776172652d726573706f6e73652d74696d65722f6c6963656e73653f666f726d61743d666c61742d737175617265 "License")](https://packagist.org/packages/shrikeh/guzzle-middleware-response-timer)[![twitter_img](https://camo.githubusercontent.com/5f2be4219d73a80c90855af25efcd1ec32e05b2d59b68ca45951096be7d7f627/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f747769747465722d253430736872696b65682d626c75652e7376673f7374796c653d666c61742d737175617265 "@shrikeh on Twitter")](https://twitter.com/shrikeh)

A simple timer and logger that records response times for requests made by a [Guzzle](http://docs.guzzlephp.org/en/stable/) client to a [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) log. Created initially to help [Gousto](https://www.gousto.co.uk/) get an idea of how microservices were interacting and performing.

It has some advantages over some other timers that already existed, in that it natively supports asynchronous calls, and uses the `Request` object itself as the key, therefore allowing multiple calls to the same URI to be recorded separately.

Installation
------------

[](#installation)

Installation is recommended via [composer](https://getcomposer.org):

```
composer require shrikeh/guzzle-middleware-response-timer
```

Requirements and versioning
---------------------------

[](#requirements-and-versioning)

If installed by composer, all requirements should be taken care of. Semantic versioning is in use and strongly adhered to in tags 1.0 and beyond; branches before that are a little bit more free as I was shopping with ideas and the interface.

Tags &lt;2.0 are 5.6 compatible; versions 2.0 and beyond are PHP 7.1+ only.

Basic usage
-----------

[](#basic-usage)

The following is a simple example using the `quickStart()` method, which accepts a `Psr\Log\LoggerInterface` logger (in this case, a simple file stream implemented by [Monolog](https://github.com/Seldaek/monolog)):

```
