diff options
author | vmarchaud <contact@vmarchaud.fr> | 2019-06-30 22:37:18 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-07-12 00:36:27 +0200 |
commit | 0ebf01dc53b474ffca78c7ace023bb10341b6664 (patch) | |
tree | 47aa24677e1903e7a2d5f694b19ea12f59ad7d43 /lib/perf_hooks.js | |
parent | ca0884a60b2fc828b6ca35e9b46e6979d9024146 (diff) | |
download | android-node-v8-0ebf01dc53b474ffca78c7ace023bb10341b6664.tar.gz android-node-v8-0ebf01dc53b474ffca78c7ace023bb10341b6664.tar.bz2 android-node-v8-0ebf01dc53b474ffca78c7ace023bb10341b6664.zip |
perf_hooks: add HttpRequest statistics monitoring #28445
```js
const { PerformanceObserver, performance } = require('perf_hooks');
const http = require('http');
const obs = new PerformanceObserver((items) => {
const entry = items.getEntries()[0];
console.log(entry.name, entry.duration);
});
obs.observe({ entryTypes: ['http'] });
const server = http.Server(function(req, res) {
server.close();
res.writeHead(200);
res.end('hello world\n');
});
server.listen(0, function() {
const req = http.request({
port: this.address().port,
path: '/',
method: 'POST'
}).end();
});
```
PR-URL: https://github.com/nodejs/node/pull/28486
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/perf_hooks.js')
-rw-r--r-- | lib/perf_hooks.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index e0b7e9d960..14b1aa44dd 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -25,6 +25,7 @@ const { NODE_PERFORMANCE_ENTRY_TYPE_GC, NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION, NODE_PERFORMANCE_ENTRY_TYPE_HTTP2, + NODE_PERFORMANCE_ENTRY_TYPE_HTTP, NODE_PERFORMANCE_MILESTONE_NODE_START, NODE_PERFORMANCE_MILESTONE_V8_START, @@ -70,7 +71,8 @@ const observerableTypes = [ 'measure', 'gc', 'function', - 'http2' + 'http2', + 'http' ]; const IDX_STREAM_STATS_ID = 0; @@ -508,6 +510,7 @@ function mapTypes(i) { case 'gc': return NODE_PERFORMANCE_ENTRY_TYPE_GC; case 'function': return NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION; case 'http2': return NODE_PERFORMANCE_ENTRY_TYPE_HTTP2; + case 'http': return NODE_PERFORMANCE_ENTRY_TYPE_HTTP; } } |