http-duration-client
Measure duration (in milliseconds) for Node HTTP
lifecycle events from various phases of HTTP:
- DNS lookup
- TCP/Socket connect
- TLS connect
- First byte
- Content transfer
- Total request
Development
- To check the HTTP lifecycle events, clone this repository
git clone git@github.com:congruencelabs/http-duration-client.git
- Install the package dependencies using
yarn
yarn install
- Run the
examples/client-with-duration.js
file to see the lifecycle events being logged for a request tohttps://api.github.com/users
Usage
- Install the
http-duration-client
usingnpm
oryarn
npm install http-duration-client
or
yarn add http-duration-client
- Make an http request to an endpoint as shown in example below
const requestWithDuration = ; { iferr console; else console; });
The result of the above should look similar to
You can also use it with async
and await requestWithDuration()
or requestWithDuration().then()
async { try const resp = await ; console catcherr console }
The result of the above should look similar to