WORK IN PROGRESS
Trace outgoing http requests for an http server and track the time spent doing CPU intensive workload during each such request and more.
When optimizing app's performance, requests to a remote server can turn out to
be the bottleneck.
breakdown helps identify such scenarios and provides
insights into the latency and CPU usage for such requests as well as for the
server endpoints themselves.
const http = ;const Breakdown = ;const b = ;bstart'/path/to/log';const middleware = b;http;
Events are logged into a newline separated JSON objects:
id- unique event id
ts- timestamp of the event in seconds (unix time)
payload- a payload object dependent on the
type- type of the event
parentId- event id of the parent or
meta- various fields pertaining to particular type of event.
- anything specific to particular event type.
spin- total CPU time in seconds spent during this event and its children
selfSpin- total CPU time in seconds spent during this event.
Supported Asynchronous Events
So far the only supported events are:
- HTTP Server requests
- HTTP Client requests
- DNS lookups
How does this work?
This work through use of
async_hooks APIs and some unfortunate use of
Node.js (semi-) internal code.
Which Node.js versions are supported?
The module was tested on Node.js versions starting from v10 and up to v14.
This software is licensed under the MIT License.
Copyright Fedor Indutny, 2020.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.